Writing to EEPROM of Yun is lost after reset

Hi,

I got a Yun this week and tried out a lot examples so far without problems. I tried now to store and read some data with the EEPROM demos. If I write to EEPROM and read the values back in the same sketch, it works. But if the Yun is reseted (reconnect power), the data is lost and I do read only "255" in addresses 0 to 255. Has somebody tried this out successfully on his Yun? Or is this a known problem? If EEPROM does not work, I want to try SD card but there you have to supply correct pin information about some signals used. Could someone tell me which pins to use for a Yun please?

Best regards Robert

The Yun has a socket for a micro SD card uou can use. If you want to add more external memory you could just plug in a USB-stick and use that as storage.

Hi,

I know that. But what's about the pins used to interface to an SD card on the Yun? And does the EEPROM work on your Yun? I want to know if my board is maybe defective.

If you do want to connect yet another SD card to your yun take a lokke at this:

http://forum.arduino.cc/index.php?topic=113058.0

The Arduino part of the Yun is the same as a Leonardo.

And does the EEPROM work on your Yun?

I don'r know, I haven't tried. My guess is that the fuses are set to do an erase during upload.

I still don't understand why you would want all that external memory, (two SD-cards and a memory stick)

I still don't understand why you would want all that external memory, (two SD-cards and a memory stick)

I don't know where you read that. I wanted to use only one SD card in the Yun as alternative to the EEPROM ... And I still don't know which pins to configure for a Yun. It's not mentioned in the article.

But I have some good news: You made me think about the uploading process and the effect on the EEPROM. Before, I tried with removing the power AND loading another sketch (to read the EEPROM values after the writing made with the first sketch). But you are right, the EEPROM seems to be cleared when you upload a sketch. When I just uploaded a sketch which can read and write to EEPROM for testing and I removed the power and reconnect power, the content of the EEPROM was NOT cleared! I have also an Arduino Mega and with this one, uploading does NOT clear the EEPROM, strange.

The SPI pins on the Yun/Leonardo are only available on the ICSP header, so you can connect yor SD card to that, and the CS pin to pin 4 (according to the link I provided)

Also note that you will have to use level-shifting between the Yun and the SD-card (YUN 5V <-> SDcard 3.3V)

If you read through the Yun subforum you will note that we all use the built in SD card for storage, that’s why I am confused about why you want to use yet another SD card.

Regarding the EEPROM.

The fuses can be set to Preserve EEPROM memory through the Chip Erase cycle;

If you want, and if you know what you are doing you can change that for the Atmega32U4

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

By default the fuses are set to:

low: 0xFF
High: 0xD8
Extended 0xFB

Thanx for the info. But I don't know why you insist that I would want to use an external SD slot, l want to use the internal one which is part of the Yun, nothing else. Am I so unclear in my writing?

l want to use the internal one

Ahh, in that case, try one of the examples taht comes with the IDE. This one for example:

http://arduino.cc/en/Tutorial/YunDatalogger

I was confused by the question about configuring pin's

Hi Erni,

the datalogger example was a good tip. With this one the SD card (Fat32, with an "arduino" folder) worked at the first try. I only had to change "Serial" to "Console" because I'm using WiFi to upload the sketch.

Best regards Robert

It appears that EEPROM is erased on the Yun when you upload a sketch, but works correctly and retains values if the Yun loses power and then power is restored.

Going a little further on this. I want to compile the hex file for the yun and manually upload it via ssh into linino and from a usb pendrive.

So taking the example from

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

If I scroll down to the bottom and input the current settings for the Yun from the boards.txt file of:

low: 0xFF High: 0xD8 Extended 0xFB

The middle part of the page updates to refect what those fuse bits actually mean. So in theory, all I need to do to preserve the EEPROM during chip erase is tick the

"EESAVE EEPROM memory is preserved through chip erase"

tick box

This changes the new fuses to

low: 0xFF High: 0xD*0* Extended 0xFB

I am assuming thats all. If I then put this back into the boards.txt file and produce a .hex file. can I just upload the resultant file using run-avrdude sketch.hex on the yun and assume the fuse bits were built into the .hex file at compile time or do I need to run-avrdude sketch.hex -U lfuse:w:0xff:m -U hfuse:w:0xd0:m -U efuse:w:0xfb:m to explicitely name the switches

I've just dug into this a little further

https://github.com/arduino/linino/blob/master/trunk/package/linino/yun-scripts/files/usr/bin/run-avrdude

shows me that run-avrdud seems to be a shell script with the arguments for the fuses already in it. I dont understand linux scripts that well so all the gpio stuff is confusing me. I am assuming run-avrdude is invoked somehow by the upload from the remove ide

!/bin/sh

echo 1 > /sys/class/gpio/gpio21/value avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFB:m -Uflash:w:$1:i $2 echo 0 > /sys/class/gpio/gpio21/value

so I am guessing my command would be

avrdude -c PROGRAMMER -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD0:m -U efuse:w:0xFB:m -Uflash:w:$1:i $2

Its the bits in red I dont understand. I am trying to figure out what i should use on here for a Yun? I assume that the programmer will remain -c linuxgpio as we are using the programmer attached to the gpio pins on the SOc but I cant make head nor tail of -Uflash:w:$1:i $2

From the AVRDUDE documentation -Uflash:w seems to be a switch which says w

read the specified file and write it to the specified device memory

and :i seems to be Intel Hex

but I have no idea what the $1 and $2 represent. At a guess I would assume they were wildcards fed to the script so I would run a command like

run-avrdude sketch.hex where I assume $1 is the sketch.hex file but I don't understand if I can just ignore the $2 parameter completely

Hello, I have the same problem here.. With an arduino Yun, after upload a sketch it seems to reset the eeprom also. Any news about a solution?

I'm observing the same behavior.

hello It appears that EEPROM is erased on the Yun when you upload a sketch, but works correctly and retains values if the Yun loses power and then power is restored.

Hoalan