Skip to content

Add nvs_flash_init Retry #11

@jorgeespinoza0x20

Description

@jorgeespinoza0x20

In example esp-idf/examples/wifi/wps/main/wps.c, there is a retry if nvs_flash_init returns specific failure codes.

esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
    ESP_ERROR_CHECK(nvs_flash_erase());
    ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);

I was really lucky to read a specific example that had the retry. Many of the other examples do not have the retry.

I asked about this retry as a best practice on the ESP32 forum. @igrr responded that the retry as above is the correct thing to do for a production code.

The source code for this template does not have the retry. If the template is a common starting point for writing production code then it would help if the retry was present in the template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions