BELK-AN-011: Using the external watchdog timer

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box


Warning-icon.png This application note was validated against specific versions of the kit only. It may not work with other versions. Supported versions are listed in the History section. Warning-icon.png

History[edit | edit source]

ID# Date BELK version Notes

18006

Jul 2023 BELK 4.1.4 First release

Introduction[edit | edit source]

BORA, BORA Xpress and BORA Lite SOMs have an onboard watchdog timer (MAX6373 device) usable as a system monitor to detect and - in case of stall condition - reset the main SoC.

This application note shows, for instance, how is configured by default the watchdog peripheral (aka WDT) and how to configure a generic Linux driver for managing the WDT.

Configuration[edit | edit source]

The default configuration is clearly explained in the SOM Hardware Manual and in the following wiki pages:

Linux driver[edit | edit source]

It is possible to enable the gpio driver for using the gpio-watchdog driver: you have to enable the kernel driver CONFIG_GPIO_WATCHDOG=y and then configure the MIO 15 pin in the device tree, for example:

watchdog: watchdog {
       /* MAX6373 */
       compatible = "linux,wdt-gpio";
       gpios = <&gpio0 15 0>;
       hw_algo = "toggle";
       hw_margin_ms = <10000>;
       always-running;
};

&watchdog {
    status = "okay";
};

Using the WDT via sysfs[edit | edit source]

If it is required to manage directly the WDI pin at userspace, it is possible - for example - to manage the simply by activating it via sysfs interface:

root@bora:~# echo 921 > /sys/class/gpio/export
root@bora:~# echo out > /sys/class/gpio/gpio921/direction
root@bora:~# echo 1 > /sys/class/gpio/gpio921/value
…
root@bora:~# echo 0 > /sys/class/gpio/gpio921/value

In this example, it is worth remembering that the MIO pins (BANK 500) are available starting from gpio906 (corresponding to MIO00), so:

  • PS_MIO15_500 → MIO 15 → 906+15 → 921

Kernel debug[edit | edit source]

It is possible to see the kernel recognizes the GPIO pin status via:

root@bora:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 906-1023, parent: platform/e000a000.gpio, zynq_gpio:
gpio-921 (                    |watchdog            ) out hi
root@bora:~#