Clear eeprom on IDE upload

Hi

Is there a way to clear some/all of the eeprom
area when uploading from the IDE. I think there is an option in Avrdude , but in the IDE itself ?
I’m using this memory area to save a few factors and during development it’s a pain to have to keep clearing it with another sketch .
I don't want to clear eeprom on a re boot only when loading a new sketch .

Is there a specific board you are interested in?

I believe all the "MCUdude" and "DrAzzy" boards platforms have a custom menu under Tools in the Arduino IDE you can use to configure whether or not you want EEPROM to be preserved.

For example:

https://github.com/MCUdude/MiniCore#eeprom-option

If you want the EEPROM to be erased every time you burn the bootloader or upload using a programmer, you can turn off this option. You'll have to connect an ISP programmer and hit "Burn bootloader" to enable or disable EEPROM retain. Note that when uploading using a bootloader, the EEPROM will always be retained.

1 Like

Sorry ..

It’s a Leonardo lookie like ( ATmega32u4 ) on a Latte Panda

I’ll have a google if the two things you mentioned :+1: -I have mini core installed, might not support this processor*

  • never did like Leonardo !

You might want to explore what is possible with the EEMEM keyword (some discussion here ➜ EEMEM - #8 by rlogiacco, I did not look much deeper in the forum but I'm sure there are other discussions)

If I remember correctly it requires using an ISP, generating the .eep file and possibly modifying plattform.txt to upload automate this in the IDE

1 Like

Unfortunately, the ATmega32U4 and family are the AVR chips that have received the least amount of coverage by 3rd party platforms, and never got the blessing of the MCUdude/DrAzzy treatment. The only one for this family I'm familiar with is HoodLoader, which is more focused on a specific use case for these chips.

However, the EEPROM erasing behavior you want is default in even the official Arduino AVR Boards platform. You can see here that the EESAVE bit is unprogrammed in the configuration fuse setting for the Leonardo, and the same for the other ATmega32U4 boards of that platform:

https://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega32u4&LOW=FF&HIGH=D8&EXTENDED=CB&LOCKBIT=2F

So the only thing you miss is having a menu to control the behavior. If you are wanting that, it can easily be added on to whatever platform you are using already, using the custom board options system like how it was done in the MCUdude and DrAzzy platforms:

1 Like

Thx guys - A few things for me to research , never really been under the hood much !

If you have a spare GPIO pin, you could use that as a 'clear EEPROM on boot' pin, Set the INPUT_PULLUP and Clearthe EEPROM if it reads LOW at boot.

There is some related work and discussion here: