You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/09/08 10:16:59 UTC
[incubator-nuttx] branch master updated (26b4bb3 -> adef197)
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.
from 26b4bb3 xtensa:cache: fix typo error
new c0344d2 tools/esp32: Create option for merging all binaries into a single file
new 6de75d9 tools/esp32: Add nuttx.signed.bin to the manifest file
new cc36712 boards: Include Kconfig for configs common to ESP32-S2 chips
new 12b4d22 tools/esp32s2: Create option for merging all binaries into a single file
new 310a2dd tools/esp32c3: Create option for merging all binaries into a single file
new adef197 tools/esp32[s2,c3]: Extract POSTBUILD operations into functions
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
boards/Kconfig | 3 ++
boards/risc-v/esp32c3/esp32c3-devkit/Kconfig | 9 ++++
boards/xtensa/esp32/common/Kconfig | 9 ++++
boards/xtensa/esp32s2/common/Kconfig | 8 ++++
tools/esp32/Config.mk | 51 +++++++++++++++++++--
tools/esp32c3/Config.mk | 54 ++++++++++++++++++-----
tools/esp32s2/Config.mk | 66 ++++++++++++++++++++--------
7 files changed, 166 insertions(+), 34 deletions(-)
[incubator-nuttx] 01/06: tools/esp32: Create option for merging all
binaries into a single file
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit c0344d22736861aeb731107da90c40a78c323e68
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Wed Sep 1 19:19:47 2021 -0300
tools/esp32: Create option for merging all binaries into a single file
This is only useful when the path to binary files (e.g. bootloader) is
provided via the ESPTOOL_BINDIR variable.
Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
boards/xtensa/esp32/common/Kconfig | 9 +++++++++
tools/esp32/Config.mk | 26 ++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/boards/xtensa/esp32/common/Kconfig b/boards/xtensa/esp32/common/Kconfig
index bd3e862..944e54c 100644
--- a/boards/xtensa/esp32/common/Kconfig
+++ b/boards/xtensa/esp32/common/Kconfig
@@ -2,6 +2,15 @@
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
+config ESP32_MERGE_BINS
+ bool "Merge raw binary files into a single file"
+ default n
+ ---help---
+ Merge the raw binary files into a single file for flashing to the
+ device.
+ This is only useful when the path to binary files (e.g. bootloader)
+ is provided via the ESPTOOL_BINDIR variable.
+
config ESP32_QEMU_IMAGE
bool "ESP32 binary image for QEMU"
default n
diff --git a/tools/esp32/Config.mk b/tools/esp32/Config.mk
index 21740c0..dcbeae2 100644
--- a/tools/esp32/Config.mk
+++ b/tools/esp32/Config.mk
@@ -104,6 +104,30 @@ else
MK_QEMU_IMG=
endif
+# MERGEBIN -- Merge raw binary files into a single file
+
+ifeq ($(CONFIG_ESP32_MERGE_BINS),y)
+define MERGEBIN
+ $(Q) if [ -z $(ESPTOOL_BINDIR) ]; then \
+ echo "MERGEBIN error: Missing argument for binary files directory."; \
+ echo "USAGE: make ESPTOOL_BINDIR=<dir>"; \
+ exit 1; \
+ fi
+ $(Q) if [ -z $(FLASH_SIZE) ]; then \
+ echo "Missing Flash memory size configuration for the ESP32 chip."; \
+ exit 1; \
+ fi
+ $(eval ESPTOOL_MERGEBIN_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
+ esptool.py -c esp32 merge_bin --output nuttx.merged.bin $(ESPTOOL_MERGEBIN_OPTS) $(ESPTOOL_BINS)
+ $(Q) echo nuttx.merged.bin >> nuttx.manifest
+ $(Q) echo "Generated: nuttx.merged.bin"
+endef
+else
+define MERGEBIN
+
+endef
+endif
+
# POSTBUILD -- Perform post build operations
ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
@@ -121,6 +145,7 @@ define POSTBUILD
-S $(CONFIG_ESP32_OTA_SLOT_SIZE) \
nuttx.bin nuttx.signed.bin
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
+ $(call MERGEBIN)
endef
else
define POSTBUILD
@@ -139,6 +164,7 @@ define POSTBUILD
$(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
$(Q) echo "Generated: nuttx.bin (ESP32 compatible)"
+ $(call MERGEBIN)
$(Q) $(MK_QEMU_IMG)
endef
endif
[incubator-nuttx] 06/06: tools/esp32[s2,
c3]: Extract POSTBUILD operations into functions
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit adef19704d278c4eca515873b605252cb2dd3f2b
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Sat Sep 4 07:28:53 2021 -0300
tools/esp32[s2,c3]: Extract POSTBUILD operations into functions
Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
tools/esp32/Config.mk | 26 +++++++++++++++++++++-----
tools/esp32c3/Config.mk | 37 +++++++++++++++++++++----------------
tools/esp32s2/Config.mk | 37 +++++++++++++++++++++----------------
3 files changed, 63 insertions(+), 37 deletions(-)
diff --git a/tools/esp32/Config.mk b/tools/esp32/Config.mk
index 229d18c..71a033b 100644
--- a/tools/esp32/Config.mk
+++ b/tools/esp32/Config.mk
@@ -128,10 +128,10 @@ define MERGEBIN
endef
endif
-# POSTBUILD -- Perform post build operations
+# SIGNBIN -- Sign the binary image file
ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
-define POSTBUILD
+define SIGNBIN
$(Q) echo "MKIMAGE: ESP32 binary"
$(Q) if ! imgtool version 1>/dev/null 2>&1; then \
echo ""; \
@@ -146,10 +146,13 @@ define POSTBUILD
nuttx.bin nuttx.signed.bin
$(Q) echo nuttx.signed.bin >> nuttx.manifest
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
- $(call MERGEBIN)
endef
-else
-define POSTBUILD
+endif
+
+# 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) if ! esptool.py version 1>/dev/null 2>&1; then \
echo ""; \
@@ -165,6 +168,19 @@ define POSTBUILD
$(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
$(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)
$(Q) $(MK_QEMU_IMG)
endef
diff --git a/tools/esp32c3/Config.mk b/tools/esp32c3/Config.mk
index 0659b70..8030121 100644
--- a/tools/esp32c3/Config.mk
+++ b/tools/esp32c3/Config.mk
@@ -52,8 +52,6 @@ else ifeq ($(CONFIG_ESP32C3_FLASH_FREQ_20M),y)
FLASH_FREQ := 20m
endif
-ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
-
ifeq ($(CONFIG_ESP32C3_FLASH_DETECT),y)
ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm dio -ff $(FLASH_FREQ)
else
@@ -72,6 +70,26 @@ endif
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
ifeq ($(CONFIG_ESP32C3_MERGE_BINS),y)
@@ -99,20 +117,7 @@ endif
# POSTBUILD -- Perform post build operations
define POSTBUILD
- $(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
- esptool.py -c esp32c3 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
- $(Q) echo "Generated: nuttx.bin (ESP32-C3 compatible)"
+ $(call ELF2IMAGE)
$(call MERGEBIN)
endef
diff --git a/tools/esp32s2/Config.mk b/tools/esp32s2/Config.mk
index bd61b10..f53f19e 100644
--- a/tools/esp32s2/Config.mk
+++ b/tools/esp32s2/Config.mk
@@ -52,8 +52,6 @@ else ifeq ($(CONFIG_ESP32S2_FLASH_FREQ_20M),y)
FLASH_FREQ := 20m
endif
-ESPTOOL_ELF2IMG_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
-
ifeq ($(CONFIG_ESP32S2_FLASH_DETECT),y)
ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm dio -ff $(FLASH_FREQ)
else
@@ -72,6 +70,26 @@ endif
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
ifeq ($(CONFIG_ESP32S2_MERGE_BINS),y)
@@ -99,20 +117,7 @@ endif
# POSTBUILD -- Perform post build operations
define POSTBUILD
- $(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
- esptool.py -c esp32s2 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
- $(Q) echo "Generated: nuttx.bin (ESP32-S2 compatible)"
+ $(call ELF2IMAGE)
$(call MERGEBIN)
endef
[incubator-nuttx] 05/06: tools/esp32c3: Create option for merging
all binaries into a single file
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 310a2dd0e454bfd2d7cd2390bfdc2c13cab4765d
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Wed Sep 1 19:40:08 2021 -0300
tools/esp32c3: Create option for merging all binaries into a single file
Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
boards/risc-v/esp32c3/esp32c3-devkit/Kconfig | 9 ++++++
tools/esp32c3/Config.mk | 41 ++++++++++++++++++++++------
2 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig b/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig
index 153e528..0ab2283 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/Kconfig
@@ -41,6 +41,15 @@ config ESP32C3_DEVKIT_RUN_IRAM
bool "Run from IRAM"
default n
+config ESP32C3_MERGE_BINS
+ bool "Merge raw binary files into a single file"
+ default n
+ ---help---
+ Merge the raw binary files into a single file for flashing to the
+ device.
+ This is only useful when the path to binary files (e.g. bootloader)
+ is provided via the ESPTOOL_BINDIR variable.
+
choice
prompt "SPIFLASH File System"
default ESP32C3_SPIFLASH_SMARTFS
diff --git a/tools/esp32c3/Config.mk b/tools/esp32c3/Config.mk
index 9952f70..0659b70 100644
--- a/tools/esp32c3/Config.mk
+++ b/tools/esp32c3/Config.mk
@@ -61,12 +61,39 @@ else
endif
ifdef ESPTOOL_BINDIR
- BL_OFFSET := 0x0
- PT_OFFSET := 0x8000
- BOOTLOADER := $(ESPTOOL_BINDIR)/bootloader-esp32c3.bin
+ BL_OFFSET := 0x0
+ PT_OFFSET := 0x8000
+ BOOTLOADER := $(ESPTOOL_BINDIR)/bootloader-esp32c3.bin
PARTITION_TABLE := $(ESPTOOL_BINDIR)/partition-table-esp32c3.bin
- FLASH_BL := $(BL_OFFSET) $(BOOTLOADER)
- FLASH_PT := $(PT_OFFSET) $(PARTITION_TABLE)
+ FLASH_BL := $(BL_OFFSET) $(BOOTLOADER)
+ FLASH_PT := $(PT_OFFSET) $(PARTITION_TABLE)
+ ESPTOOL_BINS := $(FLASH_BL) $(FLASH_PT)
+endif
+
+ESPTOOL_BINS += 0x10000 nuttx.bin
+
+# MERGEBIN -- Merge raw binary files into a single file
+
+ifeq ($(CONFIG_ESP32C3_MERGE_BINS),y)
+define MERGEBIN
+ $(Q) if [ -z $(ESPTOOL_BINDIR) ]; then \
+ echo "MERGEBIN error: Missing argument for binary files directory."; \
+ echo "USAGE: make ESPTOOL_BINDIR=<dir>"; \
+ 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_MERGEBIN_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
+ esptool.py -c esp32c3 merge_bin --output nuttx.merged.bin $(ESPTOOL_MERGEBIN_OPTS) $(ESPTOOL_BINS)
+ $(Q) echo nuttx.merged.bin >> nuttx.manifest
+ $(Q) echo "Generated: nuttx.merged.bin"
+endef
+else
+define MERGEBIN
+
+endef
endif
# POSTBUILD -- Perform post build operations
@@ -86,6 +113,7 @@ define POSTBUILD
fi
esptool.py -c esp32c3 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
$(Q) echo "Generated: nuttx.bin (ESP32-C3 compatible)"
+ $(call MERGEBIN)
endef
# ESPTOOL_BAUD -- Serial port baud rate used when flashing/reading via esptool.py
@@ -95,9 +123,6 @@ ESPTOOL_BAUD ?= 921600
# DOWNLOAD -- Download binary image via esptool.py
define DOWNLOAD
-
- $(eval ESPTOOL_BINS := $(FLASH_BL) $(FLASH_PT) 0x10000 $(1).bin)
-
$(Q) if [ -z $(ESPTOOL_PORT) ]; then \
echo "DOWNLOAD error: Missing serial port device argument."; \
echo "USAGE: make download ESPTOOL_PORT=<port> [ ESPTOOL_BAUD=<baud> ]"; \
[incubator-nuttx] 02/06: tools/esp32: Add nuttx.signed.bin to the
manifest file
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 6de75d9932c7cceb471ed69ae9c5150f00a79dca
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Fri Sep 3 16:45:08 2021 -0300
tools/esp32: Add nuttx.signed.bin to the manifest file
Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
tools/esp32/Config.mk | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/esp32/Config.mk b/tools/esp32/Config.mk
index dcbeae2..229d18c 100644
--- a/tools/esp32/Config.mk
+++ b/tools/esp32/Config.mk
@@ -144,6 +144,7 @@ define POSTBUILD
-H $(CONFIG_ESP32_APP_MCUBOOT_HEADER_SIZE) --pad-header \
-S $(CONFIG_ESP32_OTA_SLOT_SIZE) \
nuttx.bin nuttx.signed.bin
+ $(Q) echo nuttx.signed.bin >> nuttx.manifest
$(Q) echo "Generated: nuttx.signed.bin (MCUboot compatible)"
$(call MERGEBIN)
endef
[incubator-nuttx] 03/06: boards: Include Kconfig for configs common
to ESP32-S2 chips
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit cc36712ea4bc632e9aedc9229fc076c601837b20
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Wed Sep 1 19:45:56 2021 -0300
boards: Include Kconfig for configs common to ESP32-S2 chips
Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
boards/Kconfig | 3 +++
1 file changed, 3 insertions(+)
diff --git a/boards/Kconfig b/boards/Kconfig
index 7ffd3b2..5a8133b 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -3219,6 +3219,9 @@ endif
if ARCH_BOARD_ESP32C3_DEVKIT
source "boards/risc-v/esp32c3/esp32c3-devkit/Kconfig"
endif
+if ARCH_CHIP_ESP32S2 && !ARCH_BOARD_CUSTOM
+source "boards/xtensa/esp32s2/common/Kconfig"
+endif
if ARCH_BOARD_ESP32S2_SAOLA_1
source "boards/xtensa/esp32s2/esp32s2-saola-1/Kconfig"
endif
[incubator-nuttx] 04/06: tools/esp32s2: Create option for merging
all binaries into a single file
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 12b4d2275762fa025a13654a08460e19dfd28524
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Wed Sep 1 19:39:56 2021 -0300
tools/esp32s2: Create option for merging all binaries into a single file
Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
boards/xtensa/esp32s2/common/Kconfig | 8 ++++++
tools/esp32s2/Config.mk | 53 ++++++++++++++++++++++++++----------
2 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/boards/xtensa/esp32s2/common/Kconfig b/boards/xtensa/esp32s2/common/Kconfig
index 18c7905..67d1292 100644
--- a/boards/xtensa/esp32s2/common/Kconfig
+++ b/boards/xtensa/esp32s2/common/Kconfig
@@ -3,3 +3,11 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
+config ESP32S2_MERGE_BINS
+ bool "Merge raw binary files into a single file"
+ default n
+ ---help---
+ Merge the raw binary files into a single file for flashing to the
+ device.
+ This is only useful when the path to binary files (e.g. bootloader)
+ is provided via the ESPTOOL_BINDIR variable.
diff --git a/tools/esp32s2/Config.mk b/tools/esp32s2/Config.mk
index 54f9d76..bd61b10 100644
--- a/tools/esp32s2/Config.mk
+++ b/tools/esp32s2/Config.mk
@@ -61,18 +61,45 @@ else
endif
ifdef ESPTOOL_BINDIR
- BL_OFFSET=0x1000
- PT_OFFSET=0x8000
- BOOTLOADER=$(ESPTOOL_BINDIR)/bootloader-esp32s2.bin
- PARTITION_TABLE=$(ESPTOOL_BINDIR)/partition-table-esp32s2.bin
- FLASH_BL=$(BL_OFFSET) $(BOOTLOADER)
- FLASH_PT=$(PT_OFFSET) $(PARTITION_TABLE)
+ BL_OFFSET := 0x1000
+ PT_OFFSET := 0x8000
+ BOOTLOADER := $(ESPTOOL_BINDIR)/bootloader-esp32s2.bin
+ PARTITION_TABLE := $(ESPTOOL_BINDIR)/partition-table-esp32s2.bin
+ FLASH_BL := $(BL_OFFSET) $(BOOTLOADER)
+ FLASH_PT := $(PT_OFFSET) $(PARTITION_TABLE)
+ ESPTOOL_BINS := $(FLASH_BL) $(FLASH_PT)
+endif
+
+ESPTOOL_BINS += 0x10000 nuttx.bin
+
+# MERGEBIN -- Merge raw binary files into a single file
+
+ifeq ($(CONFIG_ESP32S2_MERGE_BINS),y)
+define MERGEBIN
+ $(Q) if [ -z $(ESPTOOL_BINDIR) ]; then \
+ echo "MERGEBIN error: Missing argument for binary files directory."; \
+ echo "USAGE: make ESPTOOL_BINDIR=<dir>"; \
+ 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_MERGEBIN_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ))
+ esptool.py -c esp32s2 merge_bin --output nuttx.merged.bin $(ESPTOOL_MERGEBIN_OPTS) $(ESPTOOL_BINS)
+ $(Q) echo nuttx.merged.bin >> nuttx.manifest
+ $(Q) echo "Generated: nuttx.merged.bin"
+endef
+else
+define MERGEBIN
+
+endef
endif
# POSTBUILD -- Perform post build operations
define POSTBUILD
- $(Q) echo "MKIMAGE: ESP32S2 binary"
+ $(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\""; \
@@ -81,11 +108,12 @@ define POSTBUILD
exit 1; \
fi
$(Q) if [ -z $(FLASH_SIZE) ]; then \
- echo "Missing Flash memory size configuration for the ESP32S2 chip."; \
+ echo "Missing Flash memory size configuration for the ESP32-S2 chip."; \
exit 1; \
fi
- esptool.py -c esp32-s2 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
- $(Q) echo "Generated: nuttx.bin (ESP32S2 compatible)"
+ esptool.py -c esp32s2 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
+ $(Q) echo "Generated: nuttx.bin (ESP32-S2 compatible)"
+ $(call MERGEBIN)
endef
# ESPTOOL_BAUD -- Serial port baud rate used when flashing/reading via esptool.py
@@ -95,13 +123,10 @@ ESPTOOL_BAUD ?= 921600
# DOWNLOAD -- Download binary image via esptool.py
define DOWNLOAD
-
- $(eval ESPTOOL_BINS := $(FLASH_BL) $(FLASH_PT) 0x10000 $(1).bin)
-
$(Q) if [ -z $(ESPTOOL_PORT) ]; then \
echo "DOWNLOAD error: Missing serial port device argument."; \
echo "USAGE: make download ESPTOOL_PORT=<port> [ ESPTOOL_BAUD=<baud> ] [ ESPTOOL_BINDIR=<dir> ]"; \
exit 1; \
fi
- esptool.py -c esp32-s2 -p $(ESPTOOL_PORT) -b $(ESPTOOL_BAUD) write_flash $(ESPTOOL_WRITEFLASH_OPTS) $(ESPTOOL_BINS)
+ esptool.py -c esp32s2 -p $(ESPTOOL_PORT) -b $(ESPTOOL_BAUD) write_flash $(ESPTOOL_WRITEFLASH_OPTS) $(ESPTOOL_BINS)
endef