You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/10/25 19:35:08 UTC

[incubator-nuttx] 03/05: risc-v/esp32c3: Refactor and reorganize Partition Table related configs

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 211f899b6288439bb3ba2acf8eccc104cef3dead
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Mon Oct 25 09:41:18 2021 -0300

    risc-v/esp32c3: Refactor and reorganize Partition Table related configs
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/risc-v/src/esp32c3/Kconfig                    | 44 +++++++++++-----------
 arch/risc-v/src/esp32c3/Make.defs                  |  2 +-
 arch/risc-v/src/esp32c3/esp32c3_partition.c        |  9 ++---
 .../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c   |  2 +-
 4 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/Kconfig b/arch/risc-v/src/esp32c3/Kconfig
index 9305658..e59e9aa 100644
--- a/arch/risc-v/src/esp32c3/Kconfig
+++ b/arch/risc-v/src/esp32c3/Kconfig
@@ -895,6 +895,23 @@ config ESP32C3_SPIFLASH_DEBUG
 		If this option is enabled, SPI Flash driver read and write functions
 		will output input parameters and return values (if applicable).
 
+if ESP32C3_APP_FORMAT_LEGACY
+
+comment "Partition Table configuration"
+
+config ESP32C3_PARTITION_TABLE
+	bool "Create MTD partitions from Partition Table"
+	default n
+	---help---
+		Decode partition table and initialize partitions as MTD.
+
+config ESP32C3_PARTITION_MOUNTPT
+	string "Partition mount point"
+	default "/dev/esp/partition/"
+	depends on ESP32C3_PARTITION_TABLE
+
+endif
+
 endmenu # SPI Flash configuration
 
 menu "GDMA Configuration"
@@ -1019,30 +1036,11 @@ config ESP32C3_APP_MCUBOOT_HEADER_SIZE
 	default 32
 	depends on ESP32C3_APP_FORMAT_MCUBOOT
 
-endmenu # Application Image Configuration
-
-if ESP32C3_APP_FORMAT_LEGACY
-
-config ESP32C3_PARTITION
-	bool "ESP32-C3 Partition"
-	default n
-	select ESP32C3_SPIFLASH
-	---help---
-		Decode partition file and initialize partition as MTD.
-
-menu "Partition Configuration"
-	depends on ESP32C3_PARTITION
-
-config ESP32C3_PARTITION_OFFSET
-	hex "Partition offset"
+config ESP32C3_PARTITION_TABLE_OFFSET
+	hex "Partition Table offset"
 	default "0x8000"
+	depends on ESP32C3_APP_FORMAT_LEGACY
 
-config ESP32C3_PARTITION_MOUNT
-	string "Partition mount point"
-	default "/dev/esp/partition/"
-
-endmenu # Partition Configuration
-
-endif
+endmenu # Application Image Configuration
 
 endif # ARCH_CHIP_ESP32C3
diff --git a/arch/risc-v/src/esp32c3/Make.defs b/arch/risc-v/src/esp32c3/Make.defs
index 5ac4124..5c9039b 100644
--- a/arch/risc-v/src/esp32c3/Make.defs
+++ b/arch/risc-v/src/esp32c3/Make.defs
@@ -83,7 +83,7 @@ ifeq ($(CONFIG_ESP32C3_SPIFLASH),y)
 CHIP_CSRCS += esp32c3_spiflash.c
 endif
 
-ifeq ($(CONFIG_ESP32C3_PARTITION),y)
+ifeq ($(CONFIG_ESP32C3_PARTITION_TABLE),y)
 CHIP_CSRCS += esp32c3_partition.c
 endif
 
diff --git a/arch/risc-v/src/esp32c3/esp32c3_partition.c b/arch/risc-v/src/esp32c3/esp32c3_partition.c
index 7fa1083..7850f67 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_partition.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_partition.c
@@ -59,11 +59,11 @@
 
 /* Partition offset in SPI Flash */
 
-#define ESP32C3_PARTITION_OFFSET CONFIG_ESP32C3_PARTITION_OFFSET
+#define PARTITION_TABLE_OFFSET CONFIG_ESP32C3_PARTITION_TABLE_OFFSET
 
 /* Partition MTD device mount point */
 
-#define ESP32C3_PARTITION_MOUNT CONFIG_ESP32C3_PARTITION_MOUNT
+#define PARTITION_MOUNT_POINT CONFIG_ESP32C3_PARTITION_MOUNTPT
 
 /****************************************************************************
  * Private Types
@@ -567,7 +567,7 @@ int esp32c3_partition_init(void)
   struct mtd_dev_priv_s *mtd_priv;
   int ret = 0;
   const int num = PARTITION_MAX_SIZE / sizeof(struct partition_info_priv_s);
-  const char path_base[] = ESP32C3_PARTITION_MOUNT;
+  const char path_base[] = PARTITION_MOUNT_POINT;
   char label[PARTITION_LABEL_LEN + 1];
   char path[PARTITION_LABEL_LEN + sizeof(path_base)];
 
@@ -595,8 +595,7 @@ int esp32c3_partition_init(void)
       goto errout_with_mtd;
     }
 
-  ret = MTD_READ(mtd, ESP32C3_PARTITION_OFFSET,
-                 PARTITION_MAX_SIZE, pbuf);
+  ret = MTD_READ(mtd, PARTITION_TABLE_OFFSET, PARTITION_MAX_SIZE, pbuf);
   if (ret != PARTITION_MAX_SIZE)
     {
       ferr("ERROR: Failed to get read data from MTD\n");
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
index fc0de5a..3ca88c2 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
@@ -155,7 +155,7 @@ int esp32c3_bringup(void)
     }
 #endif
 
-#ifdef CONFIG_ESP32C3_PARTITION
+#ifdef CONFIG_ESP32C3_PARTITION_TABLE
   ret = esp32c3_partition_init();
   if (ret < 0)
     {