mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Improve robustness of reading config from flash.
This commit is contained in:
parent
cf1ce1a67b
commit
720132b2af
1 changed files with 7 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue