Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store configuration in flash #84

Closed
wants to merge 3 commits into from

Conversation

Apehaenger
Copy link
Contributor

In preparation for what we discussed in #80, I wrote some code how I would save a config structure in flash.
I preferred to implement it as described by this great blog article instead of the common known Arduino EEPROM library, for an improved wear leveling protection.

Attention:
This draft contains some sample/test code which increase config.volume every second (in main.cpp) and for quicker test/debug, wear level protection is shortened to 10 seconds (instead of more protective 1-5 minutes) (in nv_config.h line 29) for changed config members.
So, don't leave it running endless even if expected flash EOL time with this 10 second protection will be after approx. 888 hours (20'000 expected flash erase cycles * 16 wear level protection * 10 seconds write cycle)

@Apehaenger
Copy link
Contributor Author

Might be somehow over-engineered, but recognized that the wear level of the flash is caused by the flash-sector-erase and not the flash-page-write (did not know that before).
Did some tests and decided to "must try" cause interested in...

So the last commit increases the wear level protection by a factor of about 10 (for the used sample Record.config data) by writing multiple times (10) into the same page, before winding to the next (of 16) page(s)... before doing the wear level expensive flash-sector-erase

Due to this:

  1. I reduced the wear level write time protection (for production) from 5 to 1 minute
  2. and for devel/debug from 10 to 1 seconds

In addition I changed the function names to be more reasonable.

@Apehaenger Apehaenger mentioned this pull request Mar 31, 2024
@Apehaenger
Copy link
Contributor Author

Integrated in #80 now

@Apehaenger Apehaenger closed this Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant