nvs_open_from_partition failed with ESP_ERR_NVS_NOT_FOUND(4354) when nvs encryption enabled

aravindtn
Posts: 2
Joined: Sun May 22, 2022 5:26 am

nvs_open_from_partition failed with ESP_ERR_NVS_NOT_FOUND(4354) when nvs encryption enabled

Postby aravindtn » Sun May 22, 2022 5:42 am

Partition Table:
I (63) boot: 0 nvs WiFi data 01 02 0000b000 00004000
I (70) boot: 1 otadata OTA data 01 00 0000f000 00002000
I (78) boot: 2 phy_init RF data 01 01 00011000 00001000
I (85) boot: 3 ota_0 OTA app 00 10 00020000 001db000
I (93) boot: 4 ota_1 OTA app 00 11 00200000 001db000
I (100) boot: 5 nvs_certs WiFi data 01 02 003db000 00004000
I (108) boot: 6 nvs_conf WiFi data 01 02 003df000 00010000
I (115) boot: 7 nvs_key NVS keys 01 04 003ef000 00001000
I (123) boot: 8 nvs_certs_key NVS keys 01 04 003f0000 00001000
I (130) boot: 9 nvs_conf_key NVS keys 01 04 003f1000 00001000
Code Snippet:
key_part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS, "nvs_conf_key");
ret = nvs_flash_read_security_cfg(key_part, &xts_cfg);
if((ret == ESP_ERR_NVS_KEYS_NOT_INITIALIZED) || (ESP_ERR_NVS_CORRUPT_KEY_PART == ret))
{
nvs_flash_generate_keys(key_part, &xts_cfg);
}
else
{
ESP_ERROR_CHECK(ret);
}
ret = nvs_flash_secure_init(&xts_cfg);
ret = nvs_flash_secure_init_partition(NVS_CONF_PARTITION_NAME, &xts_cfg);
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ESP_ERROR_CHECK(nvs_flash_erase_partition(NVS_CONF_PARTITION_NAME));
ret = nvs_flash_secure_init_partition(NVS_CONF_PARTITION_NAME, &xts_cfg);
}
ESP_ERROR_CHECK(ret);

/*Load the wifi config from NVS*/
ret = nvs_open_from_partition("nvs_conf", "wifi", NVS_READONLY, &configHdl);
if(ESP_OK == ret)
{
ESP_LOGI(TAG,"opening partition success");
nvs_close(configHdl);
}
else
{
ESP_LOGE(TAG,"WiFi open partition failed %d", ret);
}

Error print:
E (511) main: WiFi open partition failed 4354

ESP_Mahavir
Posts: 188
Joined: Wed Jan 24, 2018 6:51 am

Re: nvs_open_from_partition failed with ESP_ERR_NVS_NOT_FOUND(4354) when nvs encryption enabled

Postby ESP_Mahavir » Sat May 28, 2022 7:58 am

Hello,

Code: Select all

nvs_open_from_partition("nvs_conf", "wifi", NVS_READONLY, &configHdl);
Here 2nd argument is "namespace". Do you have such namespace already created in this partition? If not it shall return an error "ESP_ERR_NVS_NOT_FOUND". Please have a look at the API documentation here.

You may change mode to `NVS_READWRITE` in this API and then retry.

Who is online

Users browsing this forum: No registered users and 112 guests