3

I have a custom 5V 16Mhz Arduino Uno (a breadboard Uno of sorts) that runs the grbl firmware. After the initial flashing I can see all the settings (through the serial monitor) and everything works. However, if I make any changes to the firmware files and re-flash it, I can see that the old settings values have not been replaced with the new ones. I can only assume that these values are in the EEPROM and are not being erased on every re-flash cycle. I then tried the eeprom_clear program from Examples in the Arduino IDE and then re-flashed with the new firmware settings, after which I can see the new settings values.

I did some digging and found that the EESAVE fuse is responsible for this. However the Uno does have this fuse bit unprogrammed (set to 1). Why then am I able to see the old EEPROM settings and have to explicitly run an eeprom clear program before re-flashing with the updated firmware?

4
  • I'm pretty sure Arduino IDE isn't uploading eeprom at all. And for example in Platform IO CLI, there is different command to upload eeprom data instead of flashing program memory.
    – KIIV
    Apr 8, 2017 at 19:01
  • The IDE isn't. The program is setting values in the EEPROM. I simply want to clear the EEPROM everytime a new program is uploaded. Apr 8, 2017 at 20:15
  • Also posted at forum.arduino.cc/index.php?topic=469061
    – per1234
    Apr 8, 2017 at 21:07
  • save the old built date to eeprom and on boot, if it's different than the current build, run your clear routine
    – dandavis
    Apr 8, 2017 at 21:10

2 Answers 2

2

Flash isn't EEPROM. When you reprogram the flash it doesn't touch the EEPROM.

It's controlled by the -U... flag to avrdude:

avrdude ... -Uflash:w:<hex file>

If you want to set the EEPROM to something specific you can use avrdude to program an EEPROM file if the bootloader supports it (not sure it does, so you may need a programmer for it):

avrdude ... -Ueeprom:w:<hex file>
3
  • I do not want to program the EEPROM. I simply want to clear its contents whenever I re-flash the Uno with a new program. When you burn the Arduino bootloader this bit remains unchanged and hence whenever the IDE runs avrdude with an -e parameter it erases the flash and the eeprom. Am I right? If so, this does not seem to be the case with my Uno and I'm hoping to understand why. Apr 8, 2017 at 20:14
  • It's all to do with what the bootloader is capable of. You're not programming the board, you're uploading firmware for the board to program itself - it's a very different scenario.
    – Majenko
    Apr 8, 2017 at 20:34
  • 1
    You could add a "reset to factory settings" button - if it's held in while the power is turned on (or the board reset, or programmed, etc) it wipes the EEPROM.
    – Majenko
    Apr 8, 2017 at 20:35
1

The -e parameter in avrdude should only erase the EEPROM if the fuse bit

Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

is not set. However it appears it is not possible to SET this fuse bit. (at least not with AVRDUDESS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.