Question : Can i define the address where will be stored NVS key-value pairs in flash?
Posted: Sun Apr 22, 2018 11:51 pm
Hi everyone,
For my project i need to use the flash to store 2 types of information :
1. Vital configuration of my ESP32 (i.e server authentification keys, WIFI credentials and some other values...)
2. Sensor data that will be stored in flash and that will be recovered after a week of usage.
Currently, to store items listed in ( 1 ) i use NVS library to store key-value pairs in flash.
To store items listed in ( 2 ), i use spi_flash_write() to write data when needed. I begin writing at sector 0x1A2 (418).
Now, why i am writing this post : i do not know where the NVS library used in ( 1 ) stores it's data, meaning at what address in the flash. I am scared that by writing data using spi_flash_write() like in ( 2 ), that it will someday overwrite the data stored from the NVS library where will be stored vital data for my system to function ( 1 ).
Here is an exemple of the flash from begin to end at a certain moment :
flash_begin ---- > data written in ( 2 ) -----> empty (not used yet) -----> used by NVS library ( 1 ) (where my key-value pairs are stored, maybe) ----> empty -----> flash_end
And what i am scared that will happen after a certain time ( that using spi_flash_write will overwrite my key-value pairs) :
flash_begin ---- > data written in ( 2 ) ----->data written in ( 2 ) -----> data written in ( 2 ) (OVERWRITED key-value data) --> empty -----> flash_end
So my question is : how can i be sure that i will never overwrite data stored by the NVS library? Can i define the start address where will be stored NVS key-value pairs in flash to be sure to never overwrite them by using spi_flash_write() ? Cause i do not know where NVS library stores its data in flash.
Note : i am using ESP-WROOM-32 chip.
Regards,
ogensyts
For my project i need to use the flash to store 2 types of information :
1. Vital configuration of my ESP32 (i.e server authentification keys, WIFI credentials and some other values...)
2. Sensor data that will be stored in flash and that will be recovered after a week of usage.
Currently, to store items listed in ( 1 ) i use NVS library to store key-value pairs in flash.
To store items listed in ( 2 ), i use spi_flash_write() to write data when needed. I begin writing at sector 0x1A2 (418).
Now, why i am writing this post : i do not know where the NVS library used in ( 1 ) stores it's data, meaning at what address in the flash. I am scared that by writing data using spi_flash_write() like in ( 2 ), that it will someday overwrite the data stored from the NVS library where will be stored vital data for my system to function ( 1 ).
Here is an exemple of the flash from begin to end at a certain moment :
flash_begin ---- > data written in ( 2 ) -----> empty (not used yet) -----> used by NVS library ( 1 ) (where my key-value pairs are stored, maybe) ----> empty -----> flash_end
And what i am scared that will happen after a certain time ( that using spi_flash_write will overwrite my key-value pairs) :
flash_begin ---- > data written in ( 2 ) ----->data written in ( 2 ) -----> data written in ( 2 ) (OVERWRITED key-value data) --> empty -----> flash_end
So my question is : how can i be sure that i will never overwrite data stored by the NVS library? Can i define the start address where will be stored NVS key-value pairs in flash to be sure to never overwrite them by using spi_flash_write() ? Cause i do not know where NVS library stores its data in flash.
Note : i am using ESP-WROOM-32 chip.
Regards,
ogensyts