mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-03 22:08:28 +00:00 
			
		
		
		
	refactor(esp_partition): Expose function for unloading partitions
Closes https://github.com/espressif/esp-idf/issues/12625
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
 | 
					 * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * SPDX-License-Identifier: Apache-2.0
 | 
					 * SPDX-License-Identifier: Apache-2.0
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -459,6 +459,11 @@ esp_err_t esp_partition_register_external(esp_flash_t* flash_chip, size_t offset
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
esp_err_t esp_partition_deregister_external(const esp_partition_t* partition);
 | 
					esp_err_t esp_partition_deregister_external(const esp_partition_t* partition);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @brief Unload partitions and free space allocated by them
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void esp_partition_unload_all(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -236,10 +236,6 @@ esp_partition_file_mmap_ctrl_t* esp_partition_get_file_mmap_ctrl_input(void);
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
esp_partition_file_mmap_ctrl_t* esp_partition_get_file_mmap_ctrl_act(void);
 | 
					esp_partition_file_mmap_ctrl_t* esp_partition_get_file_mmap_ctrl_act(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// private function in partition.c to unload partitions and free space allocated by them
 | 
					 | 
				
			||||||
void unload_partitions(void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -234,7 +234,7 @@ static esp_err_t load_partitions(void)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void unload_partitions(void)
 | 
					void esp_partition_unload_all(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    _lock_acquire(&s_partition_list_lock);
 | 
					    _lock_acquire(&s_partition_list_lock);
 | 
				
			||||||
    partition_list_item_t *it;
 | 
					    partition_list_item_t *it;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -331,7 +331,7 @@ esp_err_t esp_partition_file_munmap(void)
 | 
				
			|||||||
        return ESP_ERR_NOT_FOUND;
 | 
					        return ESP_ERR_NOT_FOUND;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unload_partitions();
 | 
					    esp_partition_unload_all();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_ESP_PARTITION_ENABLE_STATS
 | 
					#ifdef CONFIG_ESP_PARTITION_ENABLE_STATS
 | 
				
			||||||
    free(s_esp_partition_stat_sector_erase_count);
 | 
					    free(s_esp_partition_stat_sector_erase_count);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user