Let's get (non)volatile

The functions like sFLASH_ReadBuffer and sFLASH_WriteBuffer for working with the external flash chip are defined in the core-common-lib, here:

Additionally, you may in some cases have to erase a sector using sFLASH_EraseSector(uint32_t SectorAddr) before writing to it. I encountered this when working on the thermostat. Most of the rest of the following commit is incidental—the thing that made it work was the addition of sFLASH_EraseSector before writing:

The size of the erasable sectors is 4kB = 0x1000. So e.g., if you erase the sector at 0x80000 like I do in the thermostat code, that erases everything from 0x80000 to 0x80FFF. The next sector begins at 0x81000.

1 Like