Registered User No edit summary |
Registered User m (Text replacement - "{{Board$}} " to "{{Board$}}") |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{ApplicableFor | |||
|MPUs list=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | |||
|MPUs checklist=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | |||
}} | |||
<noinclude></noinclude> | |||
This article provides information on the Linux<sup>®</sup> WDT (Watchdog Timer) framework.<br/> | This article provides information on the Linux<sup>®</sup> WDT (Watchdog Timer) framework.<br/> | ||
It explains how to activate the WDT interface and, based on examples, how to use it.<br /> | It explains how to activate the WDT interface and, based on examples, how to use it.<br /> | ||
Line 13: | Line 18: | ||
*'''Application''' (User Space): an application that configures and regularly pings the char device<ref name="char device">[https://bootlin.com/doc/training/linux-kernel/linux-kernel-slides.pdf character device interface], ''Linux Kernel and Driver Development'' training document, see '''Character drivers''' and '''Kernel frameworks for device drivers''' chapter</ref>. | *'''Application''' (User Space): an application that configures and regularly pings the char device<ref name="char device">[https://bootlin.com/doc/training/linux-kernel/linux-kernel-slides.pdf character device interface], ''Linux Kernel and Driver Development'' training document, see '''Character drivers''' and '''Kernel frameworks for device drivers''' chapter</ref>. | ||
*'''User Space interface''': composed of a standard char device<ref name="char device" />. | *'''User Space interface''': composed of a standard char device<ref name="char device" />. | ||
*'''Watchdog framework''' (Kernel Space): this component provides a watchdog common interface <ref name="wdt user api">{{CodeSource | Linux kernel | Documentation/watchdog/watchdog-api. | *'''Watchdog framework''' (Kernel Space): this component provides a watchdog common interface <ref name="wdt user api">{{CodeSource | Linux kernel | Documentation/watchdog/watchdog-api.rst | kernel.org watchdog user api}}</ref>(through a char device) to configure and control a watchdog hardware block. | ||
*'''User driver''' (Kernel Space): Linux kernel drivers that handle internal peripherals or external devices under watchdog core<ref name="wdt kernel api">{{CodeSource | Linux kernel | Documentation/watchdog/watchdog- | *'''User driver''' (Kernel Space): Linux kernel drivers that handle internal peripherals or external devices under watchdog core<ref name="wdt kernel api">{{CodeSource | Linux kernel | Documentation/watchdog/watchdog-kernel-api.rst | kernel.org watchdog kernel api}}</ref>. | ||
*'''STM32 peripherals''' (Hardware): Hardware block for watchdog handling ([[IWDG internal peripheral|IWDT]]). | *'''STM32 peripherals''' (Hardware): Hardware block for watchdog handling ([[IWDG internal peripheral|IWDT]]). | ||
Line 33: | Line 38: | ||
[*] Disable watchdog shutdown on close | [*] Disable watchdog shutdown on close | ||
[*] Update boot-enabled watchdog until userspace takes over | [*] Update boot-enabled watchdog until userspace takes over | ||
<*> ARM Secure Monitor Call based watchdog support | |||
<*> STM32 Independent WatchDoG (IWDG) support | <*> STM32 Independent WatchDoG (IWDG) support | ||
</pre> | </pre> | ||
Line 51: | Line 57: | ||
===How to trace=== | ===How to trace=== | ||
For details on dynamic trace usage, refer to How to use the kernel dynamic debug. | For details on dynamic trace usage, refer to How to use the kernel dynamic debug. | ||
{{Board$}} echo "file drivers/watchdog/* +p" > /sys/kernel/debug/dynamic_debug/control | {{Board$}}echo "file drivers/watchdog/* +p" > /sys/kernel/debug/dynamic_debug/control | ||
==Source code location== | ==Source code location== | ||
*{{CodeSource | Linux kernel | drivers/watchdog/watchdog_core.c | WatchdogAPI core}} | *{{CodeSource | Linux kernel | drivers/watchdog/watchdog_core.c | WatchdogAPI core}} | ||
*{{CodeSource | Linux kernel | include/uapi/linux/watchdog.h | WatchdogAPI interface}} | *{{CodeSource | Linux kernel | include/uapi/linux/watchdog.h | WatchdogAPI interface}} | ||
*{{CodeSource | Linux kernel | drivers/watchdog/stm32_iwdg.c | stm32 iwdg | *{{CodeSource | Linux kernel | drivers/watchdog/arm_smc_wdt.c | ARM Secure Monitor Call based watchdog driver}} | ||
*{{CodeSource | Linux kernel | drivers/watchdog/stm32_iwdg.c | stm32 iwdg driver}} | |||
==References== | ==References== |
Latest revision as of 16:45, 8 October 2024
This article provides information on the Linux® WDT (Watchdog Timer) framework.
It explains how to activate the WDT interface and, based on examples, how to use it.
1. Framework purpose[edit | edit source]
A Watchdog Timer is a hardware circuit that can reset the computer system in case of a software fault (for example, when the software is blocked in an infinity loop and cannot reload the timer before an elapsed time).
2. System overview[edit | edit source]

2.1. Component description[edit | edit source]
From client application to hardware, the components are the following:
- Application (User Space): an application that configures and regularly pings the char device[1].
- User Space interface: composed of a standard char device[1].
- Watchdog framework (Kernel Space): this component provides a watchdog common interface [2](through a char device) to configure and control a watchdog hardware block.
- User driver (Kernel Space): Linux kernel drivers that handle internal peripherals or external devices under watchdog core[3].
- STM32 peripherals (Hardware): Hardware block for watchdog handling (IWDT).
2.2. API description[edit | edit source]
A userspace daemon notifies the kernel watchdog driver that the userspace is still alive at regular intervals. This is done via the char device[1] special device file ((/dev/watchdog). When such a notification occurs, the driver tells the hardware watchdog that everything is in order, and that the watchdog must wait a little more to reset the system. If the userspace fails (because of a RAM error or a kernel bug), the notifications stop and the hardware watchdog resets the system after the timeout occurs, thus causing a reboot.
3. Configuration[edit | edit source]
3.1. Kernel configuration[edit | edit source]
By default, the Watchdog Timer (WDT[2]) framework is activated in STMicroelectronics deliveries. If a specific configuration is needed, this section indicates how the WDT framework can be activated/inactivated in the kernel.
The WDT framework can be activated in the kernel configuration via Linux® Menuconfig tool. Follow the steps below to configure the kernel via Menuconfig:
IWDG) support[*] Watchdog Timer Support ---> [*] Disable watchdog shutdown on close [*] Update boot-enabled watchdog until userspace takes over <*> ARM Secure Monitor Call based watchdog support <*> STM32 Independent WatchDoG (
3.2. Device tree configuration[edit | edit source]
DT configuration can be done thanks to STM32CubeMX.
Please refer to the IWDG device tree configuration.
4. How to use the Watchdog framework[edit | edit source]
The Watchdog framework can be used by the userspace application:
- The kernel provides a simple code example[4]
- Busybox provides a watchdog daemon[5]
- Systemd provides a watchdog support[6]
5. How to trace and debug the framework[edit | edit source]
5.1. How to trace[edit | edit source]
For details on dynamic trace usage, refer to How to use the kernel dynamic debug.
echo "file drivers/watchdog/* +p" > /sys/kernel/debug/dynamic_debug/control
6. Source code location[edit | edit source]
- WatchdogAPI core
- WatchdogAPI interface
- ARM Secure Monitor Call based watchdog driver
- stm32 iwdg driver
7. References[edit | edit source]
- ↑ Jump up to: 1.0 1.1 1.2 character device interface, Linux Kernel and Driver Development training document, see Character drivers and Kernel frameworks for device drivers chapter
- ↑ Jump up to: 2.0 2.1 kernel.org watchdog user api
- ↑ kernel.org watchdog kernel api
- ↑ user example
- ↑ busybox commands
- ↑ systemd watchdog configuration