nvs program and read
Posted: Fri Jun 08, 2018 12:21 pm
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:
The prod area will be used to store serial number and product number
I flashed the .bin file with this script:
Then I have used nvs_partition_gen.py passing:
I flashed the .bin file with this script:
The code to read is:
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
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
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"
Code: Select all
key,type,encoding,value
prod,namespace,,
prodotto,data,string,123456789012
scheda,data,string,XYZpy000000
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"
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 ;
}
What am I doing wrong?
Thank you