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 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3 2024-11-26 17:07:22 +08:00 committed by Xiang Xiao
parent 430c2ecf46
commit 57595a7937
3 changed files with 18 additions and 0 deletions

View file

@ -40,6 +40,9 @@
#include <nuttx/spi/spi.h> #include <nuttx/spi/spi.h>
#include <nuttx/mtd/mtd.h> #include <nuttx/mtd/mtd.h>
#include <nuttx/fs/nxffs.h> #include <nuttx/fs/nxffs.h>
#ifdef CONFIG_MTD_PARTITION
#include <nuttx/fs/partition.h>
#endif
#ifdef CONFIG_BCH #ifdef CONFIG_BCH
#include <nuttx/drivers/drivers.h> #include <nuttx/drivers/drivers.h>
#endif #endif
@ -330,6 +333,15 @@ static int init_storage_partition(void)
return ret; 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 #endif
return ret; return ret;

View file

@ -63,4 +63,8 @@ CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
ifeq ($(CONFIG_ETC_ROMFS),y) ifeq ($(CONFIG_ETC_ROMFS),y)
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
ifeq ($(CONFIG_TXTABLE_PARTITION),y)
RCRAWS = etc/txtable.txt
endif # CONFIG_TXTABLE_PARTITION
endif endif

View file

@ -0,0 +1,2 @@
TXTABLE0
data 0x100000 0