check if flash erase failed (#2543)

* check flash erase result

* format

* string

* s
This commit is contained in:
Matthew Kennedy 2021-04-12 05:18:11 -07:00 committed by GitHub
parent 2a754c6e3f
commit 70283f42c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -89,7 +89,12 @@ void writeToFlashIfPending() {
template <typename TStorage>
int eraseAndFlashCopy(flashaddr_t storageAddress, const TStorage& data)
{
intFlashErase(storageAddress, sizeof(TStorage));
auto err = intFlashErase(storageAddress, sizeof(TStorage));
if (FLASH_RETURN_SUCCESS != err) {
firmwareError(OBD_PCM_Processor_Fault, "Failed to erase flash at %#010x", storageAddress);
return err;
}
return intFlashWrite(storageAddress, reinterpret_cast<const char*>(&data), sizeof(TStorage));
}