zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.04k stars 6.18k forks source link

drivers: watchdog: NRFX watchdog cannot be started on boot #73356

Open AustinLiuMesoMat opened 1 month ago

AustinLiuMesoMat commented 1 month ago

Is your enhancement proposal related to a problem? Please describe.

The watchdog driver for the NRFX drivers (source code) cannot be started automatically on boot. This poses an issue where the watchdog can only be started later in the application code and does not offer protection if anything in sys init gets stuck. Additionally, this watchdog can't be used in something like MCUboot if without modifying the its source code.

Describe the solution you'd like

A way to enable and install the watchdog timeout using only Kconfig options.

The Kconfig options should allow the equivalent of calling wdt_install_timeout and wdt_setup. It seems reasonable to perform this initialization within the devicetree init function of the watchdog itself.

Describe alternatives you've considered

There have been several related issues raised: https://github.com/zephyrproject-rtos/zephyr/issues/57188 https://github.com/mcu-tools/mcuboot/issues/1688

Using CONFIG_WDT_DISABLE_AT_BOOT=n has been suggested, however it doesn't reflect the intent well here as the watchdog is not enabled by default at boot.

It's also possible to register a callback to sys init in either the EARLY or one of the PRE_KERNEL stages. However, an early callback means the watchdog devicetree is not initialized, while the priorities must be set correctly for a PRE_KERNEL level callback. Most importantly, this approach does not work for MCUboot.

Additional context The Nordic SoCs (NRF52) do not have a non-volatile configuration register that starts the watchdog automatically in hardware, so it must be enabled through boot.

github-actions[bot] commented 1 month ago

Hi @AustinLiuMesoMat! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙