mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-30 16:20:24 +00:00
stm32-f4discovery-cc256x: add disabled hard fault analysis helper code
This commit is contained in:
parent
bcd517299d
commit
b93f385697
@ -360,3 +360,61 @@ void port_main(void){
|
||||
// go
|
||||
btstack_run_loop_execute();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
// Help with debugging hard faults - from FreeRTOS docu
|
||||
// https://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html
|
||||
|
||||
void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress );
|
||||
void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress ) {
|
||||
|
||||
/* These are volatile to try and prevent the compiler/linker optimising them
|
||||
away as the variables never actually get used. If the debugger won't show the
|
||||
values of the variables, make them global my moving their declaration outside
|
||||
of this function. */
|
||||
volatile uint32_t r0;
|
||||
volatile uint32_t r1;
|
||||
volatile uint32_t r2;
|
||||
volatile uint32_t r3;
|
||||
volatile uint32_t r12;
|
||||
volatile uint32_t lr; /* Link register. */
|
||||
volatile uint32_t pc; /* Program counter. */
|
||||
volatile uint32_t psr;/* Program status register. */
|
||||
|
||||
r0 = pulFaultStackAddress[ 0 ];
|
||||
r1 = pulFaultStackAddress[ 1 ];
|
||||
r2 = pulFaultStackAddress[ 2 ];
|
||||
r3 = pulFaultStackAddress[ 3 ];
|
||||
|
||||
r12 = pulFaultStackAddress[ 4 ];
|
||||
lr = pulFaultStackAddress[ 5 ];
|
||||
pc = pulFaultStackAddress[ 6 ];
|
||||
psr = pulFaultStackAddress[ 7 ];
|
||||
|
||||
/* When the following line is hit, the variables contain the register values. */
|
||||
for( ;; );
|
||||
}
|
||||
|
||||
/* The prototype shows it is a naked function - in effect this is just an
|
||||
assembly function. */
|
||||
void HardFault_Handler( void ) __attribute__( ( naked ) );
|
||||
|
||||
/* The fault handler implementation calls a function called
|
||||
prvGetRegistersFromStack(). */
|
||||
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 prvGetRegistersFromStack \n"
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user