diff --git a/core/embed/sys/task/stm32/system.c b/core/embed/sys/task/stm32/system.c index cc31c71ea5..65d20f2415 100644 --- a/core/embed/sys/task/stm32/system.c +++ b/core/embed/sys/task/stm32/system.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -154,41 +155,59 @@ __attribute((naked, noreturn, no_stack_protector)) void system_emergency_rescue( #ifdef STM32U5 const char* system_fault_message(const system_fault_t* fault) { + static char message[48] = {0}; + const char* fault_type = "FAULT"; switch (fault->irqn) { case HardFault_IRQn: - return "(HF)"; + fault_type = "HF"; + break; case MemoryManagement_IRQn: - return "(MM)"; + fault_type = "MM"; + break; case BusFault_IRQn: - return "(BF)"; + fault_type = "BF"; + break; case UsageFault_IRQn: - return (fault->cfsr & SCB_CFSR_STKOF_Msk) ? "(SO)" : "(UF)"; + fault_type = (fault->cfsr & SCB_CFSR_STKOF_Msk) ? "SO" : "UF"; + break; case SecureFault_IRQn: - return "(SF)"; + fault_type = "SF"; + break; case GTZC_IRQn: - return "(IA)"; + fault_type = "IA"; + break; case NonMaskableInt_IRQn: - return "(CS)"; - default: - return "(FAULT)"; + fault_type = "CS"; + break; } + mini_snprintf(message, sizeof(message), "%s @ 0x%08X", fault_type, + (unsigned int)fault->pc); + return message; } #else // STM32U5 const char* system_fault_message(const system_fault_t* fault) { + static char message[48] = {0}; + const char* fault_type = "FAULT"; switch (fault->irqn) { case HardFault_IRQn: - return "(HF)"; + fault_type = "HF"; + break; case MemoryManagement_IRQn: - return (fault->sp < fault->sp_lim) ? "(SO)" : "(MM)"; + fault_type = (fault->sp < fault->sp_lim) ? "SO" : "MM"; + break; case BusFault_IRQn: - return "(BF)"; + fault_type = "BF"; + break; case UsageFault_IRQn: - return "(UF)"; + fault_type = "UF"; + break; case NonMaskableInt_IRQn: - return "(CS)"; - default: - return "(FAULT)"; + fault_type = "CS"; + break; } + mini_snprintf(message, sizeof(message), "%s @ 0x%08X", fault_type, + (unsigned int)fault->pc); + return message; } #endif // STM32U5 diff --git a/core/embed/util/rsod/rsod.c b/core/embed/util/rsod/rsod.c index 16656c70cc..81cd4ad5bf 100644 --- a/core/embed/util/rsod/rsod.c +++ b/core/embed/util/rsod/rsod.c @@ -142,8 +142,11 @@ void rsod_gui(const systask_postmortem_t* pminfo) { if (message[0] == '\0') { mini_snprintf(message_buf, sizeof(message_buf), "%s:%u", pminfo->fatal.file, (unsigned int)pminfo->fatal.line); - message = message_buf; + } else { + mini_snprintf(message_buf, sizeof(message_buf), "%s\n%s:%u", message, + pminfo->fatal.file, (unsigned int)pminfo->fatal.line); } + message = message_buf; break; case TASK_TERM_REASON_FAULT: