From 0fa31d3e311e2e49b4a37ebf7c32cae2ee3070d4 Mon Sep 17 00:00:00 2001 From: InfiniteYuan1 Date: Tue, 18 Dec 2018 11:50:33 +0800 Subject: [PATCH] bugfix(simple_ota): Compatible with V3.1 and V3.2 --- .../system/ota/simple_ota_example/main/simple_ota_example.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index 7972f8bd5..547812432 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -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();