NVS commit / rollback
Posted: Mon Sep 21, 2020 7:05 am
Dear all
I could not find any information on this so I ask the question here. If this is already answered somewhere else, please refer me to this information.
I do store various uint32_t and one character array that are all members of the same struct as individual values in nvs. I store those individually rather than the full structure as a blob as the manual (https://docs.espressif.com/projects/esp ... flash.html) states "NVS works best for storing many small values, rather than a few large values of the type ‘string’ and ‘blob’".
I want to ensure that either all values are written or none. The function description of nvs_set_* states "Note that actual storage will not be updated until nvs_commit function is called." while the description for nvs_commit states "After setting any values, nvs_commit() must be called to ensure changes are written to non-volatile storage. Individual implementations may write to storage at other times, but this is not guaranteed."
I am unsure on how to interpret this: Does this mean, that unless I call nvs_commit in my function, the values are NEVER commited to nvs, even if another function in a concurrent process calls nvs commit in the same namespace (using its own handle)? Or does this mean that the commit could happen nevertheless and I need to first read all the old values to memory, update the values using the nvs_set function and if all updates are successful, commit, otherwise try to write back the old values from ram?
Thanks for helping
Florian
I could not find any information on this so I ask the question here. If this is already answered somewhere else, please refer me to this information.
I do store various uint32_t and one character array that are all members of the same struct as individual values in nvs. I store those individually rather than the full structure as a blob as the manual (https://docs.espressif.com/projects/esp ... flash.html) states "NVS works best for storing many small values, rather than a few large values of the type ‘string’ and ‘blob’".
I want to ensure that either all values are written or none. The function description of nvs_set_* states "Note that actual storage will not be updated until nvs_commit function is called." while the description for nvs_commit states "After setting any values, nvs_commit() must be called to ensure changes are written to non-volatile storage. Individual implementations may write to storage at other times, but this is not guaranteed."
I am unsure on how to interpret this: Does this mean, that unless I call nvs_commit in my function, the values are NEVER commited to nvs, even if another function in a concurrent process calls nvs commit in the same namespace (using its own handle)? Or does this mean that the commit could happen nevertheless and I need to first read all the old values to memory, update the values using the nvs_set function and if all updates are successful, commit, otherwise try to write back the old values from ram?
Thanks for helping
Florian