hardwario / lora-modem

Open LoRaWAN modem for Murata Type ABZ
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

Add headers to NVM data structures #17

Open janakj opened 2 years ago

janakj commented 2 years ago

At the moment, LoRaMac structures are restored from NVM if their CRC32 checksums match. We should also add a header to each data structure with the name of the structure, version, and size. This would make it possible to create NVM parts with sizes that are independent of the size of the LoRaMac NVM structure stored in it. This would essentially become a rudimentary filesystem.

If the header is updated if and only if the entire structure has been saved, we could implement atomic NVM structure writes. This would require that each such structure has two independent locations within the EEPROM.

janakj commented 2 years ago

The first part of this is implemented: fixed EEPROM partition so that all data structures have some wiggle room and it all fits into a single EEPROM bank.

In the future, support for atomic writes will be added. We will use both EEPROM banks to implement that. Writes will go into the part in the inactive bank and upon a successful write the active/inactive status of the two parts will be switched.