improve debugging on cortex m

This commit is contained in:
Kevin Hester
2021-03-08 15:20:29 +08:00
parent 6ceb423033
commit c0e180759d
3 changed files with 49 additions and 4 deletions

View File

@@ -82,8 +82,34 @@ extern "C" void HardFault_Impl(uint32_t stack[])
// while (1) ;
}
#ifndef INC_FREERTOS_H
// This is a generic cortex M entrypoint that doesn't assume freertos
extern "C" void HardFault_Handler(void)
{
asm volatile(" mrs r0,msp\n"
" b HardFault_Impl \n");
}
#else
/* The prototype shows it is a naked function - in effect this is just an
assembly function. */
extern "C" void HardFault_Handler( void ) __attribute__( ( naked ) );
/* The fault handler implementation calls a function called
prvGetRegistersFromStack(). */
extern "C" void HardFault_Handler(void)
{
__asm volatile
(
" tst lr, #4 \n"
" ite eq \n"
" mrseq r0, msp \n"
" mrsne r0, psp \n"
" ldr r1, [r0, #24] \n"
" ldr r2, handler2_address_const \n"
" bx r2 \n"
" handler2_address_const: .word HardFault_Impl \n"
);
}
#endif