Page 1 of 1

HardFault on chRescheduleAhead

Posted: Thu Jan 23, 2020 10:15 am
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?

Re: HardFault on chRescheduleAhead

Posted: Thu Jan 23, 2020 10:51 am
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

Re: HardFault on chRescheduleAhead

Posted: Thu Jan 23, 2020 11:28 am
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.

Re: HardFault on chRescheduleAhead

Posted: Thu Jan 23, 2020 11:33 am
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

Re: HardFault on chRescheduleAhead

Posted: Thu Jan 23, 2020 12:27 pm
by wurstnase
Thanks for your advice.
I will check some options.