Skip to content

Commit 79d1060

Browse files
committed
add hard_fault handler
1 parent 373e56f commit 79d1060

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.gdbinit

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target extended-remote :4242
2+
b hard_fault_handler_c

main.c

+19
Original file line numberDiff line numberDiff line change
@@ -1485,3 +1485,22 @@ int main(void)
14851485
chThdSleepMilliseconds(1000);
14861486
}
14871487
}
1488+
1489+
/* The prototype shows it is a naked function - in effect this is just an
1490+
assembly function. */
1491+
void HardFault_Handler( void );
1492+
1493+
void hard_fault_handler_c(uint32_t *sp) __attribute__( ( naked ) );;
1494+
1495+
void HardFault_Handler(void)
1496+
{
1497+
uint32_t* sp;
1498+
//__asm volatile ("mrs %0, msp \n\t": "=r" (sp) );
1499+
__asm volatile ("mrs %0, psp \n\t": "=r" (sp) );
1500+
hard_fault_handler_c(sp);
1501+
}
1502+
1503+
void hard_fault_handler_c(uint32_t* sp)
1504+
{
1505+
while (true) {}
1506+
}

0 commit comments

Comments
 (0)