Re: EEPROM guarantees after power loss during a write



David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

John Devereux wrote:
ssubbarayan <ssubba@xxxxxxxxx> writes:


[...]

John,
My only worry was getting atleast one good copy.In your whole
algorithm,you have assumed atleast one good copy exists.I was
wondering what would be situation when the first time(no copy
available,freshly you are writing data),and you encounter power brown
out situation.

Firstly, Davids algorithm is better - use a version number based
system like he describes.

For any possible algorithm, if the power fails during writing of data,
you are always going to lose *that version*. Just as if the power
failed before you started to write it.

Assuming your eeprom is initially filled with 0xff, and a 32 bit
version number, then a version number of 0xffffffff (or -1) would
indicate a missing copy.


It's actually enough with the versioning stamp to distinguish between
invalid, and newer or later versions. All you really need are
versions 1, 2, and 3, and wrap to 1 again after 3. Anything other
than 1, 2, or 3 is invalid.

Cool - I was thinking of avoiding the wrap entirely by having a range
so high it would never happen :)

One thing to watch out for, however, is the possibility of corruption
at addresses other than the one you are writing. External serial
eeproms generally have protection against this, but Atmel AVRs are
known to be able to corrupt byte 0 of the eeprom if they get a reset
during a write (the address register gets cleared to 0, but the write
continues - thus the data at address 0 may be half overwritten). The
same problem can probably occur on many other eeproms - I don't know
if the AVRs are a particular high risk, or if Atmel is just unusually
honest!

I would still love to know, for sure, that a write to part of a page
does not involve an internal erasure of the entire page. Without
knowing this each version stamp needs a page of its own as far as I
can see. The act of writing the version number must be guaranteed not
to upset the data it refers to, if it gets interrupted.

I think I will have to try and test this.

--

John Devereux
.



Relevant Pages

  • Re: EEPROM guarantees after power loss during a write
    ... My only worry was getting atleast one good copy.In your whole ... For any possible algorithm, if the power fails during writing of data, ... External serial eeproms generally have protection against this, but Atmel AVRs are known to be able to corrupt byte 0 of the eeprom if they get a reset during a write. ...
    (comp.arch.embedded)
  • Re: How to design non blocking device drivers?
    ... You have only one EEPROM, and one EEPROM can only do one write job at a time. ... But your requirement to complete writing excludes 3) and 1), and you explicitly excluded 2), which leaves you with no way to do the job. ... is called asynchronous operations. ...
    (comp.arch.embedded)
  • Re: Writing to EEPROM
    ... I will be using internal EEprom - 512bytes. ... How many bytes will you be writing?. ... before the processor stops working (normally if the brownout is at ... How low can you get the power consumption ...
    (sci.electronics.design)
  • Re: Sopranos "A pint of blood is worth more than a gallon of gold"
    ... That doesn't mean it waas good writing... ... (atleast I didn't say... ... That don't mean the writing ain't any good) ... -A hallmark christmas ending with no discernable resolution? ...
    (rec.music.phish)
  • Re: Writing a serial number to EEPROM...
    ... data to the EEPROM. ... tells the Cypress chip to write to EEPROM and how to do it. ... so I wasn't writing to the EEPROM. ... upload the new binary file to the FX2 EEPROM. ...
    (comp.arch.embedded)