nvs_open and nvs_get work from namespaces that do not exist.

CKiamy
Posts: 19
Joined: Wed Nov 23, 2022 3:01 pm

nvs_open and nvs_get work from namespaces that do not exist.

Postby CKiamy » Tue Feb 07, 2023 5:20 pm

I have a few devices that have different namespaces and partitions within their nvs storage to store different values, but share the same code. In my code, I have made exceptions for when a specific namespace does not exist:
  1. esp_err_t ret = nvs_open("myNamespace", NVS_READWRITE, &handle);
  2.     if(ret != 0){
  3.         ESP_LOGE(TAG, "Failed to open myNamespace namespace.");
  4.         goto other_task;
  5.         }
However the devices that I know for sure that do not have this specific namespace within their partition return no error, and reads garbage values whenever I try to read the data inside the keys from within this namespace. What is happening here? Will the device always open namespaces that do not exist within the device? I made the NVS partition namespaces using nvs_partition_gen.py and parttool.py

CKiamy
Posts: 19
Joined: Wed Nov 23, 2022 3:01 pm

Re: nvs_open and nvs_get work from namespaces that do not exist.

Postby CKiamy » Thu Feb 09, 2023 10:44 am

bump

User avatar
gtjoseph
Posts: 92
Joined: Fri Oct 15, 2021 10:55 pm

Re: nvs_open and nvs_get work from namespaces that do not exist.

Postby gtjoseph » Thu Feb 09, 2023 1:13 pm

Hard to say what's going on without seeing the input to nvs_partition_gen.py and parttool.py for each device but nvs_open WILL create a namespace if it doesn't already exist and if it was called with NVS_READWRITE. When you say "reads garbage values" are you saying that the read returns ESP_OK when it should return a failure code?

Who is online

Users browsing this forum: No registered users and 100 guests