EEPROM reset after upload sketch (fuse setting help).

Hello,
I found some information in other thread that there is a fuse configuration that can prevent to erase the eeprom when uploading a sketch in my arduino yun.
But I have difficulties to understand this process.
Any simple hint to help me to configure this?
I don't want to clear eeprom when I upload a sketch either via wifi or usb
Thanks, Paolo

Unfortunately there is no a simple way, because when you play with fuses you have to know what you are doing. If you set a wrong value for fuses you can brick the Atmega and make it unusable.

If you want to change both USB and WiFi upload process you have to modify two different files.

For the WiFi upload you can modify this file openwrt-packages-yun/run-avrdude at master · arduino/openwrt-packages-yun · GitHub and change the fuses value to what you need. This is the script that the Linux side of the Yun runs when you upload a sketch via WiFi.

For the USB process you have to modify the Boards.txt file inside the IDE folder and then rewrite the bootloader on the ATmega.

If you want, it is possible to leave the Boards.txt unchanged because if you modify the WiFi procedure you will change the fuses value after the first upload and then you can upload from USB because fuses won't change.

So I haven't fully tested this yet but, by using this awesome tool:

and by cross referencing what is in boards.txt and also in the /usr/bin/run-avrdude script on the Yun, I was fairly easily able to tell what was going on. The EESAVE bit needs to be turned on in the HIGH FUSE (hfuse). So basically for the Yun (and according to boards.txt, the Leonardo/32u4 as well) the default value is hfuse=0xD8 and enabling EESAVE makes it hfuse=0xD0.

So in boards.txt and the run-avrdude script I just made it 0xD0. I haven't tested it just yet, but I sincerely doubt it will brick anything.

I am confused. In another thread someone was writing that the EEPROM was not erased when loading a new sketch:

http://forum.arduino.cc/index.php?topic=294431.msg2056547#msg2056547

Did you actually see it being erased on uploading a new sketch?

It would be nice to have some resolution on the default erase-behavior when uploading a new sketch.

NewLine:
I am confused. In another thread someone was writing that the EEPROM was not erased when loading a new sketch:

different kind of memories for storing strings - #7 by mikeruss - Arduino Yún - Arduino Forum

Did you actually see it being erased on uploading a new sketch?

It would be nice to have some resolution on the default erase-behavior when uploading a new sketch.

Well, I posted about the use of the EEPROM in that thread you referred to,but I did not refer to any possible erasure of the EEPROM contents when uploading a sketch as I can't say that I have ever encountered that issue before (not on the Yun, not on Uno/Leonardo/Mega2560). Would have to make a test myself in order to check if this is indeed happening. Can't see a reason why though, as the FlashROM where the sketches reside is separate from the EEPROM circuitry on the chip FAIK.
Now on a Due, where EEPROM is only simulated, that could be another issue altogether...

Ralf

Just a quick followup, what I posted (jumping off Angelo9999's post) did end up working to set the EESAVE fuse, thereby enabling EEPROM data to survive flashing. Basically I just went the WiFi route, and since then have been programming the Yun via USB, and the EEPROM stays nice n persistent.

i find this all a bit confusing, because according to Atmel's documentation: http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf
... according to table 28.4 (page 331), bit 3 (EESAVE) bit should be left high if one wants to preserve the EEPROM content ... I must be misreading something ...

kind regards,

Jos

Hey there.
I have been looking for actual instructions on how to implement the edited avrdude script. I have no idea how to install it or edit it. Can someone point me in the right direction?
I want to not loose my EEPROM data on the Yun every time I upload a new sketch.
Thanks!