RTOS iwatchdog callback

basile wrote on Thursday, May 17, 2018:

Hello everyone,

I’m currently working on a stm32f4 project and I have a question about the best way to identify errors.
I have a iwatchdog (from HAL library) which guaranted that my application is still running (refresh during idle time).
My goal is to make my application crash and be able after the restart to know which file/line was the error.

It seems that a iwatchdog can’t have a callback, it just restart the board.

What is the best way to have this behaviour ? Is a watchdog a good idea ?

Thanks

rtel wrote on Thursday, May 17, 2018:

I’m currently working on a stm32f4 project and I have a question about
the best way to identify errors.

What are the errors you want to identify? You can use asserts() to
catch a lot of programmatic errors.

I have a iwatchdog (from HAL library) which guaranted that my
application is still running (refresh during idle time).

That may only guarantee that the idle task is still running, nothing
else. All your application tasks might be deadlocked, or otherwise just
dead.

My goal is to make my application crash

I’m really good at that ;o)

and be able after the restart to
know which file/line was the error.

How does this crash manifest itself? In a lot of cases an exception
will occur, which can be handled to print out or otherwise store the
line that caused the exception.
https://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html

basile wrote on Friday, May 18, 2018:

What are the errors you want to identify? You can use asserts() to
catch a lot of programmatic errors.

Mainly spinlock/deadlock situtation when a task take the freeRTOS scheduler.
To test it for example i just add wile(1) inside
My idea is to record the last task each time

That may only guarantee that the idle task is still running, nothing
else. All your application tasks might be deadlocked, or otherwise just
dead.

The fact that the idle task is still running mean that the scheduler can still manage switch so my application is not blocked.

My goal is to make my application crash
I’m really good at that ;o)

Even more on Friday :wink:

How does this crash manifest itself? In a lot of cases an exception
will occur, which can be handled to print out or otherwise store the
line that caused the exception.

We can’t refresh the watchdog since Idle task can’t be reach so after the timeout the board restart.
My will was to add a callbach on this iwatchdog to store the error datas (file, line and task on which the error occur)