Watchdog module
The watchdog module is responsible for controlling the watchdog timer.
The watchdog timer is used to prevent hangs caused by software or hardware faults. When the system hangs, it is automatically restarted by the watchdog timer.
Module events
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
---|---|---|---|---|
|
|
|||
|
Note
See the Overview: Firmware architecture for more information about the event-based communication in the nRF Desktop application and about how to read this table.
Configuration
The module uses Zephyr’s Watchdog driver.
For this reason, it automatically selects the CONFIG_WATCHDOG
option.
The module is enabled by the CONFIG_DESKTOP_WATCHDOG_ENABLE option.
You must define CONFIG_DESKTOP_WATCHDOG_TIMEOUT option. After this amount of time (in ms), the device will be restarted if the watchdog timer was not reset.
Note
The module is by default used only in the release configurations that do not enable logs. When the CONFIG_DESKTOP_LOG Kconfig option is enabled, enabling watchdog timer can cause losing logs, for example, when the logger is in the panic mode.
Implementation details
The watchdog timer is started when the Basic module (main) is ready (which is reported using module_state_event
).
The module periodically resets the watchdog timer using k_work_delayable
.
The work resubmits itself with delay equal to CONFIG_DESKTOP_WATCHDOG_TIMEOUT / 3
.
In case of the system hang, the work will not be processed, the watchdog timer will not be reset on time, and the system will be restarted.