HardFault on chRescheduleAhead

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

HardFault on chRescheduleAhead

Post by wurstnase »

Hi,

i've got a hardfault while testing my code.
Unfortunately this was a tool in normal use, where I'm not able to get the complete backtrace nor a debugger on it.

The only information I've had:
The SP was at 0x200003E0.
R0 at 0x0801EA4B which is chRescheduleAhead when I'm looking in the map file.

Any idea what could be the reason for this?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: HardFault on chRescheduleAhead

Post by Giovanni »

It could be anything, are you able to run the code with debug options enabled?

I would look for a stack overflow or a state violation.

Giovanni
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: HardFault on chRescheduleAhead

Post by wurstnase »

Yes, I will try to check this with debug options again.
Unfortunately this occure only once for now, just after a reboot.

How much space should the main stack have? I can see it will go down to 100bytes free.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: HardFault on chRescheduleAhead

Post by Giovanni »

Just enough, there is no need to keep "free" space.

You should also try to enable HW stack check, there is a port option for that, it is much more reliable than the normal SW check. If the application is critical I recommend keeping stack checking ON in release code.

You may also try to use chSysIntegrityCheckI() in your error handler for some on-field diagnostic.

Giovanni
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: HardFault on chRescheduleAhead

Post by wurstnase »

Thanks for your advice.
I will check some options.
Post Reply