From f06ebeba8644b8bc34a23c5036ac963d9e947dc8 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 20 Sep 2016 18:00:49 +0800 Subject: [PATCH] components/nvs: avoid reading just-erased page --- components/nvs_flash/include/nvs.h | 2 +- components/nvs_flash/src/nvs_page.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/nvs_flash/include/nvs.h b/components/nvs_flash/include/nvs.h index 6fff2dabf6..dbcd837e17 100644 --- a/components/nvs_flash/include/nvs.h +++ b/components/nvs_flash/include/nvs.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include "esp_err.h" #ifdef __cplusplus extern "C" { diff --git a/components/nvs_flash/src/nvs_page.cpp b/components/nvs_flash/src/nvs_page.cpp index cddb69393b..3478ded461 100644 --- a/components/nvs_flash/src/nvs_page.cpp +++ b/components/nvs_flash/src/nvs_page.cpp @@ -671,7 +671,12 @@ esp_err_t Page::erase() mState = PageState::INVALID; return rc; } - return load(sector); + mUsedEntryCount = 0; + mErasedEntryCount = 0; + mFirstUsedEntry = INVALID_ENTRY; + mNextFreeEntry = INVALID_ENTRY; + mState = PageState::UNINITIALIZED; + return ESP_OK; } esp_err_t Page::markFreeing()