Makefile.projbuild 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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=$(BUILD_DIR_BASE)/bootloader
  14. BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
  15. .PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
  16. $(BOOTLOADER_BIN): $(COMPONENT_PATH)/src/sdkconfig
  17. $(Q) PROJECT_PATH= \
  18. BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
  19. $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src MAKEFLAGS= V=$(V) TARGET_BIN_LAYOUT="$(BOOTLOADER_TARGET_BIN_LAYOUT)" $(BOOTLOADER_BIN)
  20. bootloader-clean:
  21. $(Q) PROJECT_PATH= \
  22. BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
  23. $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src app-clean MAKEFLAGS= V=$(V)
  24. clean: bootloader-clean
  25. bootloader: $(BOOTLOADER_BIN)
  26. @echo "Bootloader built. Default flash command is:"
  27. @echo "$(ESPTOOLPY_WRITE_FLASH) 0x1000 $(BOOTLOADER_BIN)"
  28. all_binaries: $(BOOTLOADER_BIN)
  29. ESPTOOL_ALL_FLASH_ARGS += 0x1000 $(BOOTLOADER_BIN)
  30. # synchronise the project level config to the component's
  31. # config
  32. $(COMPONENT_PATH)/src/sdkconfig: $(PROJECT_PATH)/sdkconfig
  33. $(Q) cp $< $@
  34. # bootloader-flash calls flash in the bootloader dummy project
  35. bootloader-flash: $(BOOTLOADER_BIN)
  36. $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src flash MAKEFLAGS= V=$(V)
  37. else
  38. CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
  39. endif