1
0
Fork 0
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:
Dominic Clifton 2019-06-04 18:33:48 +02:00
parent cf1ce1a67b
commit 720132b2af

View file

@ -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;
}