You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When saving parameters to the persistent storage, we should initially erase the flash page and then write to it.
There is a chance to lose all the parameters if we turn off the power supply during the paramsSave() call.
Notes:
The single erase page takes ~20-40 ms for stm32f103
Proxy page approach
We can use proxy (temporary/intermediate) pages:
During the boot we can check the proxy pages. If they are not erased (not empty), let's try to restore data from them to the main page. Then erase the proxy pages.
During the paramsSave call we can initially save parameters to the proxy pages. It is expected that the proxy pages arealready erased before this call, so it should be fast.
The approach is simple, but it requires using erase twice for each paramsSave call.
Redundant page approach
Instead of using proxy pages, we can switch main pages after each paramsSave call.
During the boot we check which pages are erased and which are not. If first group is erased and second is not, let's consider second as main and first as redundant. If both of them are erased or written, let's use any group (it means that we lost the latest params, but at least can restore the previous version)
During the paramsSave call, we initially save to the redundant group, then erase the main group and switch main to redundant.
This approach is slightly more complex, but it is more efficient.
Notes
Before testing on a real device, it is better to implement it in SITL and cover with unit tests because the number of erase operations is limited
Usually we use 1 page for the storage, but for some tasks we need 2 or more pages.
For compatibility with current API, instead of changing the interface it is better to extend it. For example, this feature can be enabled only if paramsInitRedundantPage(first_idx) is called or similar.
The text was updated successfully, but these errors were encountered:
Problem Description
When saving parameters to the persistent storage, we should initially erase the flash page and then write to it.
There is a chance to lose all the parameters if we turn off the power supply during the
paramsSave()
call.Notes:
Proxy page approach
We can use proxy (temporary/intermediate) pages:
paramsSave
call we can initially save parameters to the proxy pages. It is expected that the proxy pages arealready erased before this call, so it should be fast.The approach is simple, but it requires using erase twice for each
paramsSave
call.Redundant page approach
Instead of using proxy pages, we can switch main pages after each
paramsSave
call.paramsSave
call, we initially save to the redundant group, then erase the main group and switch main to redundant.This approach is slightly more complex, but it is more efficient.
Notes
paramsInitRedundantPage(first_idx)
is called or similar.The text was updated successfully, but these errors were encountered: