In a EDN, Design Idea (Jan/21/2010) Algorithm keeps data safe by Luis G Uribe C, Caracas, Venezuela; Edited by Martin Rowe and Fran Granville. There is discussion of how to prevent data loss while updating memory, even if a power fail or reset happens, based on a simple Gray Code State Machine.
The article Making Nonvolatile Data Reliable by David Hinerman, covers similar ground.
Also I have previously mentioned here Offsetof, which is very useful to help keep our data safe.
Now maybe you can help me out finding something. I have been trying to find the origin of a story, without success so far for some time, related to restoring default EEPROM settings to "factory" settings. The story goes like this:
A lady took her car back to the dealer, and asked that they disable the front seat passenger Air Bags, as her young son always road in that seat. The dealer did as the lady asked, "the customer is always right". Some time later something happened, possibly a jump start due to dead battery. This event caused the Engine Control Unit (ECU) to restore the EEPROM to the default factory values. The default factory setting re-enabled the passenger side Air Bag. There was then an accident, in which the boy was killed by the Air Bag deployment.
Even if the story is not true, it still illustrates just how hard it is to do a "safe" embedded system.
"Programming is a race between writing a program that any idiot can use, and the Universe building bigger and better idiots. The Universe is winning." -- Unknown