Skip to content

Commit 61bd919

Browse files
committed
Modified to halt only if there is a debugger
1 parent 7ab4b58 commit 61bd919

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

Core/Src/stm32h7xx_it.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,14 @@ __attribute__((noreturn, optimize("O0"))) void my_fault_handler_c(sContextStateF
274274
&metadata_buffer,
275275
sizeof(metadata_buffer)
276276
);
277-
// In debug builds, stop here instead of forcing a reset loop.
278-
#ifndef NDEBUG
279-
__BKPT(0);
280-
while (1) {
281-
}
282-
#else
283-
// In debug sessions on release binaries, stop here as well.
277+
278+
// halt only when a debugger is attached, otherwise reboot.
284279
volatile uint32_t* dhcsr = (volatile uint32_t*)0xE000EDF0;
285280
if ((*dhcsr & 0x1U) != 0U) {
286281
__BKPT(0);
287282
while (1) {
288283
}
289284
}
290-
#endif
291285

292286
// Reboot the system in non-debug runs.
293287
volatile uint32_t* aircr = (volatile uint32_t*)0xE000ED0C;
@@ -316,13 +310,13 @@ void NMI_Handler(void) {
316310
* @brief This function handles Memory management fault.
317311
*/
318312
__attribute__((naked)) void MemManage_Handler(void) { HARDFAULT_HANDLING_ASM(); }
319-
/**
320-
* @brief This function handles Pre-fetch fault, memory access fault.
313+
/**
314+
* @brief This function handles Pre-fetch fault, memory access fault.
321315
*/
322316
__attribute__((naked)) void BusFault_Handler(void) { HARDFAULT_HANDLING_ASM(); }
323317

324-
/**
325-
* @brief This function handles Undefined instruction or illegal state.
318+
/**
319+
* @brief This function handles Undefined instruction or illegal state.
326320
*/
327321
__attribute__((naked)) void UsageFault_Handler(void) { HARDFAULT_HANDLING_ASM(); }
328322

0 commit comments

Comments
 (0)