feat: EEPROM-backed device configuration store #45

Open
opened 2026-08-29 20:53:27 +00:00 by time · 0 comments
Contributor

The first step toward user-configurable devices (no reflashing) is a persistent, versioned configuration block in the 256-byte data EEPROM. Currently only the packet counter is persisted (4 bytes at 0x00); the remaining 252 bytes are free. This issue defines the config schema, layout, versioning, and validation that all other configurability features build on.

Storage decision: data EEPROM. Both the data EEPROM and Flash program memory are self-writable at runtime via the EECON registers (EEPGD/CFGS select the space), so the "can the program write the Flash?" question is yes. We are using the data EEPROM anyway: it is byte-addressable, the firmware already has eeprom_read_16/32 and eeprom_write_16/32 helpers in PICKLE.h, and the config is written very infrequently (once, over UART), so wear is a non-issue. Flash would be the datasheet-recommended home for rarely-changing data, but the data EEPROM is simpler here.

Proposed starting layout (open to change):

  • magic/version byte + version (major.minor)
  • config length
  • CRC-8 over the config fields (reuse the CRC-8/MAXIM already in the firmware)
  • config fields: frequency slot, region (US/EU), update rate, analog pin config, I2C sensor config, packet format

Flow: after writing the config over UART (#46), the board is power-cycled; the config is loaded from EEPROM into RAM at boot and the device then runs continuously.

Open questions:

  • exact field layout and byte order
  • how much to reserve for future fields
  • how to handle a corrupt/absent config (fallback to factory defaults)
The first step toward user-configurable devices (no reflashing) is a persistent, versioned configuration block in the 256-byte data EEPROM. Currently only the packet counter is persisted (4 bytes at 0x00); the remaining 252 bytes are free. This issue defines the config schema, layout, versioning, and validation that all other configurability features build on. **Storage decision: data EEPROM.** Both the data EEPROM and Flash program memory are self-writable at runtime via the EECON registers (EEPGD/CFGS select the space), so the "can the program write the Flash?" question is yes. We are using the **data EEPROM** anyway: it is byte-addressable, the firmware already has `eeprom_read_16/32` and `eeprom_write_16/32` helpers in `PICKLE.h`, and the config is written very infrequently (once, over UART), so wear is a non-issue. Flash would be the datasheet-recommended home for rarely-changing data, but the data EEPROM is simpler here. Proposed starting layout (open to change): - magic/version byte + version (major.minor) - config length - CRC-8 over the config fields (reuse the CRC-8/MAXIM already in the firmware) - config fields: frequency slot, region (US/EU), update rate, analog pin config, I2C sensor config, packet format Flow: after writing the config over UART (#46), the board is power-cycled; the config is loaded from EEPROM into RAM at boot and the device then runs continuously. Open questions: - exact field layout and byte order - how much to reserve for future fields - how to handle a corrupt/absent config (fallback to factory defaults)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
daru/PICsense#45
No description provided.