mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +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 flashStartAddress = flashPartition->startSector * flashGeometry->sectorSize;
|
||||||
|
|
||||||
uint32_t totalBytesRead = 0;
|
uint32_t totalBytesRead = 0;
|
||||||
uint32_t bytesRead = 0;
|
int bytesRead = 0;
|
||||||
|
|
||||||
bool success;
|
bool success = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
bytesRead = flashReadBytes(flashStartAddress + totalBytesRead, &eepromData[totalBytesRead], EEPROM_SIZE - totalBytesRead);
|
bytesRead = flashReadBytes(flashStartAddress + totalBytesRead, &eepromData[totalBytesRead], EEPROM_SIZE - totalBytesRead);
|
||||||
totalBytesRead += bytesRead;
|
if (bytesRead > 0) {
|
||||||
success = (totalBytesRead == EEPROM_SIZE);
|
totalBytesRead += bytesRead;
|
||||||
} while (!success && bytesRead);
|
success = (totalBytesRead == EEPROM_SIZE);
|
||||||
|
}
|
||||||
|
} while (!success && bytesRead > 0);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue