Programming with ArduinoISP erases eeprom

Hello,
I just got a ArduinoISP (http://arduino.cc/en/Main/ArduinoISP) and I successfully used it to program my Uno (menu File/Upload using programmer).
Unfortunately, every time a sketch is uploaded the eeprom is erased and I loose any previously stored data...
Is there a way to prevent this behavior and only write to flash memory?

Thanks,
Daniele

There is a fuse setting that controls whether or not EEPROM is erased.

See: http://www.engbedded.com/fusecalc

The default settings for fuses for the Uno appear to be:

...
uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
...

This is in the file "boards.txt" inside your Arduino install (look in the "hardware" folder).

If you change the high fuse line to:

uno.bootloader.high_fuses=0xd6

Then it should work. Play close attention to your typing, getting that byte wrong can make the board unprogrammable.

To repeat, the high fuse should be changed to:

uno.bootloader.high_fuses=0xd6

Thank you Nick.
Here's what I did:

  • changed the high_fuses byte to D6;
  • programmed the board via ISP;
  • eeprom got erased, but I thought it was OK since the first upload sets the fuses;
  • programmed the board again.
    And unfortunately the eeprom got cleared again...

Re-reading your post, I noticed that the high_fuses directive seems to be related to the bootloader upload.
So I wrote the bootloader to the board (expected to set fuses), then programmed it via ISP (overwriting the bootloader) and this time eeprom data were still there!

Yes that is probably correct. Programming the board (but not the bootloader) may not change the fuses.