Allow to find any partition type (app and data) with iterator

Merges https://github.com/espressif/esp-idf/pull/6586
This commit is contained in:
2021-02-21 05:06:46 +01:00
committed by Ivan Grokhotkov
parent 3dbafb9a13
commit 1f419bd983
2 changed files with 4 additions and 2 deletions

View File

@@ -45,6 +45,8 @@ extern "C" {
typedef enum { typedef enum {
ESP_PARTITION_TYPE_APP = 0x00, //!< Application partition type ESP_PARTITION_TYPE_APP = 0x00, //!< Application partition type
ESP_PARTITION_TYPE_DATA = 0x01, //!< Data 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; } esp_partition_type_t;
/** /**

View File

@@ -108,10 +108,10 @@ esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t it)
_lock_acquire(&s_partition_list_lock); _lock_acquire(&s_partition_list_lock);
for (; it->next_item != NULL; it->next_item = SLIST_NEXT(it->next_item, next)) { for (; it->next_item != NULL; it->next_item = SLIST_NEXT(it->next_item, next)) {
esp_partition_t* p = &it->next_item->info; 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; continue;
} }
if (it->subtype != 0xff && it->subtype != p->subtype) { if (it->subtype != ESP_PARTITION_SUBTYPE_ANY && it->subtype != p->subtype) {
continue; continue;
} }
if (it->label != NULL && strcmp(it->label, p->label) != 0) { if (it->label != NULL && strcmp(it->label, p->label) != 0) {