From 1f419bd9832e9170969334498ddcacc3835ce524 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 21 Feb 2021 05:06:46 +0100 Subject: [PATCH] Allow to find any partition type (app and data) with iterator Merges https://github.com/espressif/esp-idf/pull/6586 --- components/spi_flash/include/esp_partition.h | 2 ++ components/spi_flash/partition.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/spi_flash/include/esp_partition.h b/components/spi_flash/include/esp_partition.h index 24c1d3dfa7..fc68d5941a 100644 --- a/components/spi_flash/include/esp_partition.h +++ b/components/spi_flash/include/esp_partition.h @@ -45,6 +45,8 @@ extern "C" { typedef enum { ESP_PARTITION_TYPE_APP = 0x00, //!< Application partition type ESP_PARTITION_TYPE_DATA = 0x01, //!< Data partition type + + ESP_PARTITION_TYPE_ANY = 0xff, //!< Used to search for partitions with any type } esp_partition_type_t; /** diff --git a/components/spi_flash/partition.c b/components/spi_flash/partition.c index 20f2e5fdf9..22272af125 100644 --- a/components/spi_flash/partition.c +++ b/components/spi_flash/partition.c @@ -108,10 +108,10 @@ esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t it) _lock_acquire(&s_partition_list_lock); for (; it->next_item != NULL; it->next_item = SLIST_NEXT(it->next_item, next)) { esp_partition_t* p = &it->next_item->info; - if (it->type != p->type) { + if (it->type != ESP_PARTITION_TYPE_ANY && it->type != p->type) { continue; } - if (it->subtype != 0xff && it->subtype != p->subtype) { + if (it->subtype != ESP_PARTITION_SUBTYPE_ANY && it->subtype != p->subtype) { continue; } if (it->label != NULL && strcmp(it->label, p->label) != 0) {