Open main menu

DAVE Developer's Wiki β

Changes

BELK-AN-011: Using the external watchdog timer

2,855 bytes added, 16:08, 18 July 2023
Created page with "{{InfoBoxTop}} {{Applies To Bora}} {{Applies To BoraX}} {{AppliesToBORA_AN}} {{AppliesToBORA Lite AN}} {{InfoBoxBottom}} {{WarningMessage|text=This application note was valid..."
{{InfoBoxTop}}
{{Applies To Bora}}
{{Applies To BoraX}}
{{AppliesToBORA_AN}}
{{AppliesToBORA Lite AN}}
{{InfoBoxBottom}}

{{WarningMessage|text=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.}}

== History ==
{| class="wikitable" border="1"
!ID#
!Date
!BELK version
!Notes
|-
|{{oldid|17999|17999}}
|Jul 2023
|[[BELK/BXELK_software_components#Release_notes|BELK 4.1.4]]
|First release
|}

== Introduction ==

[[BORA SOM| BORA]], [[BORA_Xpress_SOM|BORA Xpress]] and [[BORA_Lite_SOM|BORA Lite]] SOMs have an onboard watchdog timer ([https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6369-MAX6374.pdf 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 ===

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

* watchdog in [[BORA_SOM/BORA_Hardware/Peripherals/Watchdog | BORA]]
* watchdog in [[BORA_Xpress_SOM/BORA_Xpress_Hardware/Peripherals/Watchdog | BORA Xpress]]
* watchdog in [[BORA_Lite_SOM/BORA_Lite_Hardware/Peripherals/Watchdog | BORA Lite]]

== Linux driver ==

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

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

&watchdog {
status = "okay";
};
</pre>

=== Using the WDT via sysfs ===
It is possible to manage the WDI toggle at userspace simply by activating it via <code>sysfs</code> interface, for example:

<pre class="workstation-terminal">
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
</pre>

In this example, its is worth to remember that the MIO pins (BANK 500) are available starting from <code>gpio906</code> (corresponding to MIO00), so:
* PS_MIO15_500 → MIO 15 → 906+15 → 921

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

<pre class="workstation-terminal">
root@bora:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 906-1023, parent: platform/e000a000.gpio, zynq_gpio:
gpio-921 ( |watchdog ) out hi
root@bora:~#
</pre>
8,286
edits