Fundamental question about nvs library
Posted: Wed May 23, 2018 8:25 am
Hi,
I have a fundamental question about the operation of the nvs library. I understand that it adds new key/value pairs at the end of the reserved flash area for storing data. If a value needs to be updated it will set the status of the existing key/value pair to "erased" and put the new value at the end again.
What I am wondering about is: what will it do when it reaches the end of the available space?
As an example: say that I have two key/value pairs, one that I write once and one that I update every couple of minutes. If I run the application long enough it will eventually run out of space. The first "write once" key/value pair will still be in the original location while the regularly updated value will eventually end up at the end of the allocated flash space. The previously updated key/value pairs are still in flash but they all have the "erased" status bits.
End result: there is plenty of free space ( pages ) that just need to be erased again in order to be reused for writing new and/or updated key/value pairs to.
Is there a built in mechanism in the nvs library to deal with erasing pages so that there is always enough flash memory to write to or is it something you need to watch out for yourself and deal with it?
I have not found anything yet that explains whether or not that sort of things is in the nvs library so I thought I would pose the question here, in the mean time I will look further into the documentation to see if I can find it.
Any help much appreciated.
I have a fundamental question about the operation of the nvs library. I understand that it adds new key/value pairs at the end of the reserved flash area for storing data. If a value needs to be updated it will set the status of the existing key/value pair to "erased" and put the new value at the end again.
What I am wondering about is: what will it do when it reaches the end of the available space?
As an example: say that I have two key/value pairs, one that I write once and one that I update every couple of minutes. If I run the application long enough it will eventually run out of space. The first "write once" key/value pair will still be in the original location while the regularly updated value will eventually end up at the end of the allocated flash space. The previously updated key/value pairs are still in flash but they all have the "erased" status bits.
End result: there is plenty of free space ( pages ) that just need to be erased again in order to be reused for writing new and/or updated key/value pairs to.
Is there a built in mechanism in the nvs library to deal with erasing pages so that there is always enough flash memory to write to or is it something you need to watch out for yourself and deal with it?
I have not found anything yet that explains whether or not that sort of things is in the nvs library so I thought I would pose the question here, in the mean time I will look further into the documentation to see if I can find it.
Any help much appreciated.