From ef56aabe199ed1b53410c376f4894d34bfc1384a Mon Sep 17 00:00:00 2001 From: davidiogos Date: Thu, 10 Oct 2024 10:09:04 -0300 Subject: [PATCH] boards: riscv: esp32c6: Add partitioning support for OTA Add support for memory partitioning for OTA updates. This feature is targeted at the integration of ESP32 boards with RISC-V architecture in conjunction with MCUboot Signed-off-by: davidiogos --- .../esp32c6/common/src/esp_board_spiflash.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c b/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c index b729795e190..281427f1de7 100644 --- a/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c +++ b/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c @@ -121,22 +121,23 @@ static int init_ota_partitions(void) { struct mtd_dev_s *mtd; int ret = OK; + int i; #ifdef CONFIG_BCH char blockdev[18]; #endif - for (int i = 0; i < nitems(g_ota_partition_table); ++i) - { - const struct ota_partition_s *part = &g_ota_partition_table[i]; - mtd = esp_spiflash_alloc_mtdpart(part->offset, part->size); - - ret = ftl_initialize(i, mtd); - if (ret < 0) + for (i = 0; i < nitems(g_ota_partition_table); ++i) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); - return ret; - } + const struct ota_partition_s *part = &g_ota_partition_table[i]; + mtd = esp_spiflash_alloc_mtdpart(part->offset, part->size); + + ret = ftl_initialize(i, mtd); + if (ret < 0) + { + ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + return ret; + } #ifdef CONFIG_BCH snprintf(blockdev, sizeof(blockdev), "/dev/mtdblock%d", i); @@ -148,10 +149,11 @@ static int init_ota_partitions(void) return ret; } #endif - } + } return ret; } + #endif /****************************************************************************