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

HardFault_Hander before os_sys_init

Hi all,

I'm using Keil RV4.10 on MCBSTM32 demo board (STM32F103RB) with STM32F10x_StdPeriph_Lib_V3.1.2 and Keil RTX kernel.

My application is relocated at 0x8002800 (bootloader and configuration data are placed before).

My main just setup the clock, peripherals, interrupts, etc ... and call

os_sys_init


All seems to be ok.

Recently I had to add in infinite cicle for debug/test purposes just after clocks and irq setup, like this:

int main(void)
{
    MicroController.Setup(); //setup clock, preiphs, irq,...

    while(1) {
        IWDG_ReloadCounter(); //DEBUG
    }

    os_sys_init(FirstTask);
}

then something strange happens... during the while(1) loop the application goes into HardFault_Handler, and the debugger shows me the following call stack:

HardFault_Handler()
rt_put_rdy_first()
rt_systick()
HAL_CM3()
rt_systick()

Could this be related to the RTX kernel ?

What's happening ? Am I not allowed to do whatever I want before calling

os_sys_init

??

Parents
  • Jed C,

    thanks for the links, but they didn't help.
    I do have a large-enough main stack, my code is all privileged, and all my setup activities uses global or setup-local variables, so the stack is clean after hw initialization.
    Furthermore, there are no problems if I don't put an endless loop before the os_sys_init call, and the loop itself consumes very little stack...
    So it seems a matter of ''how long'' I indulge in the main before calling os_sys_init...
    From the call stack seems that the os is trying to schedule, but ther's nothing to schedule yet... hence the hardfault...

    Any more specific hint ?

Reply
  • Jed C,

    thanks for the links, but they didn't help.
    I do have a large-enough main stack, my code is all privileged, and all my setup activities uses global or setup-local variables, so the stack is clean after hw initialization.
    Furthermore, there are no problems if I don't put an endless loop before the os_sys_init call, and the loop itself consumes very little stack...
    So it seems a matter of ''how long'' I indulge in the main before calling os_sys_init...
    From the call stack seems that the os is trying to schedule, but ther's nothing to schedule yet... hence the hardfault...

    Any more specific hint ?

Children
No data