Watchdog
A hardware watchdog resets the MCU when the firmware stops feeding it in time, recovering the keyboard from a hang without a physical unplug. RMK feeds the watchdog from a dedicated Embassy task.
Because all Runnable tasks are joined cooperatively, a tight-loop stall in any
sibling task (for instance: matrix scan, USB, BLE) blocks the watchdog task from
feeding, so the timeout expires and the hardware resets the MCU.
The watchdog feature is enabled by default, no user configuration is
required.
Supported chips: RP2040, nRF52 (BLE and dfu_nrf builds; the nRF54L series
is not yet covered), ESP32 (see
rmk/src/watchdog).
STM32 has no automatic watchdog codegen.
How it works
WatchdogFeedis a small trait each chip implements to feed its hardware timer.WatchdogRunner<W>wraps aWatchdogFeedand callsfeed()on a fixed interval.rmk-macrogenerates chip-specific init code and joins awatchdog_runner.run()task alongside the keyboard and matrix tasks.Rp2040WatchdogandNrf52Watchdogprovide adefault_runner(); for ESP32 the generated code configures the MWDT and wraps it in aWatchdogRunnerdirectly. The timeout/feed interval pairs:
Adding support for other chips
WatchdogFeed and WatchdogRunner are public, so downstream consumers
using the Rust API aren't limited to the chips rmk-macro generates code
for. Implement WatchdogFeed for your chip's watchdog peripheral, build a
WatchdogRunner around it, and pass it to run_all! alongside your other
tasks.