1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/cortexm: rework bkpt instruction call on panic

Only call this instruction if a debug session is active otherwise it will trigger a hardfault

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
This commit is contained in:
Dylan Laduranty 2024-04-23 20:23:28 +02:00
parent 3ae63a14ef
commit 5d3324d3a9

View File

@ -39,7 +39,15 @@ void panic_arch(void)
{
#ifdef DEVELHELP
print_ipsr();
/* The bkpt instruction will signal to the debugger to break here. */
__asm__("bkpt #0");
/* CM0+ has a C_DEBUGEN bit but it is NOT accessible by CPU (only by debugger) */
#ifdef CoreDebug_DHCSR_C_DEBUGEN_Msk
if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) {
/* if Debug session is running, tell the debugger to break here.
Skip it otherwise as this instruction will cause either a fault
escalation to hardfault or a CPU lockup */
__asm__("bkpt #0");
}
#endif /* CoreDebug_DHCSR_C_DEBUGEN_Msk */
#endif
}