Skip to main content
MGrub.3
Associate II
July 26, 2020
Solved

Emulated EEPROM is not erased after flashing new code

  • July 26, 2020
  • 6 replies
  • 1984 views

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.

This topic has been closed for replies.
Best answer by MM..1

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

6 replies

S.Ma
Principal
July 26, 2020

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
July 26, 2020

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

KnarfB
Super User
July 26, 2020

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
MM..1Best answer
Chief III
July 26, 2020

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

Tesla DeLorean
Guru
July 26, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
MGrub.3
MGrub.3Author
Associate II
July 27, 2020

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.

Tesla DeLorean
Guru
July 27, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..