Skip to content

Commit

Permalink
EEPROM: Consider also zeroed header as empty
Browse files Browse the repository at this point in the history
The default state of physical EEPROMs is usually 0xFF. However, a
simulated EEPROM is initialized with zeros. Both cases should be
considered as empty.
  • Loading branch information
martinjaeger committed Apr 14, 2024
1 parent 1f23a8c commit d01f062
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/storage_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ static int thingset_eeprom_load(off_t offset)

LOG_INF("EEPROM load: ver %d, len %d, CRC 0x%.8x", header.version, header.data_len, header.crc);

if (header.version == 0xFFFF && header.data_len == 0xFFFF && header.crc == 0xFFFFFFFF) {
LOG_DBG("EEPROM empty");
if ((header.version == 0xFFFF && header.data_len == 0xFFFF && header.crc == 0xFFFFFFFF)
|| (header.version == 0U && header.data_len == 0U && header.crc == 0U))
{
LOG_INF("EEPROM empty, keeping default values for data objects");
return 0;
}
else if (header.version != CONFIG_THINGSET_STORAGE_DATA_VERSION) {
Expand Down

0 comments on commit d01f062

Please sign in to comment.