5432
5226; Exception Error Recovery Fix
Pathfinder

Changes made for Pathfinder 5226 controllers.

What was ported from the XL200 file (the three real diagnostic fixes):

Naked Exception_ISR stub that pushes R4-R11 before any compiler-emitted code, then branches to a new C body. The old version read R4-R11 from inside a C function and only worked by luck of register allocation. Correct frame selection for nested faults. The body now reads the hardware frame from the interrupt stack when the fault interrupted an ISR, and from PSP only for a task-context fault. The old code always read PSP, which blamed an unrelated task on every ISR-context crash. PSP/MSP transposition fix in both Exception_ISR and Exception_Error. The struct has PSP_Reg at 0x48 and MSP_Reg at 0x4C, but the asm stored them the other way round, so the printout in BlackBox.c and the CmdErrors.c UDP reply showed each under the other's label. Flash records written before this change are still swapped. What I verified against this workspace's MQX 4.2 before porting: the dispatcher in dispatch.S pushes lr then exactly four words, so the 20-byte nested-frame offset holds; cortex.h is identical between the K60 and K66 psp libs; MQX_USE_IO_OLD is 1 so the context struct is 16 bytes and the compile-time size check will pass; the psp directory is already on this project's include path; and READY is defined in Flash_Routine.h, so the #undef READY is needed here too.

Deliberately left out as XL-specific: Exception_Error_No_Reset, the bReset parameter on Exception_Log, the Disable_5387() call and AMS_5387.h include, Get_Task_Error(), the is_Task_Error() guard inside the flash-write loop, and the XL rewrite of that loop. The 5226 Exception_Log, CPLD reset, and high-speed-mode handling are untouched.

Not touched: Hardware_Common_5226_Board and HW_Common_5226_Board carry their own older copies of this file and were left alone. The file's 0xA9 copyright byte and CRLF endings were preserved and verified.

Model Version Released
5226BB Rev G. 5.00.31 11/2/2026
5226BB Rev H. 5.01.07 11/2/2026