123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
- BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader)
- BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
- CONFIG_SECURE_BOOT_SIGNING_KEY ?=
- SECURE_BOOT_SIGNING_KEY=$(abspath $(call dequote,$(CONFIG_SECURE_BOOT_SIGNING_KEY)))
- export SECURE_BOOT_SIGNING_KEY
- BOOTLOADER_OFFSET := 0x1000
- BOOTLOADER_MAKE= +\
- PROJECT_PATH= \
- COMPONENT_DIRS= \
- $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/subproject \
- V=$(V) \
- BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
- TEST_COMPONENTS= \
- TESTS_ALL= \
- EXCLUDE_COMPONENTS=
- .PHONY: bootloader-clean bootloader-flash bootloader-list-components bootloader $(BOOTLOADER_BIN)
- $(BOOTLOADER_BIN): $(SDKCONFIG_MAKEFILE)
- $(BOOTLOADER_MAKE) $@
- clean: bootloader-clean
- bootloader-list-components:
- $(BOOTLOADER_MAKE) list-components
- ifndef CONFIG_SECURE_BOOT_ENABLED
- bootloader: $(BOOTLOADER_BIN) | check_python_dependencies
- @echo $(SEPARATOR)
- @echo "Bootloader built. Default flash command is:"
- @echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $^"
- ESPTOOL_ALL_FLASH_ARGS += $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)
- bootloader-flash: $(BOOTLOADER_BIN) $(call prereq_if_explicit,erase_flash) | check_python_dependencies
- $(ESPTOOLPY_WRITE_FLASH) 0x1000 $^
- else ifdef CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
- bootloader: $(BOOTLOADER_BIN) | check_python_dependencies
- @echo $(SEPARATOR)
- @echo "Bootloader built. One-time flash command is:"
- @echo "$(subst hard_reset,no_reset,$(ESPTOOLPY_WRITE_FLASH)) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
- @echo $(SEPARATOR)
- @echo "* IMPORTANT: After first boot, BOOTLOADER CANNOT BE RE-FLASHED on same device"
- else ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
- ifdef CONFIG_SECURE_BOOTLOADER_KEY_ENCODING_192BIT
- KEY_DIGEST_LEN=192
- else
- KEY_DIGEST_LEN=256
- endif
- BOOTLOADER_DIGEST_BIN := $(BOOTLOADER_BUILD_DIR)/bootloader-reflash-digest.bin
- SECURE_BOOTLOADER_KEY := $(BOOTLOADER_BUILD_DIR)/secure-bootloader-key-$(KEY_DIGEST_LEN).bin
- ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
- $(SECURE_BOOTLOADER_KEY): $(SECURE_BOOT_SIGNING_KEY) | check_python_dependencies
- $(ESPSECUREPY) digest_private_key --keylen $(KEY_DIGEST_LEN) -k $< $@
- else
- $(SECURE_BOOTLOADER_KEY):
- @echo "No pre-generated key for a reflashable secure bootloader is available, due to signing configuration."
- @echo "To generate one, you can use this command:"
- @echo "espsecure.py generate_flash_encryption_key $@"
- @echo "then re-run make."
- exit 1
- endif
- bootloader: $(BOOTLOADER_DIGEST_BIN)
- @echo $(SEPARATOR)
- @echo "Bootloader built and secure digest generated. First time flash command is:"
- @echo "$(ESPEFUSEPY) burn_key secure_boot $(SECURE_BOOTLOADER_KEY)"
- @echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
- @echo $(SEPARATOR)
- @echo "To reflash the bootloader after initial flash:"
- @echo "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_DIGEST_BIN)"
- @echo $(SEPARATOR)
- @echo "* After first boot, only re-flashes of this kind (with same key) will be accepted."
- @echo "* Not recommended to re-use the same secure boot keyfile on multiple production devices."
- $(BOOTLOADER_DIGEST_BIN): $(BOOTLOADER_BIN) $(SECURE_BOOTLOADER_KEY) | check_python_dependencies
- @echo "DIGEST $(notdir $@)"
- $(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
- else
- bootloader:
- @echo "Invalid bootloader target: bad sdkconfig?"
- @exit 1
- endif
- ifndef CONFIG_SECURE_BOOT_ENABLED
- all_binaries: $(BOOTLOADER_BIN)
- endif
- bootloader-clean: $(SDKCONFIG_MAKEFILE)
- $(BOOTLOADER_MAKE) app-clean
- ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
- rm -f $(SECURE_BOOTLOADER_KEY) $(BOOTLOADER_DIGEST_BIN)
- endif
|