(solved) how to encode binary (blob) in .csv file?

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

(solved) how to encode binary (blob) in .csv file?

Postby mzimmers » Fri Oct 01, 2021 4:26 am

Hi all -

I'm porting an app to the ESP32. It currently stores all of its configuration settings in a struct, which it reads and writes in its entirety. I can read and write the blob from the app, using NVS calls. What I need to do is figure out how to initialize it. My original idea is to write a second program (that would run on the desktop) to produce a binary file, that I could specify in my .csv file, and use the partition generator to create the .bin, and flash that using esptool write_flash.

This seems like it would work, but it seems rather circuitous. Am I overlooking an easier way to do this?

Thanks...
Last edited by mzimmers on Thu Nov 11, 2021 6:09 pm, edited 2 times in total.

nopnop2002
Posts: 46
Joined: Thu Oct 03, 2019 10:52 pm

Re: initializing a blob for NVS

Postby nopnop2002 » Tue Oct 12, 2021 7:21 am

Erase specified NVS partition and open specified NVS partition.

nvs_flash_erase_partition()

nvs_flash_init_partition()

nvs_open_from_partition()

-------------------------------------------

Erase key-value pair with given key name.

nvs_erase_key()

-------------------------------------------

Erase all key-value pairs in a namespace.

nvs_erase_all()

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: initializing a blob for NVS

Postby mzimmers » Wed Nov 10, 2021 5:12 pm

I'm trying to encode a default value for the blob in my .csv file, not create it programmatically. The customer needs to provision data like run schedules at manufacture.

Anyone have an idea for doing this?

Thanks...

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: how to encode binary (blob) in .csv file?

Postby mzimmers » Thu Nov 11, 2021 6:09 pm

Figured it out:

Code: Select all

NVS_KEY_SCH,file,hex2bin,schedule.hex
where schedule.hex is a text file with hex representations (with no formatting):

Code: Select all

44656661756C74205363686564756C6500000...
Evidently, you can only initialize scalars directly in the .csv file; aggregates have to go into files.

nopnop2002
Posts: 46
Joined: Thu Oct 03, 2019 10:52 pm

Re: (solved) how to encode binary (blob) in .csv file?

Postby nopnop2002 » Thu Dec 02, 2021 12:47 am

There is how to do a "Create Unique Factory Data Image".

You can use nvs_partition_gen.py to create NVS partitions.

Data such as the serial number can be written to the second NVS area.

https://blog.espressif.com/building-pro ... 642832a7a3

Who is online

Users browsing this forum: iseries1 and 127 guests