You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/03/04 02:28:29 UTC
[incubator-nuttx] 02/02: risc-v/esp32c3: Add more flash options to
esptool.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 85620c3c1ae743c606fc34e405832ec052f1d5ea
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Mon Mar 1 14:54:16 2021 +0100
risc-v/esp32c3: Add more flash options to esptool.
Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
arch/risc-v/src/esp32c3/Kconfig | 47 +++++++++++++++++++++++++++++--
tools/esp32c3/Config.mk | 62 +++++++++++++++++++++++++++++++----------
2 files changed, 91 insertions(+), 18 deletions(-)
diff --git a/arch/risc-v/src/esp32c3/Kconfig b/arch/risc-v/src/esp32c3/Kconfig
index d1f0e5c..63738c9 100644
--- a/arch/risc-v/src/esp32c3/Kconfig
+++ b/arch/risc-v/src/esp32c3/Kconfig
@@ -52,6 +52,11 @@ config ESP32C3_DUAL_CPU
bool
default n
+config ESP32C3_ESP32C3XXX
+ bool
+ default n
+ select ESP32C3_SINGLE_CPU
+
config ESP32C3_FLASH_2M
bool
default n
@@ -68,10 +73,46 @@ config ESP32C3_FLASH_16M
bool
default n
-config ESP32C3_ESP32C3XXX
- bool
+config ESP32C3_FLASH_DETECT
+ bool "Auto-detect FLASH size (to be used with master esptool)"
default n
- select ESP32C3_SINGLE_CPU
+ help
+ Auto detect flash size when flashing.
+ Current released version of esptool doesn't support auto-detecting flash size.
+ Use latest master from https://github.com/espressif/esptool.
+
+choice ESP32C3_FLASH_MODE
+ prompt "SPI FLASH mode"
+ default ESP32C3_FLASH_MODE_DIO
+ help
+ These options control how many I/O pins are used for communication with the attached SPI flash chip.
+ The option selected here is then used by esptool when flashing.
+
+ config ESP32C3_FLASH_MODE_DIO
+ bool "Dual IO (DIO)"
+ config ESP32C3_FLASH_MODE_DOUT
+ bool "Dual Output (DOUT)"
+ config ESP32C3_FLASH_MODE_QIO
+ bool "Quad IO (QIO)"
+ config ESP32C3_FLASH_MODE_QOUT
+ bool "Quad Output (QOUT)"
+endchoice # ESP32C3_FLASH_MODE
+
+choice ESP32C3_FLASH_FREQ
+ prompt "SPI FLASH frequency"
+ default ESP32C3_FLASH_FREQ_40M
+ help
+ SPI FLASH frequency
+
+ config ESP32C3_FLASH_FREQ_80M
+ bool "80 MHz"
+ config ESP32C3_FLASH_FREQ_40M
+ bool "40 MHz"
+ config ESP32C3_FLASH_FREQ_26M
+ bool "26 MHz"
+ config ESP32C3_FLASH_FREQ_20M
+ bool "20 MHz"
+endchoice # ESP32C3_FLASH_FREQ
choice ESP32C3_CPU_FREQ
prompt "CPU frequency"
diff --git a/tools/esp32c3/Config.mk b/tools/esp32c3/Config.mk
index 41af319..46d37d0 100644
--- a/tools/esp32c3/Config.mk
+++ b/tools/esp32c3/Config.mk
@@ -22,23 +22,52 @@
# and assemble source files and to insert the resulting object files into an
# archive. These replace the default definitions at tools/Config.mk
-ifdef ESPTOOL_BINDIR
- 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)
-endif
-
ifeq ($(CONFIG_ESP32C3_FLASH_2M),y)
- FLASH_SIZE="2MB"
+ FLASH_SIZE := 2MB
else ifeq ($(CONFIG_ESP32C3_FLASH_4M),y)
- FLASH_SIZE="4MB"
+ FLASH_SIZE := 4MB
else ifeq ($(CONFIG_ESP32C3_FLASH_8M),y)
- FLASH_SIZE="8MB"
+ FLASH_SIZE := 8MB
else ifeq ($(CONFIG_ESP32C3_FLASH_16M),y)
- FLASH_SIZE="16MB"
+ FLASH_SIZE := 16MB
+endif
+
+ifeq ($(CONFIG_ESP32C3_FLASH_MODE_DIO),y)
+ FLASH_MODE := dio
+else ifeq ($(CONFIG_ESP32C3_FLASH_MODE_DOUT),y)
+ FLASH_MODE := dout
+else ifeq ($(CONFIG_ESP32C3_FLASH_MODE_QIO),y)
+ FLASH_MODE := qio
+else ifeq ($(CONFIG_ESP32C3_FLASH_MODE_QOUT),y)
+ FLASH_MODE := qout
+endif
+
+ifeq ($(CONFIG_ESP32C3_FLASH_FREQ_80M),y)
+ FLASH_FREQ := 80m
+else ifeq ($(CONFIG_ESP32C3_FLASH_FREQ_40M),y)
+ FLASH_FREQ := 40m
+else ifeq ($(CONFIG_ESP32C3_FLASH_FREQ_26M),y)
+ FLASH_FREQ := 26m
+else ifeq ($(CONFIG_ESP32C3_FLASH_FREQ_20M),y)
+ FLASH_FREQ := 20m
+endif
+
+ESPTOOL_FLASH_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
+ESPTOOL_ELF2IMG_OPTS := $(ESPTOOL_FLASH_OPTS)
+
+ifeq ($(CONFIG_ESP32C3_FLASH_DETECT),y)
+ ESPTOOL_WRITEFLASH_OPTS := -fs detect -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
+else
+ ESPTOOL_WRITEFLASH_OPTS := $(ESPTOOL_FLASH_OPTS)
+endif
+
+ifdef ESPTOOL_BINDIR
+ 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)
endif
# POSTBUILD -- Perform post build operations
@@ -57,7 +86,7 @@ define POSTBUILD
echo "Missing Flash memory size configuration for the ESP32-C3 chip."; \
exit 1; \
fi
- esptool.py --chip esp32c3 elf2image --flash_mode dio --flash_size $(FLASH_SIZE) -o nuttx.bin nuttx
+ esptool.py -c esp32c3 elf2image $(ESPTOOL_ELF2IMG_OPTS) -o nuttx.bin nuttx
$(Q) echo "Generated: nuttx.bin (ESP32-C3 compatible)"
endef
@@ -68,10 +97,13 @@ 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> ]"; \
exit 1; \
fi
- esptool.py --chip esp32c3 --port $(ESPTOOL_PORT) --baud $(ESPTOOL_BAUD) write_flash $(FLASH_BL) $(FLASH_PT) 0x10000 $(1).bin
+ esptool.py -c esp32c3 -p $(ESPTOOL_PORT) -b $(ESPTOOL_BAUD) write_flash $(ESPTOOL_WRITEFLASH_OPTS) $(ESPTOOL_BINS)
endef