Makefile.projbuild 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #
  2. # Bootloader component
  3. #
  4. # The bootloader is not a real component that gets linked into the project.
  5. # Instead it is an entire standalone project ( in src/) that gets built in
  6. # the upper projects build directory. This Makefile.projbuild provides the
  7. # glue to build the bootloader project from the original project. It
  8. # basically runs Make in the src/ directory but it needs to zero some variables
  9. # the ESP-IDF project.mk makefile exports first, to not let them interfere.
  10. #
  11. ifeq ("$(IS_BOOTLOADER_BUILD)","")
  12. BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
  13. BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader)
  14. BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
  15. BOOTLOADER_SDKCONFIG=$(BOOTLOADER_BUILD_DIR)/sdkconfig
  16. # Custom recursive make for bootloader sub-project
  17. BOOTLOADER_MAKE=+$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
  18. V=$(V) SDKCONFIG=$(BOOTLOADER_SDKCONFIG) \
  19. BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
  20. .PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
  21. $(BOOTLOADER_BIN): | $(BOOTLOADER_BUILD_DIR)/sdkconfig
  22. $(Q) $(BOOTLOADER_MAKE) $@
  23. bootloader-clean:
  24. $(Q) $(BOOTLOADER_MAKE) app-clean config-clean
  25. $(Q) rm -f $(BOOTLOADER_SDKCONFIG) $(BOOTLOADER_SDKCONFIG).old
  26. clean: bootloader-clean
  27. bootloader: $(BOOTLOADER_BIN)
  28. @echo "Bootloader built. Default flash command is:"
  29. @echo "$(ESPTOOLPY_WRITE_FLASH) 0x1000 $(BOOTLOADER_BIN)"
  30. all_binaries: $(BOOTLOADER_BIN)
  31. ESPTOOL_ALL_FLASH_ARGS += 0x1000 $(BOOTLOADER_BIN)
  32. # bootloader-flash calls flash in the bootloader dummy project
  33. bootloader-flash: $(BOOTLOADER_BIN)
  34. $(BOOTLOADER_MAKE) flash
  35. # synchronise the project level config to the bootloader's
  36. # config
  37. $(BOOTLOADER_SDKCONFIG): $(PROJECT_PATH)/sdkconfig | $(BOOTLOADER_BUILD_DIR)
  38. $(Q) cp $< $@
  39. $(BOOTLOADER_BUILD_DIR):
  40. $(Q) mkdir -p $@
  41. else
  42. CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
  43. endif