[SOLVED]create NVS bin file without nvs_partition_gen.py

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

[SOLVED]create NVS bin file without nvs_partition_gen.py

Postby davdav » Tue Nov 06, 2018 3:18 pm

Hi everybody,

we would like to pre-generate the NVS .bin partition file without the use of nvs_partition_gen.py

Currently we create a .csv file, apply the nvs_partition_gen.py script and then download the resulting .bin file to esp32 (together with application, bootloader and partition table) via esptool.py

In order to avoid this intermediate step we would like to generate directly the .bin file. Checking the documentation for entry structure

https://docs.espressif.com/projects/es ... of-entry

I'm not able to calculate the CRC32 as indicated. Just to give you an example I have an uint8_t entry (key name is "nvs_pass_count" and value is 0); the 32 bytes composing the entry (in hex format) is

Code: Select all

01 01 01 FF 0E 8B B6 A5 6E 76 73 5F 70 61 73 73
63 6F 75 6E 74 00 00 00 00 FF FF FF FF FF FF FF
As per docs, the crc 32 should "0E 8B B6 A5". However if I calculate the crc32 of the remaining part (not including 0E 8B B6 A5 bytes) I'm not able to obtain the same.

Check here:
https://crccalc.com/?crc=010101FF6E767 ... atype=hex

Where am I wrong?

Thanks
Last edited by davdav on Wed Nov 07, 2018 4:41 pm, edited 1 time in total.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: create NVS bin file without nvs_partition_gen.py

Postby WiFive » Tue Nov 06, 2018 6:37 pm


davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: create NVS bin file without nvs_partition_gen.py

Postby davdav » Wed Nov 07, 2018 3:10 pm

Thanks @WiFive, it works.

Now I have another rock on my trip. I have some blob variable stored in NVS and I'm struggling to calculate the two crc32 reported in docs.

For example I have a structure defined as

Code: Select all

typedef struct{
	char	type[17];
	char	dop[11];
	char	notes[16];
}Struct_NVS_DeviceInfo;
which is stored in a blob (named "nvs_dev_info")

If I generate the bin file, the part associated to this blob is:

Code: Select all

01 41 03 FF 43 DE 46 2A 6E 76 73 5F 64 65 76 5F
69 6E 66 6F 00 00 00 00 2C 00 FF FF B8 C8 40 A8
41 76 69 6F 72 20 32 39 30 30 2E 43 4D 2E 32 42
00 32 30 31 38 2F 31 31 2F 30 37 00 53 61 6D 70
6C 65 43 79 62 65 72 6C 61 6E 64 00 FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
From my understanding there are two crc32 for blobs.
The first one (crc32 of the entire entry) is from 5th to 8th byte, in my case:

Code: Select all

43 DE 46 2A
The second one is for the data of the blob and it should be located from 29th and 32th bytes:

Code: Select all

B8 C8 40 A8
I was able to calculate the second one (only data field without last FF)

https://crccalc.com/?crc=FFFFFFFF417669 ... tatype=hex

Then I'm trying to calculate the crc32 for the entire entry (expect the 5th to 8th bytes). I have considered the last FF because the entry span is 3, so I have to consider 32*3-4 =92 bytes

https://crccalc.com/?crc=FFFFFFFF014103 ... tatype=hex

but the result is different. I have tried also to delete last FF and I did various attempts without success.

Any help on this last step?

Thanks


davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: create NVS bin file without nvs_partition_gen.py

Postby davdav » Wed Nov 07, 2018 4:41 pm

OK thanks!!

In practice crc32 of entry for blobs is calculated not considering that is after the 8 bytes of "data" field.

I think documentation should be a little clear regarding this point.

Who is online

Users browsing this forum: Bing [Bot] and 100 guests