I need AVR Dude to erase eeprom

I am using IDE 1.05 and working on an Arduino UNO.

I need the EEPROM erased when the chip is programmed. I don't see an option for this. Currently the FLASH is being programmed and the EEPROM is not being touched.

Thanks in advance.

BOLTS25

Just posting so that I can see what solution comes out of this.

All I can be sure of now is the lame run a sketch to erase EEPROM first solution.

The Arduino Uno bootloader (optiboot) does not support writing (or erasing) of EEPROM, so there's no way to do this without having a device programmer (either to erase the EEPROM directly, or to load a different bootloader that can erase the EEPROM.)
You'd probably have to use 1.5.x and play with the platform.txt file to change the upload commands, too.

(Hmm. You might actually be able to use platform.txt to make each upload actually upload two sketches with a "wait" in between. The first one would do nothing but erase the eeprom (as per GoForSmoke, but less "lame" since it would be done automatically.))

The bootloader is invoked by the hardware on reset so you can't just erase it after you have uploaded your program you still need something to "call" your program.

Mark

The bootloader is invoked by the hardware on reset so you can't just erase it after you have uploaded your program you still need something to "call" your program.

I don't understand how this is relevant to the question?

I just want AVRDUDE to erase the EEPROM at program-time. Nothing to do with run-time. I think you are confusing FLASH with EEPROM.

bolts:
I am using IDE 1.05 and working on an Arduino UNO.

I need the EEPROM erased when the chip is programmed. I don't see an option for this. Currently the FLASH is being programmed and the EEPROM is not being touched.

Thanks in advance.

BOLTS25

Well you of course could just 'erase' the EEPROM in your setup function. It would be slower of course but at least under your full program control and depending on how often the project is powered off and on might not be a big issue with total EEPROM write limitations.

I am guessing that he does not want to erase the EEPROM at startup, only when he re-programs the chip.

This is only slightly more kludgey than a separate sketch, but you could program a magic number in EEPROM, and in setup() check it. If it doesn't match the number in the program erase the EEPROM, otherwise, leave it alone. DATE could be used to make it happen automagically.

Pseudo code would go like this:
Get magic string from EEPROM.
Compare to DATE
If it does not match then erase EEPROM and put DATE into magic string
else - continue on

The ATMEL 328 (family) complete doc section on Serial Programming shows it's possible to erase or pre-load EEPROM but it's not in optiboot as Westfw should know for some odd reason.

If you want to erase EEPROM as part of programming the chip often enough then it'd probably be worth making a special version bootloader but that would be a lot of times, > 20 or so.

KeithRB:
I am guessing that he does not want to erase the EEPROM at startup, only when he re-programs the chip.

This is only slightly more kludgey than a separate sketch, but you could program a magic number in EEPROM, and in setup() check it. If it doesn't match the number in the program erase the EEPROM, otherwise, leave it alone. DATE could be used to make it happen automagically.

Pseudo code would go like this:
Get magic string from EEPROM.
Compare to DATE
If it does not match then erase EEPROM and put DATE into magic string
else - continue on

Yes, this might work.

This is how I want it to function.

In setup(), the first time run, I see that the EEPROM is erased so I set some default parameters in the EEPROM. From that point the program allows the user to change some/all of those parameters.

Next time the program starts the parameters (perhaps modified by the user) are already in EEPROM so nothing needs be done. The user may still modify some/all of the parameters.

This allows me to keep the user's configuration of the application until such time as the Arduino is re-programmed.

bolts:
Yes, this might work.

It will definitely work. I have used this technique many times, back when I programmed them in assembler.

DATE is nice in that assuming you don't reprogram it twice in one day, you do not need to keep remembering to check the magic number each time you program. A rev number would work too, though you would need to remember to keep updating it.

Say it the right way and it simple it's not erase (the ram/flash/eeprom/disk etc) must contain something but you can overwrite.....

Mark