feat: STM32 watchdog and fault recovery handler (Issue #565) #583
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "sl-firmware/issue-565-fault-handler"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
.noinitSRAM capture ring tagged with magic; survivesNVIC_SystemReset(); persisted to flash sector 7 (8×64-byte slots at 0x08060000) on subsequent boot__stack_end) → MemManage →FAULT_STACK_OVFRCC_CSR_BORRSTF→FAULT_BROWNOUTfault_handler_init(),fault_led_tick(),fault_log_read(),fault_get_last_type(),FAULT_ASSERT()macroJLINK_CMD_FAULT_LOG_GET(0x0F) →JLINK_TLM_FAULT_LOG(0x86, 20 bytes)fault_handler_init()first inmain(); boot-time fault log TLM;fault_led_tick()in loop;fault_log_reqhandlerTest plan
pio run -e f722— no errorsFAULT_LOG_GET(0x0F) →FAULT_LOGTLM (0x86) with PC/CFSRfault_log_clear()→ sector erased, PID store restoredCloses #565
🤖 Generated with Claude Code
- New src/fault_handler.c + include/fault_handler.h: - HardFault/MemManage/BusFault/UsageFault naked ISR stubs with Cortex-M7 stack-frame capture (R0-R3, LR, PC, xPSR, CFSR, HFSR, MMFAR, BFAR, SP) and NVIC_SystemReset() - .noinit SRAM capture ring survives soft reset; persisted to flash sector 7 (0x08060000, 8x64-byte slots) on subsequent boot - MPU Region 0 stack guard (32 B at __stack_end, no-access) -> MemManage fault detected as FAULT_STACK_OVF - Brownout detect via RCC_CSR_BORRSTF on boot -> FAULT_BROWNOUT - Watchdog reset detection delegates to existing watchdog.c - LED blink codes on LED2 (PC14, active-low) for 10 s post-recovery: HARDFAULT=3, WATCHDOG=2, BROWNOUT=1, STACK_OVF=4 fast blinks - fault_led_tick(), fault_log_read(), fault_log_get_count(), fault_get_last_type(), fault_log_clear(), FAULT_ASSERT() macro - jlink.h: add JLINK_CMD_FAULT_LOG_GET (0x0F), JLINK_TLM_FAULT_LOG (0x86), jlink_tlm_fault_log_t (20 bytes), fault_log_req in JLinkState, jlink_send_fault_log() declaration - jlink.c: dispatch JLINK_CMD_FAULT_LOG_GET; implement jlink_send_fault_log() (26-byte CRC16-XModem framed response) - main.c: call fault_handler_init() first in main(); send fault log TLM on boot if prior fault recorded; fault_led_tick() in main loop; handle fault_log_req flag to respond to Jetson queries Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>13dd30c44cto8fbe7c0033