From 09c3f3aa5ebefa769d06c622cefba96aec069302 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 21 Oct 2023 16:24:38 -0400 Subject: [PATCH] EMI kills USB and causes a FATAL on the ECU #4310 only:small-can-board_debug --- firmware/controllers/core/error_handling.cpp | 12 ++++++++++++ firmware/hw_layer/backup_ram.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index 6b7802c999..5bfc994419 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -35,6 +35,9 @@ void checkLastBootError() { efiPrintf("Last boot had firmware error: %s", sramState->ErrorString); break; case ErrorCookie::HardFault: { + efiPrintf("Last boot had raw: %s", sramState->rawMsg); + efiPrintf("Last boot had hardFile: %s", sramState->hardFile); + efiPrintf("Last boot had line: %d", sramState->hardLine); efiPrintf("Last boot had error: %s", sramState->ErrorString); efiPrintf("Last boot had hard fault type: %x addr: %x CSFR: %x", sramState->FaultType, sramState->FaultAddress, sramState->Csfr); if (engineConfiguration->rethrowHardFault) { @@ -102,6 +105,15 @@ void chDbgPanic3(const char *msg, const char * file, int line) { __asm volatile("BKPT #0\n"); #endif +#if EFI_BACKUP_SRAM + auto sramState = getBackupSram(); + if (sramState != nullptr) { + strncpy(sramState->hardFile, file, efi::size(sramState->hardFile)); + sramState->hardLine = line; + strncpy(sramState->rawMsg, msg, efi::size(sramState->rawMsg)); + } +#endif // EFI_BACKUP_SRAM + if (hasOsPanicError()) return; dbg_panic_file = file; diff --git a/firmware/hw_layer/backup_ram.h b/firmware/hw_layer/backup_ram.h index a7b7d13d3c..2a880d4954 100644 --- a/firmware/hw_layer/backup_ram.h +++ b/firmware/hw_layer/backup_ram.h @@ -52,6 +52,9 @@ struct BackupSramData { ErrorCookie Cookie; critical_msg_t ErrorString; + critical_msg_t hardFile; + int hardLine; + critical_msg_t rawMsg; port_extctx FaultCtx; uint32_t FaultType; uint32_t FaultAddress;