Hi,
I'm wondering how to reset nvs to default settings?
Some of the default settings are non-zero values.
So below code won't work because all fields become zero.
nvs_flash_erase();
nvs_flash_init();
Any API to reset nvs to default setting?
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: Any API to reset nvs to default setting?
Erm, nope, if you erase the flash, it will nuke all the keys as well as values; reading a key should return an error, not a value of 0. Also, what default settings do you mean? NVS as-is has no concept of default values.
Re: Any API to reset nvs to default setting?
I use nvs_partition_gen.py to generate bin file from my csv file which includes the settings for my application.
And then using esptool.py to flash the bin file to flash.
My application will load the settings (follow the examples/storage/nvs_rw_value snip code) when booting.
The user may modify some setting at runtime.
However, I need a way to restore the original setting as the original bin file.
I'm not sure how to do this.
And then using esptool.py to flash the bin file to flash.
My application will load the settings (follow the examples/storage/nvs_rw_value snip code) when booting.
The user may modify some setting at runtime.
However, I need a way to restore the original setting as the original bin file.
I'm not sure how to do this.
Re: Any API to reset nvs to default setting?
Include "default settings" as constants in your code or in another partition, than you can easily "restore" them
BDW, erasing Flash sets all bits to 1, not 0.
BDW, erasing Flash sets all bits to 1, not 0.
Re: Any API to reset nvs to default setting?
Hi loboris,
Thanks for your comments, I know how to do this now.
Thanks for your comments, I know how to do this now.
Who is online
Users browsing this forum: No registered users and 106 guests