I'm finishing an application which will use some non-volatile parameters stored on an AVR Atmega644P EEPROM. The initial EEPROM values were generated using the EEMEM attribute (like described on this tutorial) and burned to the AVR using avrdude like this:

avrdude -c usbasp -p atmega644p -u -U eeprom:w:application.eep

The application runs and retrieves the correct EEPROM values, but if I upgrade just the firmware with avrdude -c usbasp -p atmega644p -u -U flash:w:application.hex the EEPROM seems to be erased too, for the values read are "all ones" instead of the previously loaded ones. So I ask, is there any way to burn the firmware to flash but avoid the EEPROM to be erased (using avrdude)?


Before reflashing any Atmel AVR MCU you need to erase it. Erase procedure by default clears FLASH, EEPROM and lock bits. There are 2 ways to solve your issue:

  1. Read EEPROM, erase all, program all including your backed-up EEPROM.
  2. Set EESAVE fuse bit. In this case EEPROM will not be erased during Erase procedure. But you will need to clear this flag some day later if you want to clear and/or reflash EEPROM.
  • \$\begingroup\$ This issue is not specific to avrdude, but to all Atmel AVR MCU programmers. \$\endgroup\$ – x4mer Feb 6 '14 at 14:00
  • \$\begingroup\$ So if I ever have to update the eeprom values from the running application using, say, the eeprom_update_byte function, I can't have the EESAVE fuse set? \$\endgroup\$ – Claudio Feb 6 '14 at 14:12
  • 5
    \$\begingroup\$ EESAVE fuse only relates to external MCU programming. Your code is not affected in any way, feel free to write whatever you want to EEPROM. \$\endgroup\$ – x4mer Feb 6 '14 at 14:21
  • 4
    \$\begingroup\$ Just a useful update: I just tested and when the EESAVE fuse is set it does preserve the EEPROM on a flash erase/program, but it doesn't block you from burning a new EEPROM file either. \$\endgroup\$ – Claudio Feb 6 '14 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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