Window Watchdog
Important
The Peripheral will only work for AM62L devices (am62l_evm).
Overview
The AM62L watchdog is the Real Time Interrupt (RTI) module of the K3 family
(ti,j7-rti-wdt).
It is a digital windowed watchdog and is exposed through Zephyr’s standard
watchdog API (<zephyr/drivers/watchdog.h>) by the CONFIG_WDT_TI_RTI
driver.
The AM62L devicetree describes two instances, main_rti0 and main_rti1,
both clocked at 25 MHz. am62l_evm enables main_rti0 and points the
watchdog0 alias at it.
Features Supported
Standard API:
wdt_install_timeout(),wdt_setup(),wdt_feed()andwdt_disable()Reset mode: a timeout resets the SoC (
WDT_FLAG_RESET_SOC)Windowed operation:
window.mincan be non-zero, and feeding before the window opens is a violation just like a timeout (see Timeout and Window)Pausing the watchdog while the CPU is halted by a debugger (
WDT_OPT_PAUSE_HALTED_BY_DBG)Disabling the watchdog at runtime with
wdt_disable()
Features NOT Supported
NMI mode and the pre-reset callback. The driver only supports NMI when the node has an
interruptsproperty, which the AM62L RTI nodes do not. Installing a timeout withoutWDT_FLAG_RESET_SOCreturns-ENOTSUP, and acallbackis stored but never called.More than one timeout channel. Only channel 0 exists, and a second
wdt_install_timeout()call replaces the first one.
Usage
Enabling the Driver
am62l_evm already enables main_rti0, and CONFIG_WDT_TI_RTI is
selected automatically once an enabled ti,j7-rti-wdt node is present. For
another board or for the second instance, enable the node and make it the
watchdog0 alias in the board devicetree (or an application overlay), and
turn the watchdog subsystem on in prj.conf.
/ {
aliases {
watchdog0 = &main_rti1;
};
};
&main_rti1 {
status = "okay";
};
CONFIG_WATCHDOG=y
Devicetree Bindings
The node properties are described in ti,j7-rti-wdt devicetree binding.
Timeout and Window
The timeout is the window.max field of wdt_timeout_cfg, in
milliseconds. The driver converts it to the RTI preload value, which limits the
longest timeout at the 25 MHz clock to about 1342 ms; a larger value makes
wdt_install_timeout() return -EINVAL.
The window is fixed to a fraction of the timeout, so window.min cannot be
chosen freely. Feeding is only accepted during the last part of the timeout:
Open window (share of |
|
|---|---|
100% |
|
50% |
|
25% |
|
12.5% |
|
6.25% |
|
3.125% |
|
window.min must match one of these values exactly, otherwise
wdt_install_timeout() returns -EINVAL. window.min = 0, as used
by the upstream sample, gives the plain (non-windowed) behavior.
Using the Watchdog
#include <zephyr/device.h>
#include <zephyr/drivers/watchdog.h>
static const struct device *const wdt = DEVICE_DT_GET(DT_ALIAS(watchdog0));
int main(void)
{
struct wdt_timeout_cfg cfg = {
.window.min = 0,
.window.max = 1000,
.flags = WDT_FLAG_RESET_SOC,
};
int channel;
if (!device_is_ready(wdt)) {
return -ENODEV;
}
channel = wdt_install_timeout(wdt, &cfg);
if (channel < 0) {
return channel;
}
wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG);
while (1) {
/* do work, then feed before 1000 ms elapse */
wdt_feed(wdt, channel);
k_msleep(500);
}
}
Samples and Tests
Samples
-
Standard Zephyr watchdog sample; it builds for
am62l_evmthrough thewatchdog0alias.Feeds the watchdog a few times, then stops feeding and waits for the reset.
Tests
drivers.watchdog(tests/drivers/watchdog/wdt_basic_api) - Validates the standard Zephyr watchdog API (timeout installation, setup, feed, and reset on expiry).