risc-v/esp32c3: Refactor and reorganize Partition Table related configs

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
Gustavo Henrique Nihei 2021-10-25 09:41:18 -03:00 committed by Alan Carvalho de Assis
parent 9d7b9821b3
commit 211f899b62
4 changed files with 28 additions and 31 deletions

View File

@ -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
config ESP32C3_PARTITION_TABLE_OFFSET
hex "Partition Table offset"
default "0x8000"
depends on ESP32C3_APP_FORMAT_LEGACY
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"
default "0x8000"
config ESP32C3_PARTITION_MOUNT
string "Partition mount point"
default "/dev/esp/partition/"
endmenu # Partition Configuration
endif
endif # ARCH_CHIP_ESP32C3

View File

@ -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

View File

@ -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");

View File

@ -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)
{