bugfix(simple_ota): Compatible with V3.1 and V3.2

(cherry picked from commit 0fa31d3e31)
This commit is contained in:
InfiniteYuan1 2018-12-18 11:50:33 +08:00 committed by Mahavir Jain
parent beb29bc88a
commit 07fc1d181f

View file

@ -133,9 +133,10 @@ void app_main()
{ {
// Initialize NVS. // Initialize NVS.
esp_err_t err = nvs_flash_init(); esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) { if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// OTA app partition table has a smaller NVS partition size than the non-OTA // 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. // 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. // If this happens, we erase NVS partition and initialize NVS again.
ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init(); err = nvs_flash_init();