fix(esp_system/panic): ensure breakpoint set from panic handler gets hit afterwards

This commit is contained in:
Samuel Obuch
2026-09-03 12:36:02 +02:00
parent b2672c7937
commit 2faeddce31
4 changed files with 31 additions and 6 deletions
+13 -1
View File
@@ -394,6 +394,12 @@ void esp_panic_handler(panic_info_t *info)
}
panic_print_str("Setting breakpoint at 0x");
panic_print_hex((uint32_t)info->addr);
#if __riscv
// Interrupts can trigger before the breakpoint is hit,
// so disable them on global level to avoid any further execution.
RV_CLEAR_CSR(mstatus, MSTATUS_MPIE | MSTATUS_SPIE | MSTATUS_UPIE);
panic_print_str(", disabling global interrupts,");
#endif
panic_print_str(" and returning...\r\n");
// Trigger early breakpoint handlers before returning to debugger.
@@ -404,7 +410,13 @@ void esp_panic_handler(panic_info_t *info)
esp_panic_trigger_event(ESP_SYS_EVENT_PANIC_EARLY_BREAK, &panic_ctx);
panic_disable_all_wdts();
esp_cpu_set_breakpoint(0, info->addr); // use breakpoint 0
// use breakpoint 0
if (esp_cpu_set_breakpoint(0, info->addr) != ESP_OK) {
#if __riscv
// Halt here if unable to set a breakpoint.
asm("ebreak");
#endif
}
return;
}
#endif //CONFIG_ESP_DEBUG_OCDAWARE