25

ATMEL says the cell lifetime of an EEPROM cell is about 100,000 write cycle/ cell. Is this actually how the EEPROM performs in the wild?

If I do not change the value of a cell, does this stress the lifetime? For example, if I write the value 0xFF to the same cell again and again, is this any different to writing 0x00, 0xFF, 0x00 etc.

0

5 Answers 5

23

As you state, the internal EEPROM has a lifetime of 100,000 write cycles. This isn't a guess - a very significant proportion of ATmega328 will reach this number with no issues. I have tested three processors before, and all reached 150,000 cycles with no issues.

It is important to note the failure mode of EEPROM. Most "EEPROM destroyer" projects repeatedly read/write until the data is not written at all. Before this point, the EEPROM will still be damaged. This would be manifested by data not being retained for a reasonable period. It is unwise to rely on anything more than 100,000 write cycles for this reason.

EEPROM is different to the RAM on an ATmega. Writing to it is not simple or quick, but it is wrapped up in a friendly Arduino library, hiding this complexity from the user.

The first level of indirection is the EEPROM library, which is trivially simple], just calling two other functions for read and write. This calls eeprom_write_byte, found here.

This function uses inline assembly, so might not be easily understood. There is a comment that is easily understood though:

Set programming mode: erase and write

This hints to one of the complexities of dealing with EEPROM - to write to it, you first need to erase it. This means that if you call EEPROM.write(), it will perform a write cycle regardless of the value you are writing.

This means that repeatedly writing 0xFF will likely have the same effect as writing 0xFF,0x00,0xFF,0x00 etc.

There are ways to work around this - you can try calling EEPROM.read() before EEPROM.write() to see if the value is already the same, but this takes additional time.

There are other techniques to avoid excessive EEPROM wear, but their use depends on your application.

2
  • 4
    Wear leveling for EEPROM: electronics.stackexchange.com/questions/60342/…
    – jippie
    Commented Feb 15, 2014 at 7:40
  • @Cybergibbons I am trying to determine why an EEPROM in a system is only retaining a value for seconds. E.g. if I read the value back immediately it looks like the write was successful. If I read it back seconds later I start seeing bits go from 1 to 0. You mentioned above "Before this point, the EEPROM will still be damaged. This would be manifested by data not being retained for a reasonable period." Does the failure mode I am describing sounds like something that could occur from a high number of erase/write cycles to a particular EEPROM location?
    – Nick
    Commented Jul 31, 2020 at 20:14
10

I once ran an experiment on an external EEPROM with 1 million max rated cycles. It took about 6 million cycles to become majorly corrupted, and before that it had progressed having sporadic amounts of corruption.

When you say you do not change the value, i am assuming you are writing the same data to an address multiple times. This almost certainly would stress the life, although it would probably not stress the surrounding cells.

4

The magic solution - if you dont want to code what Cybergibbons said about reading before writing, is the EEPROM.update() function. It does exactly that:

EEPROM.update(address, value);

will only write and stress the memory if value is different from that already stored.

2

http://hackaday.com/2011/05/16/destroying-an-arduinos-eeprom/

The Arduino was plugged into a wall wart and sat, “behind a couch for a couple of months.” The EEPROM saw it’s first write error after 47 days and 1,230,163 cycles. This is an order of magnitude better than the spec on the atmel datasheet, but similar to the results of similar experiments.

2
  • This seems far too high. I had heard of 150k to 200k before, but never this :o
    – asheeshr
    Commented Feb 15, 2014 at 9:00
  • 7
    The problem is that this doesn't detect all the failure modes. When EEPROM becomes damaged, what happens is the length of time that it will retain data is gradually decreased. At 100,000 cycles, Atmel guarantee 20 years data retention. Beyond this, the data retention reduces. When 1.2m cycles are reached, and you see an error, this is an immediate error. at 1,230,160 cycles, there may not have been an immediate error, but the data might only have been retained for days. Commented Feb 19, 2014 at 6:24
1

Couple years ago I made run time logger for piece of equipment. Memory got corrupted after 6 months 40 hours logged with 1s resolution => 144000 writes. My solution was to spread writes over entire eeprom.

2
  • Can you provide more details about how you did this?
    – VE7JRO
    Commented Jan 2, 2020 at 20:14
  • 1
    My 2ct: clear the memory (write all zeroes or 0xFF; something you can recognise). Then: every time you want to restore: find the first occurrence of the identifier, load from the address before it and save the new value to the spot you found. This way you move over the entire address space. Rise and repeat when you reach the end of the address space.
    – Nebula
    Commented Mar 21, 2022 at 21:02

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