This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Event recorder cause hard fault

By enable the event recoder in our uVision RTX project I run into an hard vault inside "Check Round Robin timeout".

The hard fault happens on Line 150 in rtx_system.c ("if (thread->delay != 0U)")

I get the stack  and the programm counter with this 

__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"
);

and with this.

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 scatter file

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x08000000 0x00400000 { ; load region size_region
ER_IROM1 0x08000000 0x00400000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
.ANY (+XO)
}
RW_IRAM1 0x20000000 0x00260000 { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 0x20260000 UNINIT 0x00001000 {
EventRecorder.o (+ZI)
}
}

If I comment out the 

EventRecorderInitialize (EventRecordAll, 1); 

The systems runs as expected.

Thanks for your help and kind regards

René Henke 

  • I would suggest you debug that function and see when and if it is the one that causes that fault.

    From your information it looks like the CPU tried to access memory at address 0x1C (BFAR register) and it seems there is no memory mapped at that address thus it resulted in Bus fault.

    And then the BusFault handler caused another fault resulting in HardFault escalation.

    You can take also a look at CMSIS-View Fault analysis and use that to try to find what exactly happens.

  • Hi Milorad

    The problem was, that the SysTick Timer was configured instead of TIM6. So the SysTick was running and if the initalisation process needs more time the RTX tries to start a thread but the OS isn't configured because I start it after the hardware initalisation and directly after enable of TIM6 (that wasn't my SysTick timer).

    Inside the osRtxTick_Handler there is no control if there is allready a task or not.

    Thanks and kind regards

    René

  • Hi René,

    thanks for providing a follow up on the issue, it might be useful for somebody in future.

    Best regards, Milorad