mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-10-31 13:09:38 +00:00 
			
		
		
		
	Merge branch 'feature/partition_type_any' into 'master'
esp_partition: add ESP_PARTITION_TYPE_ANY for iterating over all partition types (Github PR) Closes IDFGH-4783 See merge request espressif/esp-idf!13434
This commit is contained in:
		| @@ -28,6 +28,15 @@ TEST_CASE("Can read partition table", "[partition]") | ||||
|     } | ||||
|     esp_partition_iterator_release(it); | ||||
|     TEST_ASSERT_EQUAL(5, count); | ||||
|  | ||||
|     it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); | ||||
|     TEST_ASSERT_NOT_NULL(it); | ||||
|     count = 0; | ||||
|     for (; it != NULL; it = esp_partition_next(it)) { | ||||
|         ++count; | ||||
|     } | ||||
|     esp_partition_iterator_release(it); | ||||
|     TEST_ASSERT_EQUAL(8, count); | ||||
| } | ||||
|  | ||||
| TEST_CASE("Can write, read, mmap partition", "[partition][ignore]") | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
| /** | ||||
| @@ -123,7 +125,9 @@ typedef struct { | ||||
| /** | ||||
|  * @brief Find partition based on one or more parameters | ||||
|  * | ||||
|  * @param type Partition type, one of esp_partition_type_t values or an 8-bit unsigned integer | ||||
|  * @param type Partition type, one of esp_partition_type_t values or an 8-bit unsigned integer. | ||||
|  *             To find all partitions, no matter the type, use ESP_PARTITION_TYPE_ANY, and set | ||||
|  *             subtype argument to ESP_PARTITION_SUBTYPE_ANY. | ||||
|  * @param subtype Partition subtype, one of esp_partition_subtype_t values or an 8-bit unsigned integer. | ||||
|  *                To find all partitions of given type, use ESP_PARTITION_SUBTYPE_ANY. | ||||
|  * @param label (optional) Partition label. Set this value if looking | ||||
| @@ -139,7 +143,9 @@ esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, esp_parti | ||||
| /** | ||||
|  * @brief Find first partition based on one or more parameters | ||||
|  * | ||||
|  * @param type Partition type, one of esp_partition_type_t values or an 8-bit unsigned integer | ||||
|  * @param type Partition type, one of esp_partition_type_t values or an 8-bit unsigned integer. | ||||
|  *             To find all partitions, no matter the type, use ESP_PARTITION_TYPE_ANY, and set | ||||
|  *             subtype argument to ESP_PARTITION_SUBTYPE_ANY. | ||||
|  * @param subtype Partition subtype, one of esp_partition_subtype_t values or an 8-bit unsigned integer | ||||
|  *                To find all partitions of given type, use ESP_PARTITION_SUBTYPE_ANY. | ||||
|  * @param label (optional) Partition label. Set this value if looking | ||||
|   | ||||
| @@ -88,6 +88,11 @@ esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, | ||||
|     if (ensure_partitions_loaded() != ESP_OK) { | ||||
|         return NULL; | ||||
|     } | ||||
|     // Searching for a specific subtype without specifying the type doesn't make | ||||
|     // sense, and is likely a usage error. | ||||
|     if (type == ESP_PARTITION_TYPE_ANY && subtype != ESP_PARTITION_SUBTYPE_ANY) { | ||||
|         return NULL; | ||||
|     } | ||||
|     // create an iterator pointing to the start of the list | ||||
|     // (next item will be the first one) | ||||
|     esp_partition_iterator_t it = iterator_create(type, subtype, label); | ||||
| @@ -108,10 +113,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) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ivan Grokhotkov
					Ivan Grokhotkov