nvs_flash: Version compatibility check for nvs storage

This change adds a check for compatibility between the nvs version
found on nvs flash and the one assumed by running code during nvs
initialization. Any mismatch is reported to the user using new error
code ESP_ERR_NVS_NEW_VERSION_FOUND.
This commit is contained in:
Sagar Bijwe
2018-07-25 20:41:09 +05:30
committed by bot
parent 8ef7a49cc3
commit 1df85e0039
45 changed files with 86 additions and 47 deletions
@@ -1710,6 +1710,20 @@ TEST_CASE("Check that orphaned blobs are erased during init", "[nvs]")
TEST_ESP_OK(storage.writeItem(1, ItemType::BLOB, "key3", blob, sizeof(blob)));
}
TEST_CASE("Check for nvs version incompatibility", "[nvs]")
{
SpiFlashEmulator emu(3);
int32_t val1 = 0x12345678;
Page p;
p.load(0);
TEST_ESP_OK(p.setVersion(Page::NVS_VERSION - 1));
TEST_ESP_OK(p.writeItem(1, ItemType::I32, "foo", &val1, sizeof(val1)));
TEST_ESP_ERR(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3), ESP_ERR_NVS_NEW_VERSION_FOUND);
}
TEST_CASE("Check that NVS supports old blob format without blob index", "[nvs]")
{
SpiFlashEmulator emu("../nvs_partition_generator/part_old_blob_format.bin");