Page 1 of 1

nvs program and read

Posted: Fri Jun 08, 2018 12:21 pm
by maxzen
Hello all

I am using the wrover kit and I am using ubuntu 16

I am new to this micro so I think that I missed something

My goal is to write manufacture data to a nvs partition and then read the data

I have used gen_esp32part.py with this file:

Code: Select all

# 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,   16K
otadata,  data, ota,     ,  	    8K
phy_init, data, phy,     0xF000,    4K
factory,  app,  factory, 0x10000,   1M
ota,      app,  ota_0,   ,          1M
prod,     data, nvs,     ,          4K
The prod area will be used to store serial number and product number

I flashed the .bin file with this script:

Code: Select all

bin/openocd -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp32-wrover.cfg -c "program_esp32 $1 0x8000 verify exit"
Then I have used nvs_partition_gen.py passing:

Code: Select all

key,type,encoding,value
prod,namespace,,
prodotto,data,string,123456789012
scheda,data,string,XYZpy000000
I flashed the .bin file with this script:

Code: Select all

bin/openocd -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp32-wrover.cfg -c "program_esp32 $1 0x210000 verify exit"
The code to read is:

Code: Select all

#define PARTITION		"prod"
#define NAMESPACE		"prod"
#define KEY_BSN		"scheda"

bool PROD_read_board(PROD_BSN * p)
{
	bool esito = false ;
	nvs_handle h ;

	do {
		if (NULL == p)
			break ;

		if ( !init() )
			break ;

		esp_err_t err = nvs_open_from_partition(PARTITION, NAMESPACE, NVS_READWRITE, &h) ;
		if (err != ESP_OK)
			break ;

		err = nvs_get_str(h, KEY_BSN, p->bsn, &p->len) ;
		esito = err == ESP_OK ;
	} while (false) ;

	nvs_close(h) ;

    return esito ;
}
I cannot read the data because nvs_get_str(h, KEY_BSN, p->bsn, &p->len) returns 0x1102

What am I doing wrong?

Thank you

Re: nvs program and read

Posted: Wed Jun 13, 2018 6:48 am
by maxzen
I cannot use

Code: Select all

make flash
because it timeouts: is it different from programming with openocd?

Can I read the flash content with openocd ? I mean, passing something like

Code: Select all

"read_esp32 $1 0x8000 exit"
Thank you

Re: nvs program and read

Posted: Fri Jun 15, 2018 8:54 am
by maxzen
I thought that the wrover kit was not working properly, but I just discovered that it's my ict, so now I must develop on a linux pc and use com ports on a windows pc.

This is what I get:
Immagine.png
Immagine.png (67.51 KiB) Viewed 4600 times
I never updated ota, so it is correct to fall back to factory, but it seems that the partition table itself is valid.

Any idea on how to proceed?