2016-08-17 15:08:22 +00:00
|
|
|
#
|
|
|
|
# Bootloader component
|
|
|
|
#
|
|
|
|
# The bootloader is not a real component that gets linked into the project.
|
|
|
|
# Instead it is an entire standalone project ( in src/) that gets built in
|
|
|
|
# the upper projects build directory. This Makefile.projbuild provides the
|
|
|
|
# glue to build the bootloader project from the original project. It
|
|
|
|
# basically runs Make in the src/ directory but it needs to zero some variables
|
2016-08-19 06:30:39 +00:00
|
|
|
# the ESP-IDF project.mk makefile exports first, to not let them interfere.
|
2016-08-17 15:08:22 +00:00
|
|
|
#
|
2016-09-13 03:46:51 +00:00
|
|
|
ifeq ("$(IS_BOOTLOADER_BUILD)","")
|
2016-08-17 15:08:22 +00:00
|
|
|
|
|
|
|
BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
|
2016-10-06 07:05:51 +00:00
|
|
|
BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader)
|
2016-08-18 04:36:15 +00:00
|
|
|
BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
|
2016-10-04 04:38:20 +00:00
|
|
|
BOOTLOADER_SDKCONFIG=$(BOOTLOADER_BUILD_DIR)/sdkconfig
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-10-04 04:03:48 +00:00
|
|
|
# Custom recursive make for bootloader sub-project
|
|
|
|
BOOTLOADER_MAKE=$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
|
2016-10-04 04:38:20 +00:00
|
|
|
MAKEFLAGS= V=$(V) SDKCONFIG=$(BOOTLOADER_SDKCONFIG) \
|
2016-10-04 04:03:48 +00:00
|
|
|
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
|
|
|
|
2016-08-24 04:26:13 +00:00
|
|
|
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-10-04 04:38:20 +00:00
|
|
|
$(BOOTLOADER_BIN): | $(BOOTLOADER_BUILD_DIR)/sdkconfig
|
2016-10-04 04:03:48 +00:00
|
|
|
$(Q) $(BOOTLOADER_MAKE) $@
|
2016-08-17 15:08:22 +00:00
|
|
|
|
|
|
|
bootloader-clean:
|
2016-10-04 04:38:20 +00:00
|
|
|
$(Q) $(BOOTLOADER_MAKE) app-clean config-clean
|
|
|
|
$(Q) rm -f $(BOOTLOADER_SDKCONFIG) $(BOOTLOADER_SDKCONFIG).old
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-08-18 09:11:27 +00:00
|
|
|
clean: bootloader-clean
|
|
|
|
|
2016-08-18 04:36:15 +00:00
|
|
|
bootloader: $(BOOTLOADER_BIN)
|
2016-08-18 08:59:38 +00:00
|
|
|
@echo "Bootloader built. Default flash command is:"
|
2016-08-22 10:43:47 +00:00
|
|
|
@echo "$(ESPTOOLPY_WRITE_FLASH) 0x1000 $(BOOTLOADER_BIN)"
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-08-18 09:11:27 +00:00
|
|
|
all_binaries: $(BOOTLOADER_BIN)
|
|
|
|
|
|
|
|
ESPTOOL_ALL_FLASH_ARGS += 0x1000 $(BOOTLOADER_BIN)
|
|
|
|
|
2016-08-17 15:08:22 +00:00
|
|
|
# bootloader-flash calls flash in the bootloader dummy project
|
|
|
|
bootloader-flash: $(BOOTLOADER_BIN)
|
2016-10-04 04:03:48 +00:00
|
|
|
$(BOOTLOADER_MAKE) flash
|
|
|
|
|
2016-10-04 04:38:20 +00:00
|
|
|
# synchronise the project level config to the bootloader's
|
|
|
|
# config
|
|
|
|
$(BOOTLOADER_SDKCONFIG): $(PROJECT_PATH)/sdkconfig | $(BOOTLOADER_BUILD_DIR)
|
|
|
|
$(Q) cp $< $@
|
|
|
|
|
|
|
|
$(BOOTLOADER_BUILD_DIR):
|
|
|
|
$(Q) mkdir -p $@
|
2016-09-13 03:46:51 +00:00
|
|
|
|
2016-09-14 18:37:54 +00:00
|
|
|
else
|
|
|
|
CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
|
|
|
|
|
2016-09-13 03:46:51 +00:00
|
|
|
endif
|