mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
tools/esp32[s2,c3]: Extract POSTBUILD operations into functions
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
committed by
Abdelatif Guettouche
parent
310a2dd0e4
commit
adef19704d
+21
-5
@@ -128,10 +128,10 @@ define MERGEBIN
|
|||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# POSTBUILD -- Perform post build operations
|
# SIGNBIN -- Sign the binary image file
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
|
ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
|
||||||
define POSTBUILD
|
define SIGNBIN
|
||||||
$(Q) echo "MKIMAGE: ESP32 binary"
|
$(Q) echo "MKIMAGE: ESP32 binary"
|
||||||
$(Q) if ! imgtool version 1>/dev/null 2>&1; then \
|
$(Q) if ! imgtool version 1>/dev/null 2>&1; then \
|
||||||
echo ""; \
|
echo ""; \
|
||||||
@@ -146,10 +146,13 @@ define POSTBUILD
|
|||||||
nuttx.bin nuttx.signed.bin
|
nuttx.bin 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)"
|
||||||
$(call MERGEBIN)
|
|
||||||
endef
|
endef
|
||||||
else
|
endif
|
||||||
define POSTBUILD
|
|
||||||
|
# ELF2IMAGE -- Convert an ELF file into a binary file in Espressif application image format
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
|
||||||
|
define ELF2IMAGE
|
||||||
$(Q) echo "MKIMAGE: ESP32 binary"
|
$(Q) echo "MKIMAGE: ESP32 binary"
|
||||||
$(Q) if ! esptool.py version 1>/dev/null 2>&1; then \
|
$(Q) if ! esptool.py version 1>/dev/null 2>&1; then \
|
||||||
echo ""; \
|
echo ""; \
|
||||||
@@ -165,6 +168,19 @@ define POSTBUILD
|
|||||||
$(eval ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
|
$(eval ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
|
||||||
esptool.py -c esp32 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
|
esptool.py -c esp32 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
|
||||||
$(Q) echo "Generated: nuttx.bin (ESP32 compatible)"
|
$(Q) echo "Generated: nuttx.bin (ESP32 compatible)"
|
||||||
|
endef
|
||||||
|
endif
|
||||||
|
|
||||||
|
# POSTBUILD -- Perform post build operations
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
|
||||||
|
define POSTBUILD
|
||||||
|
$(call SIGNBIN)
|
||||||
|
$(call MERGEBIN)
|
||||||
|
endef
|
||||||
|
else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
|
||||||
|
define POSTBUILD
|
||||||
|
$(call ELF2IMAGE)
|
||||||
$(call MERGEBIN)
|
$(call MERGEBIN)
|
||||||
$(Q) $(MK_QEMU_IMG)
|
$(Q) $(MK_QEMU_IMG)
|
||||||
endef
|
endef
|
||||||
|
|||||||
+21
-16
@@ -52,8 +52,6 @@ else ifeq ($(CONFIG_ESP32C3_FLASH_FREQ_20M),y)
|
|||||||
FLASH_FREQ := 20m
|
FLASH_FREQ := 20m
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP32C3_FLASH_DETECT),y)
|
ifeq ($(CONFIG_ESP32C3_FLASH_DETECT),y)
|
||||||
ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm dio -ff $(FLASH_FREQ)
|
ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm dio -ff $(FLASH_FREQ)
|
||||||
else
|
else
|
||||||
@@ -72,6 +70,26 @@ endif
|
|||||||
|
|
||||||
ESPTOOL_BINS += 0x10000 nuttx.bin
|
ESPTOOL_BINS += 0x10000 nuttx.bin
|
||||||
|
|
||||||
|
# ELF2IMAGE -- Convert an ELF file into a binary file in Espressif application image format
|
||||||
|
|
||||||
|
define ELF2IMAGE
|
||||||
|
$(Q) echo "MKIMAGE: ESP32-C3 binary"
|
||||||
|
$(Q) if ! esptool.py version 1>/dev/null 2>&1; then \
|
||||||
|
echo ""; \
|
||||||
|
echo "esptool.py not found. Please run: \"pip install esptool\""; \
|
||||||
|
echo ""; \
|
||||||
|
echo "Run make again to create the nuttx.bin image."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
$(Q) if [ -z $(FLASH_SIZE) ]; then \
|
||||||
|
echo "Missing Flash memory size configuration for the ESP32-C3 chip."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
$(eval ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
|
||||||
|
esptool.py -c esp32c3 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
|
||||||
|
$(Q) echo "Generated: nuttx.bin (ESP32-C3 compatible)"
|
||||||
|
endef
|
||||||
|
|
||||||
# MERGEBIN -- Merge raw binary files into a single file
|
# MERGEBIN -- Merge raw binary files into a single file
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP32C3_MERGE_BINS),y)
|
ifeq ($(CONFIG_ESP32C3_MERGE_BINS),y)
|
||||||
@@ -99,20 +117,7 @@ endif
|
|||||||
# POSTBUILD -- Perform post build operations
|
# POSTBUILD -- Perform post build operations
|
||||||
|
|
||||||
define POSTBUILD
|
define POSTBUILD
|
||||||
$(Q) echo "MKIMAGE: ESP32-C3 binary"
|
$(call ELF2IMAGE)
|
||||||
$(Q) if ! esptool.py version 1>/dev/null 2>&1; then \
|
|
||||||
echo ""; \
|
|
||||||
echo "esptool.py not found. Please run: \"pip install esptool\""; \
|
|
||||||
echo ""; \
|
|
||||||
echo "Run make again to create the nuttx.bin image."; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
$(Q) if [ -z $(FLASH_SIZE) ]; then \
|
|
||||||
echo "Missing Flash memory size configuration for the ESP32-C3 chip."; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
esptool.py -c esp32c3 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
|
|
||||||
$(Q) echo "Generated: nuttx.bin (ESP32-C3 compatible)"
|
|
||||||
$(call MERGEBIN)
|
$(call MERGEBIN)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|||||||
+21
-16
@@ -52,8 +52,6 @@ else ifeq ($(CONFIG_ESP32S2_FLASH_FREQ_20M),y)
|
|||||||
FLASH_FREQ := 20m
|
FLASH_FREQ := 20m
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP32S2_FLASH_DETECT),y)
|
ifeq ($(CONFIG_ESP32S2_FLASH_DETECT),y)
|
||||||
ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm dio -ff $(FLASH_FREQ)
|
ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm dio -ff $(FLASH_FREQ)
|
||||||
else
|
else
|
||||||
@@ -72,6 +70,26 @@ endif
|
|||||||
|
|
||||||
ESPTOOL_BINS += 0x10000 nuttx.bin
|
ESPTOOL_BINS += 0x10000 nuttx.bin
|
||||||
|
|
||||||
|
# ELF2IMAGE -- Convert an ELF file into a binary file in Espressif application image format
|
||||||
|
|
||||||
|
define ELF2IMAGE
|
||||||
|
$(Q) echo "MKIMAGE: ESP32-S2 binary"
|
||||||
|
$(Q) if ! esptool.py version 1>/dev/null 2>&1; then \
|
||||||
|
echo ""; \
|
||||||
|
echo "esptool.py not found. Please run: \"pip install esptool\""; \
|
||||||
|
echo ""; \
|
||||||
|
echo "Run make again to create the nuttx.bin image."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
$(Q) if [ -z $(FLASH_SIZE) ]; then \
|
||||||
|
echo "Missing Flash memory size configuration for the ESP32-S2 chip."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
$(eval ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
|
||||||
|
esptool.py -c esp32s2 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
|
||||||
|
$(Q) echo "Generated: nuttx.bin (ESP32-S2 compatible)"
|
||||||
|
endef
|
||||||
|
|
||||||
# MERGEBIN -- Merge raw binary files into a single file
|
# MERGEBIN -- Merge raw binary files into a single file
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP32S2_MERGE_BINS),y)
|
ifeq ($(CONFIG_ESP32S2_MERGE_BINS),y)
|
||||||
@@ -99,20 +117,7 @@ endif
|
|||||||
# POSTBUILD -- Perform post build operations
|
# POSTBUILD -- Perform post build operations
|
||||||
|
|
||||||
define POSTBUILD
|
define POSTBUILD
|
||||||
$(Q) echo "MKIMAGE: ESP32-S2 binary"
|
$(call ELF2IMAGE)
|
||||||
$(Q) if ! esptool.py version 1>/dev/null 2>&1; then \
|
|
||||||
echo ""; \
|
|
||||||
echo "esptool.py not found. Please run: \"pip install esptool\""; \
|
|
||||||
echo ""; \
|
|
||||||
echo "Run make again to create the nuttx.bin image."; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
$(Q) if [ -z $(FLASH_SIZE) ]; then \
|
|
||||||
echo "Missing Flash memory size configuration for the ESP32-S2 chip."; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
esptool.py -c esp32s2 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
|
|
||||||
$(Q) echo "Generated: nuttx.bin (ESP32-S2 compatible)"
|
|
||||||
$(call MERGEBIN)
|
$(call MERGEBIN)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user