Merge branch 'bugfix/nvs_api_usage_in_simple_ota_example_v3.1' into 'release/v3.1'

Minor bugfix in simple ota example (backport v3.1)

See merge request idf/esp-idf!4583
This commit is contained in:
Jiang Jiang Jian 2019-03-21 11:40:31 +08:00
commit 00c3f795a2

View file

@ -133,9 +133,10 @@ void app_main()
{
// Initialize NVS.
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
// OTA app partition table has a smaller NVS partition size than the non-OTA
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// 1.OTA app partition table has a smaller NVS partition size than the non-OTA
// partition table. This size mismatch may cause NVS initialization to fail.
// 2.NVS partition contains data in new format and cannot be recognized by this version of code.
// If this happens, we erase NVS partition and initialize NVS again.
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();