Chapter 2. API Reference
esp_err_t nvs_flash_init_partition_ptr(const esp_partition_t *partition)
Initialize NVS flash storage for the partition specified by partition pointer.
Return
• ESP_OK if storage was successfully initialized
• ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages (which may hap-
pen if NVS partition was truncated)
• ESP_ERR_INVALID_ARG in case partition is NULL
• ESP_ERR_NO_MEM in case memory could not be allocated for the internal structures
• one of the error codes from the underlying flash storage driver
Parameters
• [in] partition: pointer to a partition obtained by the ESP partition API.
esp_err_t nvs_flash_deinit(void)
Deinitialize NVS storage for the default NVS partition.
Default NVS partition is the partition with “nvs”label in the partition table.
Return
• ESP_OK on success (storage was deinitialized)
• ESP_ERR_NVS_NOT_INITIALIZED if the storage was not initialized prior to this call
esp_err_t nvs_flash_deinit_partition(const char *partition_label)
Deinitialize NVS storage for the given NVS partition.
Return
• ESP_OK on success
• ESP_ERR_NVS_NOT_INITIALIZED if the storage for given partition was not initialized prior to
this call
Parameters
• [in] partition_label: Label of the partition
esp_err_t nvs_flash_erase(void)
Erase the default NVS partition.
Erases all contents of the default NVS partition (one with label “nvs”).
Note If the partition is initialized, this function first de-initializes it. Afterwards, the partition has to be ini-
tialized again to be used.
Return
• ESP_OK on success
• ESP_ERR_NOT_FOUND if there is no NVS partition labeled “nvs”in the partition table
• different error in case de-initialization fails (shouldn’t happen)
esp_err_t nvs_flash_erase_partition(const char *part_name)
Erase specified NVS partition.
Erase all content of a specified NVS partition
Note If the partition is initialized, this function first de-initializes it. Afterwards, the partition has to be ini-
tialized again to be used.
Return
• ESP_OK on success
• ESP_ERR_NOT_FOUND if there is no NVS partition with the specified name in the partition table
• different error in case de-initialization fails (shouldn’t happen)
Parameters
• [in] part_name: Name (label) of the partition which should be erased
esp_err_t nvs_flash_erase_partition_ptr(const esp_partition_t *partition)
Erase custom partition.
Erase all content of specified custom partition.
Note If the partition is initialized, this function first de-initializes it. Afterwards, the partition has to be ini-
tialized again to be used.
Return
Espressif Systems 713
Submit Document Feedback
Release v4.4