NVS partition generator fails for v3.1.3 <SOLVED>

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

NVS partition generator fails for v3.1.3 <SOLVED>

Postby fly135 » Tue May 21, 2019 7:58 pm

I'm using IDF v3.1.3 and the included partition generator. I'm using a second NVS partition, so I'm using nvs_flash_init_partition(nvs_partition). When I leave the partition blank it's able to init and open, but the keys are not there and the return code to nvs_get_blob(l_nvs, key, NULL, &length) is...
#define ESP_ERR_NVS_NOT_FOUND (ESP_ERR_NVS_BASE + 0x02) /*!< Id namespace doesn’t exist yet and mode is NVS_READONLY */
The description doesn't exactly look correct, but "not found" sounds right. I opened it READ/WRITE, even though I'm only wanting to read it right now...
nvs_open_from_partition(nvs_partition, l_nvs_tag, NVS_READWRITE, &l_nvs)
However, after writing the bin file I created with the partition generator, I get the following error return on calling nvs_flash_init_partition....
#define ESP_ERR_NVS_NEW_VERSION_FOUND (ESP_ERR_NVS_BASE + 0x10) /*!< NVS partition contains data in new format and cannot be recognized by this version of code */
I tried specifying version v1 with the generator and it fails with the following message....
OTA: Size exceeds max allowed length.
So, I'm stumped on how to create a valid partition file. This is my csv file....
key,type,encoding,value
CERTS,namespace,,
OTA,file,string,myota.pem
PNUB,file,string,mypn.pem
BEND,file,string,mybe.pem
The pem files are all text, so I'm wondering if it would be better to read them as string instead of blob. I.E. nvs_get_blob or nvs_get_str? But I need to get past the init and open first.

This is my partition file....
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 2M,
storage, data, spiffs, 0x210000, 0x80000,
secstore, data, nvs, 0x290000, 0x70000,
ota_0, 0, ota_0, 0x400000, 2M,
ota_1, 0, ota_1, 0x600000, 2M,
And this is the esptool write command, where nvscerts.bin is created with the generator....
$ python $IDF_PATH/components/esptool_py/esptool/esptool.py --port com16 write_flash 0x290000 nvscerts.bin
And the generator command....
$ python nvs_partition_gen.py --version v2 nvscerts.csv nvscerts.bin
I copied nvs_partition_gen.py to my local direction from v3.1.3 directory because it couldn't find my pem files unless they are in the directory of the "py" file.

In the code "nvs_partition" is "secstore", which is the name in the partition file. And "l_nvs_tag" is "CERTS", which is the namespace in the CSV file.
nvs_flash_init_partition(nvs_partition)
nvs_open_from_partition(nvs_partition, l_nvs_tag, NVS_READWRITE, &l_nvs)
John A
Last edited by fly135 on Tue May 21, 2019 8:23 pm, edited 1 time in total.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: NVS partition generator fails for v3.1.3

Postby fly135 » Tue May 21, 2019 8:22 pm

Well I figured out what was wrong. I needed to enable multi page blob support in make menuconfig. Also once I got it inited and opened I realized that I need to call nvs_get_str and not nvs_get_blob.

John A

Who is online

Users browsing this forum: Corand, metala, MicroController and 256 guests