cancel
Showing results for 
Search instead for 
Did you mean: 

Emulated EEPROM is not erased after flashing new code

MGrub.3
Associate II

It also doesn’t erase after starting new debug session. Is that expected behavior?

I am using STM32L476, and I downloaded X-CUBE-EEPROM software package, included it into my project and it works fine. EEPROM content is retained after NVIC_SystemReset() and after power up, which is great. But I want to start with clean EEPROM every time I flash new code or start a new debug session.

In X-CUBE-EEPROM example code, in EE_Init() it calls EE_Format() if no active page is present, but it never goes there, except first time every EEPROM is initiated.

I couldn’t find any way around this?

Appreciate your help.

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

EEPROM is emulated on end of flash and your code is less size. Check setings for flash code, default is i mean erase only sectors for code

then when you flash new version EEPROM stay valid and untouched

View solution in original post

7 REPLIES 7
S.Ma
Principal

workaround: use the compilation date and or time to put it in eeprom area and compare with the one in flash. if mismatch after reset, format and write the new time...

S.Ma
Principal

you can also do it manually coding a version number to reduce space

KnarfB
Principal III

Having some kind of version info stored with your EEPROM data is always a good idea. If you want to start "with clean EEPROM every time I flash new code or start a new debug session" you can call EE_Format() manually. You also may do that conditionally only in the Debug configuration by using "#ifdef DEBUG".

MM..1
Chief II

EEPROM is emulated on end of flash and your code is less size. Check setings for flash code, default is i mean erase only sectors for code

then when you flash new version EEPROM stay valid and untouched

The code doesn't understand what situations you want persistent memory to stop being persistent.

Use Erase All or Mass Erase options when uploading new firmware to debug.

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

I am using STM32 IDE (Eclipse based) and I can't find Erase All or Mass Erase options, and also any other settings regarding flashing the code to target.

I will explore recommended options and decide what works best for me.

Thank you all.

Yeah, probably a checkbox item in the debug settings. In Keil we have Flash -> Erase from the top level IDE

In the debug settings Flash Download, Download Function, Erase Full Chip

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