Store variables in flash #6346
Replies: 1 comment
-
Posted at 2014-07-05 by @gfwilliams Hi Alex, there's the STM32F1Flash module which will let you access the flash. You've just got to be aware that it works in pages. You can't just keep writing a single value - once you've written a value, to change it you've got to erase the whole page. Someone could make an EEPROM emulation module though - effectively a little journalling database that worked around the limitation. Posted at 2014-07-05 by Alex Hi Gordon, that sounds tricky.. I'll have to read up as to how data is stored exactly.
Regards, Alex Posted at 2014-07-05 by @gfwilliams
So, The EEPROM emulation really isn't that bad. Think of it this way:
I just had a go at doing this - just use the code below. At some point (if it works ok) I'll have a go at packing it into a module:
Posted at 2014-07-05 by @gfwilliams You use it like this:
Posted at 2014-07-05 by DrAzzy Gordon, where is code/etc saved using save() stored in the flash? Is it included in process.memory().flash_binary_end, or does the save()'ed data go at the end instead? How many write/erase cycles is the flash in the Espruino rated at? Posted at 2014-07-05 by @gfwilliams Memory layout is documented in the module's page: http://microcosm.app/out/a32 I can't remember about write cycles offhand. But yes, this should come with a warning. Great for settings modified by the user, but you don't want to be updating it every second! Posted at 2014-07-08 by Alex Hi Gordon, Posted at 2020-10-16 by Joshua_Sturmvogel Hi. a have same question, but with esp8266. need to save one variable after manual change and restore it from memory after reboot.
thanks Posted at 2020-10-16 by @gfwilliams A lot has happened in the 6 years since this post! This should work on any device:
Posted at 2020-10-16 by Joshua_Sturmvogel All working. Thanks a lot!!) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-07-05 by Alex
Hi All,
Is there a way to store vertaling variables in flash while running code? Like for a small DB?
I know save() stores all ram to flash, I just want to store a few variables.
Regards,
Alex
Beta Was this translation helpful? Give feedback.
All reactions