mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/nvs_part_ptr_wrong_init' into 'master'
bugfix (nvs_flash): Fix nvs_flash_init_partition_ptr Closes IDFGH-7503 and IDFGH-7152 See merge request espressif/esp-idf!18503
This commit is contained in:
commit
87180907f7
@ -106,7 +106,7 @@ extern "C" esp_err_t nvs_flash_init_partition_ptr(const esp_partition_t *partiti
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t init_res = NVSPartitionManager::get_instance()->init_custom(part,
|
esp_err_t init_res = NVSPartitionManager::get_instance()->init_custom(part,
|
||||||
partition->address / SPI_FLASH_SEC_SIZE,
|
0,
|
||||||
partition->size / SPI_FLASH_SEC_SIZE);
|
partition->size / SPI_FLASH_SEC_SIZE);
|
||||||
|
|
||||||
if (init_res != ESP_OK) {
|
if (init_res != ESP_OK) {
|
||||||
|
@ -49,6 +49,35 @@ TEST_CASE("flash erase deinitializes initialized partition", "[nvs]")
|
|||||||
nvs_flash_deinit();
|
nvs_flash_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("nvs_flash_init_partition_ptr() works correctly", "[nvs]")
|
||||||
|
{
|
||||||
|
// First, open and write to partition using normal initialization
|
||||||
|
nvs_handle_t handle;
|
||||||
|
esp_err_t err = nvs_flash_init();
|
||||||
|
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||||
|
nvs_flash_erase();
|
||||||
|
err = nvs_flash_init();
|
||||||
|
}
|
||||||
|
TEST_ESP_OK(err);
|
||||||
|
TEST_ESP_OK(nvs_open("uninit_ns", NVS_READWRITE, &handle));
|
||||||
|
TEST_ESP_OK(nvs_set_i32(handle, "foo", 0x12345678));
|
||||||
|
nvs_close(handle);
|
||||||
|
nvs_flash_deinit();
|
||||||
|
|
||||||
|
// Then open and read using partition ptr initialization
|
||||||
|
const esp_partition_t* nvs_partition = esp_partition_find_first(
|
||||||
|
ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, "nvs");
|
||||||
|
TEST_ESP_OK(nvs_flash_init_partition_ptr(nvs_partition));
|
||||||
|
|
||||||
|
TEST_ESP_OK(nvs_open("uninit_ns", NVS_READWRITE, &handle));
|
||||||
|
int32_t foo = 0;
|
||||||
|
TEST_ESP_OK(nvs_get_i32(handle, "foo", &foo));
|
||||||
|
nvs_close(handle);
|
||||||
|
TEST_ASSERT_EQUAL_INT32(foo, 0x12345678);
|
||||||
|
|
||||||
|
nvs_flash_deinit();
|
||||||
|
}
|
||||||
|
|
||||||
// test could have different output on host tests
|
// test could have different output on host tests
|
||||||
TEST_CASE("nvs deinit with open handle", "[nvs]")
|
TEST_CASE("nvs deinit with open handle", "[nvs]")
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user