This one is so weird I assume I'm doing something wrong (in large part because I haven't worked with eeprom on the AVR before).
I've got a couple of configuration values in eeprom (ATmega48P), and after a day or two unpowered many units have lost the values. At this point my code does not write to eeprom, only reads from it. I write the eeprom by downloading the .eep file from AVR Studio.
Here are the relevant code snips:
Initializing in source:
uint8_t EEMEM EE_device_addr = 3;
Reading back on code startup:
Device_addr = eeprom_read_byte( &EE_device_addr );
From the map file:
.eeprom 0x00810000 0x2 *(.eeprom*) .eeprom 0x00810000 0x2 globals.o 0x00810001 EE_frame_cnt 0x00810000 EE_device_addr 0x00810002 __eeprom_end = .
The code compiles without error or warning, and it always runs correctly after I program the devices. It's only when I turn on the units a few days later that some have lost their configuration values, replaced with random values such as 0x1D, 0xEE, 0xFC, 0xFF.
FWIW, of the two configuration values I'm setting, the first is always trashed when I read back from bad units, while the second was only trashed in one unit.