Difference between revisions of "BELK-AN-011: Using the external watchdog timer"

From DAVE Developer's Wiki
Jump to: navigation, search
(Created page with "{{InfoBoxTop}} {{Applies To Bora}} {{Applies To BoraX}} {{AppliesToBORA_AN}} {{AppliesToBORA Lite AN}} {{InfoBoxBottom}} {{WarningMessage|text=This application note was valid...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{InfoBoxTop}}
 
{{InfoBoxTop}}
{{Applies To Bora}}
 
{{Applies To BoraX}}
 
 
{{AppliesToBORA_AN}}
 
{{AppliesToBORA_AN}}
 +
{{AppliesToBORA_Xpress_AN}}
 
{{AppliesToBORA Lite AN}}
 
{{AppliesToBORA Lite AN}}
 
{{InfoBoxBottom}}
 
{{InfoBoxBottom}}
Line 15: Line 14:
 
!Notes
 
!Notes
 
|-
 
|-
|{{oldid|17999|17999}}
+
|{{oldid|18006|18006}}
 
|Jul 2023
 
|Jul 2023
 
|[[BELK/BXELK_software_components#Release_notes|BELK 4.1.4]]
 
|[[BELK/BXELK_software_components#Release_notes|BELK 4.1.4]]
Line 37: Line 36:
 
== Linux driver ==
 
== 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:
+
It is possible to enable the gpio driver for using the [https://elixir.bootlin.com/linux/v4.9/source/Documentation/devicetree/bindings/watchdog/gpio-wdt.txt gpio-watchdog] driver: 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">
 
<pre class="workstation-terminal">
Line 55: Line 54:
  
 
=== Using the WDT via sysfs ===
 
=== 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:
+
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 <code>sysfs</code> interface:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 65: Line 64:
 
</pre>
 
</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:
+
In this example, it is worth remembering 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
 
* PS_MIO15_500 → MIO 15 → 906+15 → 921
  
=== Kernel debug ===
+
== Kernel debug ==
 
It is possible to see the kernel recognizes the GPIO pin status via:
 
It is possible to see the kernel recognizes the GPIO pin status via:
  

Latest revision as of 16:15, 18 July 2023

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:~#