Skip to content

Commit

Permalink
Improve robustness of reading config from flash.
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra committed Jun 13, 2019
1 parent cf1ce1a commit 720132b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/config/config_eeprom.c
Expand Up @@ -88,15 +88,17 @@ bool loadEEPROMFromExternalFlash(void)
uint32_t flashStartAddress = flashPartition->startSector * flashGeometry->sectorSize;

uint32_t totalBytesRead = 0;
uint32_t bytesRead = 0;
int bytesRead = 0;

bool success;
bool success = false;

do {
bytesRead = flashReadBytes(flashStartAddress + totalBytesRead, &eepromData[totalBytesRead], EEPROM_SIZE - totalBytesRead);
totalBytesRead += bytesRead;
success = (totalBytesRead == EEPROM_SIZE);
} while (!success && bytesRead);
if (bytesRead > 0) {
totalBytesRead += bytesRead;
success = (totalBytesRead == EEPROM_SIZE);
}
} while (!success && bytesRead > 0);

return success;
}
Expand Down

0 comments on commit 720132b

Please sign in to comment.