Skip to main content
Mario Luzeiro
Associate III
April 22, 2022
Solved

How to catch and handle M4 watchdog crashes on Linux side?

  • April 22, 2022
  • 1 reply
  • 1838 views

I managed to make the M4 WWDOG to work.

I got on Linux cmd line:

remoteproc remoteproc0: crash detected in m4: type watchdog

How can I catch and handle this events programmatically on a shell script, C or Python ?

This topic has been closed for replies.
Best answer by ArnaudP

Hello Mario,

Different strategies are possible.

1) The polling method

  • disable the auto recovery
echo disabled >/sys/class/remoteproc/remoteproc0/recovery
  • poll the remoteproc state, looking for the "crashed" stated
cat /sys/class/remoteproc/remoteproc0/state
  • recover the M4
echo recover >/sys/class/remoteproc/remoteproc0/recovery 

2) Use coredump trigger

An event is sent to the userspace application on crash to save the coredump, this can also be used to detect the crash

Details and link to udev script are available on this page:

https://wiki.st.com/stm32mpu/wiki/How_to_retrieve_Cortex-M4_logs_after_crash

3) Create your own udev trigger based on virtio device add/remove ( work only if you use RPMsg)

this page provide details on how to implement it:

https://www.tecmint.com/udev-for-device-detection-management-in-linux/

The rules to implement is:

SUBSYSTEM=="virtio", ACTION=="add", RUN+="/bin/device_added.sh"
SUBSYSTEM=="virtio", ACTION=="remove", RUN+="/bin/device_removed.sh"

4) tips to ease your test

you can simulate a watchdog crash using following command:

echo 1 >/sys/kernel/debug/remoteproc/remoteproc0/crash

Regards,

Arnaud

1 reply

ArnaudP
ArnaudPBest answer
ST Employee
April 29, 2022

Hello Mario,

Different strategies are possible.

1) The polling method

  • disable the auto recovery
echo disabled >/sys/class/remoteproc/remoteproc0/recovery
  • poll the remoteproc state, looking for the "crashed" stated
cat /sys/class/remoteproc/remoteproc0/state
  • recover the M4
echo recover >/sys/class/remoteproc/remoteproc0/recovery 

2) Use coredump trigger

An event is sent to the userspace application on crash to save the coredump, this can also be used to detect the crash

Details and link to udev script are available on this page:

https://wiki.st.com/stm32mpu/wiki/How_to_retrieve_Cortex-M4_logs_after_crash

3) Create your own udev trigger based on virtio device add/remove ( work only if you use RPMsg)

this page provide details on how to implement it:

https://www.tecmint.com/udev-for-device-detection-management-in-linux/

The rules to implement is:

SUBSYSTEM=="virtio", ACTION=="add", RUN+="/bin/device_added.sh"
SUBSYSTEM=="virtio", ACTION=="remove", RUN+="/bin/device_removed.sh"

4) tips to ease your test

you can simulate a watchdog crash using following command:

echo 1 >/sys/kernel/debug/remoteproc/remoteproc0/crash

Regards,

Arnaud