NVS Flash: prevent erasing initialized partition

Closes https://github.com/espressif/esp-idf/issues/4755
Closes https://github.com/espressif/esp-idf/issues/2777

* nvs_flash_erase_partition() checks whether
  the parition in question is initialized
  already and will return an error if so
* reflect changes in the documentation
This commit is contained in:
Jakob Hasse
2020-02-14 15:09:22 +01:00
parent fa4eba2e34
commit c6deffb8a2
4 changed files with 34 additions and 10 deletions
+5 -3
View File
@@ -87,26 +87,28 @@ esp_err_t nvs_flash_deinit_partition(const char* partition_label);
/**
* @brief Erase the default NVS partition
*
* This function erases all contents of the default NVS partition (one with label "nvs")
* Erases all contents of the default NVS partition (one with label "nvs"), which must be uninitialized.
*
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_FOUND if there is no NVS partition labeled "nvs" in the
* partition table
* - ESP_ERR_NVS_INVALID_STATE if the default partition is initialized already
*/
esp_err_t nvs_flash_erase(void);
/**
* @brief Erase specified NVS partition
*
* This function erases all contents of specified NVS partition
* Erase all content of a specified uninitialized NVS partition
*
* @param[in] part_name Name (label) of the partition to be erased
* @param[in] part_name Name (label) of an uninitialized partition which should be erased
*
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_FOUND if there is no NVS partition with the specified name
* in the partition table
* - ESP_ERR_NVS_INVALID_STATE if the partition with part_name is initialized already
*/
esp_err_t nvs_flash_erase_partition(const char *part_name);