forked from nuttx/nuttx-update
tools/esp: Fix App image alignment when Flash Encryption is enabled
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
parent
10a8dc9f22
commit
42ffae2d2d
3 changed files with 42 additions and 33 deletions
|
@ -112,7 +112,18 @@ else ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
|
||||||
else
|
else
|
||||||
APP_IMAGE := nuttx.bin
|
APP_IMAGE := nuttx.bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FLASH_APP := $(APP_OFFSET) $(APP_IMAGE)
|
FLASH_APP := $(APP_OFFSET) $(APP_IMAGE)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32_SECURE_FLASH_ENC_ENABLED),y)
|
||||||
|
IMGTOOL_ALIGN_ARGS := --align 32 --max-align 32
|
||||||
|
else
|
||||||
|
IMGTOOL_ALIGN_ARGS := --align 4
|
||||||
|
endif
|
||||||
|
|
||||||
|
IMGTOOL_SIGN_ARGS := --pad $(VERIFIED) $(IMGTOOL_ALIGN_ARGS) -v 0 -s auto \
|
||||||
|
-H $(CONFIG_ESP32_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
||||||
|
-S $(CONFIG_ESP32_OTA_SLOT_SIZE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ESPTOOL_BINS += $(FLASH_APP)
|
ESPTOOL_BINS += $(FLASH_APP)
|
||||||
|
@ -130,7 +141,7 @@ define HELP_SIGN_APP
|
||||||
$(Q) echo ""
|
$(Q) echo ""
|
||||||
$(Q) echo "$(YELLOW)Application not signed. Sign the application before flashing.$(RST)"
|
$(Q) echo "$(YELLOW)Application not signed. Sign the application before flashing.$(RST)"
|
||||||
$(Q) echo "To sign the application, you can use this command:"
|
$(Q) echo "To sign the application, you can use this command:"
|
||||||
$(Q) echo " imgtool sign -k $(ESPSEC_KEYDIR)/$(CONFIG_ESP32_SECURE_BOOT_APP_SIGNING_KEY) --public-key-format hash --pad $(VERIFIED) --align 4 -v 0 -s auto -H $(CONFIG_ESP32_APP_MCUBOOT_HEADER_SIZE) --pad-header -S $(CONFIG_ESP32_OTA_SLOT_SIZE) nuttx.hex nuttx.signed.bin"
|
$(Q) echo " imgtool sign -k $(ESPSEC_KEYDIR)/$(CONFIG_ESP32_SECURE_BOOT_APP_SIGNING_KEY) --public-key-format hash $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.signed.bin"
|
||||||
$(Q) echo ""
|
$(Q) echo ""
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -196,13 +207,8 @@ define SIGNBIN
|
||||||
echo ""; \
|
echo ""; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
$(if $(CONFIG_ESP32_SECURE_BOOT_BUILD_SIGNED_BINARIES), \
|
|
||||||
$(eval IMGTOOL_KEY_ARGS := -k $(APP_SIGN_KEY) --public-key-format hash))
|
|
||||||
|
|
||||||
imgtool sign $(IMGTOOL_KEY_ARGS) --pad $(VERIFIED) --align 4 -v 0 -s auto \
|
imgtool sign -k $(APP_SIGN_KEY) --public-key-format hash $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.signed.bin
|
||||||
-H $(CONFIG_ESP32_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
|
||||||
-S $(CONFIG_ESP32_OTA_SLOT_SIZE) \
|
|
||||||
nuttx.hex nuttx.signed.bin
|
|
||||||
$(Q) echo nuttx.signed.bin >> nuttx.manifest
|
$(Q) echo nuttx.signed.bin >> nuttx.manifest
|
||||||
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
|
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
|
||||||
endef
|
endef
|
||||||
|
@ -241,10 +247,7 @@ define MKIMAGE
|
||||||
echo "Run make again to create the nuttx.bin image."; \
|
echo "Run make again to create the nuttx.bin image."; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
imgtool sign --pad $(VERIFIED) --align 4 -v 0 -s auto \
|
imgtool sign $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.bin
|
||||||
-H $(CONFIG_ESP32_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
|
||||||
-S $(CONFIG_ESP32_OTA_SLOT_SIZE) \
|
|
||||||
nuttx.hex nuttx.bin
|
|
||||||
$(Q) echo "Generated: nuttx.bin (MCUboot compatible)"
|
$(Q) echo "Generated: nuttx.bin (MCUboot compatible)"
|
||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -112,7 +112,18 @@ else ifeq ($(CONFIG_ESP32C3_APP_FORMAT_MCUBOOT),y)
|
||||||
else
|
else
|
||||||
APP_IMAGE := nuttx.bin
|
APP_IMAGE := nuttx.bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FLASH_APP := $(APP_OFFSET) $(APP_IMAGE)
|
FLASH_APP := $(APP_OFFSET) $(APP_IMAGE)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32C3_SECURE_FLASH_ENC_ENABLED),y)
|
||||||
|
IMGTOOL_ALIGN_ARGS := --align 32 --max-align 32
|
||||||
|
else
|
||||||
|
IMGTOOL_ALIGN_ARGS := --align 4
|
||||||
|
endif
|
||||||
|
|
||||||
|
IMGTOOL_SIGN_ARGS := --pad $(VERIFIED) $(IMGTOOL_ALIGN_ARGS) -v 0 -s auto \
|
||||||
|
-H $(CONFIG_ESP32C3_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
||||||
|
-S $(CONFIG_ESP32C3_OTA_SLOT_SIZE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ESPTOOL_BINS += $(FLASH_APP)
|
ESPTOOL_BINS += $(FLASH_APP)
|
||||||
|
@ -130,7 +141,7 @@ define HELP_SIGN_APP
|
||||||
$(Q) echo ""
|
$(Q) echo ""
|
||||||
$(Q) echo "$(YELLOW)Application not signed. Sign the application before flashing.$(RST)"
|
$(Q) echo "$(YELLOW)Application not signed. Sign the application before flashing.$(RST)"
|
||||||
$(Q) echo "To sign the application, you can use this command:"
|
$(Q) echo "To sign the application, you can use this command:"
|
||||||
$(Q) echo " imgtool sign -k $(ESPSEC_KEYDIR)/$(CONFIG_ESP32C3_SECURE_BOOT_APP_SIGNING_KEY) --public-key-format hash --pad $(VERIFIED) --align 4 -v 0 -s auto -H $(CONFIG_ESP32C3_APP_MCUBOOT_HEADER_SIZE) --pad-header -S $(CONFIG_ESP32C3_OTA_SLOT_SIZE) nuttx.hex nuttx.signed.bin"
|
$(Q) echo " imgtool sign -k $(ESPSEC_KEYDIR)/$(CONFIG_ESP32C3_SECURE_BOOT_APP_SIGNING_KEY) --public-key-format hash $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.signed.bin"
|
||||||
$(Q) echo ""
|
$(Q) echo ""
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -185,13 +196,8 @@ define SIGNBIN
|
||||||
echo ""; \
|
echo ""; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
$(if $(CONFIG_ESP32C3_SECURE_BOOT_BUILD_SIGNED_BINARIES), \
|
|
||||||
$(eval IMGTOOL_KEY_ARGS := -k $(APP_SIGN_KEY) --public-key-format hash))
|
|
||||||
|
|
||||||
imgtool sign $(IMGTOOL_KEY_ARGS) --pad $(VERIFIED) --align 4 -v 0 -s auto \
|
imgtool sign -k $(APP_SIGN_KEY) --public-key-format hash $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.signed.bin
|
||||||
-H $(CONFIG_ESP32C3_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
|
||||||
-S $(CONFIG_ESP32C3_OTA_SLOT_SIZE) \
|
|
||||||
nuttx.hex nuttx.signed.bin
|
|
||||||
$(Q) echo nuttx.signed.bin >> nuttx.manifest
|
$(Q) echo nuttx.signed.bin >> nuttx.manifest
|
||||||
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
|
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
|
||||||
endef
|
endef
|
||||||
|
@ -230,10 +236,7 @@ define MKIMAGE
|
||||||
echo "Run make again to create the nuttx.bin image."; \
|
echo "Run make again to create the nuttx.bin image."; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
imgtool sign --pad $(VERIFIED) --align 4 -v 0 -s auto \
|
imgtool sign $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.bin
|
||||||
-H $(CONFIG_ESP32C3_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
|
||||||
-S $(CONFIG_ESP32C3_OTA_SLOT_SIZE) \
|
|
||||||
nuttx.hex nuttx.bin
|
|
||||||
$(Q) echo "Generated: nuttx.bin (MCUboot compatible)"
|
$(Q) echo "Generated: nuttx.bin (MCUboot compatible)"
|
||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -112,7 +112,18 @@ else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y)
|
||||||
else
|
else
|
||||||
APP_IMAGE := nuttx.bin
|
APP_IMAGE := nuttx.bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FLASH_APP := $(APP_OFFSET) $(APP_IMAGE)
|
FLASH_APP := $(APP_OFFSET) $(APP_IMAGE)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32S2_SECURE_FLASH_ENC_ENABLED),y)
|
||||||
|
IMGTOOL_ALIGN_ARGS := --align 32 --max-align 32
|
||||||
|
else
|
||||||
|
IMGTOOL_ALIGN_ARGS := --align 4
|
||||||
|
endif
|
||||||
|
|
||||||
|
IMGTOOL_SIGN_ARGS := --pad $(VERIFIED) $(IMGTOOL_ALIGN_ARGS) -v 0 -s auto \
|
||||||
|
-H $(CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
||||||
|
-S $(CONFIG_ESP32S2_OTA_SLOT_SIZE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ESPTOOL_BINS += $(FLASH_APP)
|
ESPTOOL_BINS += $(FLASH_APP)
|
||||||
|
@ -130,7 +141,7 @@ define HELP_SIGN_APP
|
||||||
$(Q) echo ""
|
$(Q) echo ""
|
||||||
$(Q) echo "$(YELLOW)Application not signed. Sign the application before flashing.$(RST)"
|
$(Q) echo "$(YELLOW)Application not signed. Sign the application before flashing.$(RST)"
|
||||||
$(Q) echo "To sign the application, you can use this command:"
|
$(Q) echo "To sign the application, you can use this command:"
|
||||||
$(Q) echo " imgtool sign -k $(ESPSEC_KEYDIR)/$(CONFIG_ESP32S2_SECURE_BOOT_APP_SIGNING_KEY) --public-key-format hash --pad $(VERIFIED) --align 4 -v 0 -s auto -H $(CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE) --pad-header -S $(CONFIG_ESP32S2_OTA_SLOT_SIZE) nuttx.hex nuttx.signed.bin"
|
$(Q) echo " imgtool sign -k $(ESPSEC_KEYDIR)/$(CONFIG_ESP32S2_SECURE_BOOT_APP_SIGNING_KEY) --public-key-format hash $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.signed.bin"
|
||||||
$(Q) echo ""
|
$(Q) echo ""
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -185,13 +196,8 @@ define SIGNBIN
|
||||||
echo ""; \
|
echo ""; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
$(if $(CONFIG_ESP32S2_SECURE_BOOT_BUILD_SIGNED_BINARIES), \
|
|
||||||
$(eval IMGTOOL_KEY_ARGS := -k $(APP_SIGN_KEY) --public-key-format hash))
|
|
||||||
|
|
||||||
imgtool sign $(IMGTOOL_KEY_ARGS) --pad $(VERIFIED) --align 4 -v 0 -s auto \
|
imgtool sign $(IMGTOOL_KEY_ARGS) $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.signed.bin
|
||||||
-H $(CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
|
||||||
-S $(CONFIG_ESP32S2_OTA_SLOT_SIZE) \
|
|
||||||
nuttx.hex nuttx.signed.bin
|
|
||||||
$(Q) echo nuttx.signed.bin >> nuttx.manifest
|
$(Q) echo nuttx.signed.bin >> nuttx.manifest
|
||||||
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
|
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
|
||||||
endef
|
endef
|
||||||
|
@ -230,10 +236,7 @@ define MKIMAGE
|
||||||
echo "Run make again to create the nuttx.bin image."; \
|
echo "Run make again to create the nuttx.bin image."; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
imgtool sign --pad $(VERIFIED) --align 4 -v 0 -s auto \
|
imgtool sign $(IMGTOOL_SIGN_ARGS) nuttx.hex nuttx.bin
|
||||||
-H $(CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE) --pad-header \
|
|
||||||
-S $(CONFIG_ESP32S2_OTA_SLOT_SIZE) \
|
|
||||||
nuttx.hex nuttx.bin
|
|
||||||
$(Q) echo "Generated: nuttx.bin (MCUboot compatible)"
|
$(Q) echo "Generated: nuttx.bin (MCUboot compatible)"
|
||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue