Page 1 of 1

nvs_open and nvs_get work from namespaces that do not exist.

Posted: Tue Feb 07, 2023 5:20 pm
by CKiamy
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

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

Posted: Thu Feb 09, 2023 10:44 am
by CKiamy
bump

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

Posted: Thu Feb 09, 2023 1:13 pm
by gtjoseph
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?