Skip to main content
Associate
February 25, 2025
Question

How to reset Emulated EEPROM (in MCU Flash) when new code is uploaded?

  • February 25, 2025
  • 4 replies
  • 905 views

Title edited to make clear that this is emulated EEPROM - in the MCU's Flash.


How to reset the EEPROM every time a new code is uploaded?

Is this possible? 

Thank you very much.

 

4 replies

urbito
Senior II
February 25, 2025

Hello Joker,

 

Just as an example:

urbito_0-1740472779103.png


You have to find the datasheet for your EEPROM chip and find the Erase Operation command, so in your microcontroller you can send it.

For example, you check in your eeprom for a value that must be FF, if it is not FF, you clean the EEPROM.

 

Hope it helps.

 

Greetings

JokerJokAuthor
Associate
February 25, 2025

Hi, thanks for the answer, will the operation be performed only when uploading new code, or every time the MCU is booted?

Andrew Neil
Super User
February 25, 2025

You have to write the code to do it - so it will happen whenever you code it to happen!

 

You need to give more details about your system.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User
February 25, 2025

@JokerJok wrote:

 the EEPROM 


What EEPROM ?

Please see How to write your question to maximize your chances to find a solution

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
urbito
Senior II
February 25, 2025

It's up to you and how you make the code work.

My words refer to the hypothetical case where you write your own code to check the EEPROM every time the MCU boots.

Best regards.

JokerJokAuthor
Associate
February 25, 2025

my MCU is: stm32f030rct

JokerJok_0-1740488653256.png

These are the addresses I want to reset their contents every time I upload new code.

I have some BYTEs that I store in EEPROM, and I reload them every time I boot the system.

But while I'm uploading new code, I would be happy if it were possible to reset the EEPROM every time I write code.

Thanks!

Tesla DeLorean
Guru
February 25, 2025

Perhaps use __TIME__ preprocessor define, and mark as a tag in EEPROM. Check if is consistent, erase and re-tag when it's different. 

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