From b555b3f89ea575be8aac8a350ffcdda65855c9d3 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Fri, 8 Oct 2021 13:42:23 -0300 Subject: [PATCH] xtensa/esp32: Refactor and reorganize Partition Table related configs Signed-off-by: Gustavo Henrique Nihei --- arch/xtensa/src/esp32/Kconfig | 45 +++++++++---------- arch/xtensa/src/esp32/Make.defs | 2 +- arch/xtensa/src/esp32/esp32_partition.c | 9 ++-- .../esp32/esp32-devkitc/src/esp32_bringup.c | 2 +- .../esp32-ethernet-kit/src/esp32_bringup.c | 2 +- .../esp32-wrover-kit/src/esp32_bringup.c | 2 +- .../esp32/ttgo_lora_esp32/src/esp32_bringup.c | 2 +- 7 files changed, 30 insertions(+), 34 deletions(-) diff --git a/arch/xtensa/src/esp32/Kconfig b/arch/xtensa/src/esp32/Kconfig index f2a3e4b5a9..766e105052 100644 --- a/arch/xtensa/src/esp32/Kconfig +++ b/arch/xtensa/src/esp32/Kconfig @@ -907,6 +907,23 @@ config ESP32_SPIFLASH_DEBUG Enable this option, read and write of SPI Flash will show input arguments and result. +if ESP32_APP_FORMAT_LEGACY + +comment "Partition Table configuration" + +config ESP32_PARTITION_TABLE + bool "Create MTD partitions from Partition Table" + default n + ---help--- + Decode partition table and initialize partitions as MTD. + +config ESP32_PARTITION_MOUNTPT + string "Partition mount point" + default "/dev/esp/partition/" + depends on ESP32_PARTITION_TABLE + +endif + endmenu # ESP32_SPIFLASH menu "SPI RAM Config" @@ -1337,32 +1354,12 @@ config ESP32_APP_MCUBOOT_HEADER_SIZE default 32 depends on ESP32_APP_FORMAT_MCUBOOT -endmenu # Application Image Configuration - -if ESP32_APP_FORMAT_LEGACY - -config ESP32_PARTITION - bool "ESP32 Partition" - default n - select ESP32_SPIFLASH - ---help--- - Decode esp-idf's partition file and initialize - partition by nuttx MTD. - -menu "Partition Configuration" - depends on ESP32_PARTITION - -config ESP32_PARTITION_OFFSET - hex "Partition offset" +config ESP32_PARTITION_TABLE_OFFSET + hex "Partition Table offset" default "0x8000" + depends on ESP32_APP_FORMAT_LEGACY -config ESP32_PARTITION_MOUNT - string "Partition mount point" - default "/dev/esp/partition/" - -endmenu # Partition Configuration - -endif +endmenu # Application Image Configuration config ESP32_AUTO_SLEEP bool "Auto-sleep" diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index da00928a12..e8f901b665 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -167,7 +167,7 @@ ifeq ($(CONFIG_ESP32_FREERUN),y) CHIP_CSRCS += esp32_freerun.c endif -ifeq ($(CONFIG_ESP32_PARTITION),y) +ifeq ($(CONFIG_ESP32_PARTITION_TABLE),y) CHIP_CSRCS += esp32_partition.c endif diff --git a/arch/xtensa/src/esp32/esp32_partition.c b/arch/xtensa/src/esp32/esp32_partition.c index fa6b1dd4b1..ab476462f8 100644 --- a/arch/xtensa/src/esp32/esp32_partition.c +++ b/arch/xtensa/src/esp32/esp32_partition.c @@ -59,11 +59,11 @@ /* Partition offset in SPI Flash */ -#define ESP32_PARTITION_OFFSET CONFIG_ESP32_PARTITION_OFFSET +#define PARTITION_TABLE_OFFSET CONFIG_ESP32_PARTITION_TABLE_OFFSET /* Partition MTD device mount point */ -#define ESP32_PARTITION_MOUNT CONFIG_ESP32_PARTITION_MOUNT +#define PARTITION_MOUNT_POINT CONFIG_ESP32_PARTITION_MOUNTPT /**************************************************************************** * Private Types @@ -566,7 +566,7 @@ int esp32_partition_init(void) struct mtd_dev_priv *mtd_priv; int ret = 0; const int num = PARTITION_MAX_SIZE / sizeof(struct partition_info_priv); - const char path_base[] = ESP32_PARTITION_MOUNT; + const char path_base[] = PARTITION_MOUNT_POINT; char label[PARTITION_LABEL_LEN + 1]; char path[PARTITION_LABEL_LEN + sizeof(path_base)]; @@ -594,8 +594,7 @@ int esp32_partition_init(void) goto errout_with_mtd; } - ret = MTD_READ(mtd, ESP32_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/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c index 79dfe73138..703c262eab 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c @@ -206,7 +206,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_PARTITION +#ifdef CONFIG_ESP32_PARTITION_TABLE ret = esp32_partition_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c index 2d911bdb7b..11f94e164e 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c @@ -151,7 +151,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_PARTITION +#ifdef CONFIG_ESP32_PARTITION_TABLE ret = esp32_partition_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c index 264df38ea5..068401e790 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c @@ -185,7 +185,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_PARTITION +#ifdef CONFIG_ESP32_PARTITION_TABLE ret = esp32_partition_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c index 10e1432297..feb947dd0e 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c @@ -176,7 +176,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_PARTITION +#ifdef CONFIG_ESP32_PARTITION_TABLE ret = esp32_partition_init(); if (ret < 0) {