DavidGriffith / bluebox-avr

Bluebox firmware for AVR microcontrollers (moved to https://gitlab.com/DavidGriffith/bluebox-avr)
GNU General Public License v3.0
2 stars 1 forks source link

EEPROM write cycles #3

Open DavidGriffith opened 7 years ago

DavidGriffith commented 7 years ago

It might be a good idea to implement some sort of wear-leveling scheme to keep the EEPROM from dying early. It was suggested to me that some sort of round-robin scheme would do.

Doodles...

struct chunk {
    uint8_t generation;
    uint8_t id;
    uint8_t mode;
    uint8_t speed;
    uint8_t data [32];
    uint8_t checksum;
}
struct chunk[12] eeprom;

id ranges from 0-12 with 0 being the startup mode (data part ignored). On startup, scan the eeprom for chunks with correct checksum and highest generation number.

When writing, increment the generation number and write after the last valid chunk and start from the beginning when reaching the end.

DavidGriffith commented 7 years ago

FRAM, MRAM, or EERAM sound like a fun solution to this. I'll explore that once I finalize this iteration.