cancel
Showing results for 
Search instead for 
Did you mean: 

K.I.S.S. STM32L0xx persistent storage / non-volatile memory

JMath.2
Associate II

I need a to read and write a simple 16 bit user configuration value that's stored in non-volatile memory. The STM32L0xx is famously short on memory and as such bringing the entire HAL in is out of the question. It swells up the code space well beyond 8k!

Is there a simple way to save and read a value from flash (virtual eeprom)? Maybe a couple of assembly instructions? I can't find an example of this anywhere. It sure would be nice if there was just a simple __no_init pragma that handled the unlock, write, lock... without a lot of HAL or wear leveling complexities.

3 REPLIES 3

The L0 has a portion of FLASH which is EEPROM-like. There are examples of usage in Appendix A of RM.

jW

TDK
Guru

You can just use the HAL functions you want and it won't increase code size that much. Most of the space is due to complicated clock initialization functions.

0693W00000BbQ6IQAV.png0693W00000BbQ6NQAV.png 

Barring that or using EEPROM, using register level access to read/write flash is quite achievable by following the RM. It has details steps. Going to take quite a bit more than a "couple of assembly instructions" though.

There is no FLASH wear leveling done in HAL.

If you feel a post has answered your question, please click "Accept as Solution".

The STM32L011 has 512-byte of "True-EEPROM" at least that's what the marketing/pr tosh says.. Using it here for calibration/configuration data

I don't think the assembler would be too complicated

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..