MCPcopy Create free account
hub / github.com/Santroller/Santroller / load

Function load

src/config.cpp:1243–1270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241 return size;
1242}
1243bool load()
1244{
1245 const uint8_t *flashEnd = reinterpret_cast<const uint8_t *>(EEPROM_ADDRESS_START) + EEPROM_SIZE_BYTES;
1246 const ConfigFooter &footer = *reinterpret_cast<const ConfigFooter *>(flashEnd - sizeof(ConfigFooter));
1247
1248 // Check for presence of magic value
1249 if (footer.magic != FOOTER_MAGIC)
1250 {
1251 printf("footer wrong %x != %x\r\n", footer.magic, FOOTER_MAGIC);
1252 return false;
1253 }
1254
1255 // Check if dataSize exceeds the reserved space
1256 if (footer.dataSize + sizeof(ConfigFooter) > EEPROM_SIZE_BYTES)
1257 {
1258 return false;
1259 }
1260
1261 const uint8_t *dataPtr = flashEnd - sizeof(ConfigFooter) - footer.dataSize;
1262
1263 // Verify CRC32 hash
1264 if (CRC32::calculate(dataPtr, footer.dataSize) != footer.dataCrc)
1265 {
1266 return false;
1267 }
1268
1269 return inner_load(footer.currentProfile, dataPtr, footer.dataSize, footer.mainSize, footer.auxSize);
1270}
1271
1272void first_load()
1273{

Callers 2

hid_taskFunction · 0.85
mainFunction · 0.85

Calls 1

inner_loadFunction · 0.85

Tested by

no test coverage detected