From 57595a7937fcaccdbfe8349203d19cf02f585c2c Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Tue, 26 Nov 2024 17:07:22 +0800 Subject: [PATCH] boards/xtensa/esp32s3: Add TXTABLE support for esp32s3 TXTABLE - Text based Partition Table https://github.com/apache/nuttx/pull/9936 https://nuttx.apache.org/docs/latest/components/filesystem/partition.html#text-based-partition-table Configuration + CONFIG_TXTABLE_PARTITION=y The backup text partition table + CONFIG_TXTABLE_DEFAULT_PARTITION=1 nsh> cat /etc/txtable.txt TXTABLE0 data 0x100000 0 Update txtable at runtime dd if=/dev/zero of=/dev/txtable cat /etc/txtable.txt > /dev/txtable Runtime - Partition devices "data" and "txtable" were registered # /dev/data - The partition descirbed by txtable # /dev/txtable - Mapping to the last eraseblock of MTD nsh> ls -l /dev/ /dev: dr--r--r-- 0 adb0/ crw-rw-rw- 0 console frw-rw-rw- 1044480 data frw-rw-rw- 1048576 esp32s3flash c-w--w--w- 0 log crw-rw-rw- 0 null crw-rw-rw- 0 ptmx dr--r--r-- 0 pts/ brw-rw-rw- 1024 ram0 crw-rw-rw- 0 ttyS0 frw-rw-rw- 4096 txtable crw-rw-rw- 0 zero Signed-off-by: wangjianyu3 --- .../esp32s3/common/src/esp32s3_board_spiflash.c | 12 ++++++++++++ boards/xtensa/esp32s3/esp32s3-devkit/src/Make.defs | 4 ++++ .../esp32s3/esp32s3-devkit/src/etc/txtable.txt | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 boards/xtensa/esp32s3/esp32s3-devkit/src/etc/txtable.txt diff --git a/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c b/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c index 52fe4ded10..7d0ceecc6d 100644 --- a/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c +++ b/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c @@ -40,6 +40,9 @@ #include #include #include +#ifdef CONFIG_MTD_PARTITION +#include +#endif #ifdef CONFIG_BCH #include #endif @@ -330,6 +333,15 @@ static int init_storage_partition(void) return ret; } +#ifdef CONFIG_MTD_PARTITION + ret = parse_mtd_partition(mtd, NULL, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to parse MTD partition: %d\n", ret); + return ret; + } +#endif /* CONFIG_MTD_PARTITION */ + #endif return ret; diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/Make.defs b/boards/xtensa/esp32s3/esp32s3-devkit/src/Make.defs index 2443ad8922..7b3f4a94fc 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/Make.defs @@ -63,4 +63,8 @@ CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src ifeq ($(CONFIG_ETC_ROMFS),y) RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS + +ifeq ($(CONFIG_TXTABLE_PARTITION),y) +RCRAWS = etc/txtable.txt +endif # CONFIG_TXTABLE_PARTITION endif diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/etc/txtable.txt b/boards/xtensa/esp32s3/esp32s3-devkit/src/etc/txtable.txt new file mode 100644 index 0000000000..903b1684fe --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/etc/txtable.txt @@ -0,0 +1,2 @@ +TXTABLE0 +data 0x100000 0