Skip to main content
Explorer
February 25, 2025
Question

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

  • February 25, 2025
  • 4 replies
  • 902 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.

 

    This topic has been closed for replies.

    4 replies

    Graduate 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
    Explorer
    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?

    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.

    Super User
    February 25, 2025
    Graduate 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
    Explorer
    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!

    Graduate II
    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.