Description
Is your enhancement proposal related to a problem? Please describe.
The current description for Kconfig symbol CONFIG_WDT_DISABLE_AT_BOOT
is:
zephyr/drivers/watchdog/Kconfig
Lines 17 to 21 in 9b2fdac
Expected behavior when CONFIG_WDT_DISABLE_AT_BOOT=y
can be easily understood: WDT drivers must disable the timer.
However, the expected behavior when CONFIG_WDT_DISABLE_AT_BOOT=n
is not specified and could be either of:
- Do not disable the WDT during boot [if it is enabled by default]
- i.e., do nothing
- Enable the WDT during boot
The currently implemented behavior varies from driver to driver.
Describe the solution you'd like
The expected driver behavior when CONFIG_WDT_DISABLE_AT_BOOT=n
should be agreed upon and documented.
Non-conforming drivers should be updated to implemented the agreed upon and documented behavior.
Describe alternatives you've considered
-
Keep expected behavior when
CONFIG_WDT_DISABLE_AT_BOOT=n
undocumented. -
Replace
WDT_DISABLE_AT_BOOT
with more generic and explicitchoice WDT_BOOT_BEHAVIOR
such as:
WDT_HARDWARE_DEFAULT
- Driver should configure the WDT (e.g., reload counter, prescaler, etc)
- Driver must not disable or enable the WDT
- After boot, the WDT status will depend on default hardware behavior
- If WDT is enabled by default on SoC, it will be enabled
- If WDT is disabled by default on SoC, it will be disabled
WDT_DISABLE_AT_BOOT
- Driver should not configure the WDT, and must explicitly disable it
- This option can be gated behind
HAS_WDT_DISABLE_AT_BOOT
WDT_ENABLE_AT_BOOT
- Driver should configure and must explicitly enable (if applicable) the WDT
Unanswered question: where should the default configuration come from? (STM32 has platform-specific Kconfig for this)
Additional context
The samples/drivers/watchdog
and tests/drivers/watchdog/wdt_basic_api
applications are setting CONFIG_WDT_DISABLE_AT_BOOT=n
.
Since commit 2509de7, these tests will "fail" on STM32 platforms, because the STM32 IWDG timer driver interprets CONFIG_WDT_DISABLE_AT_BOOT=n
as enable the WDT during boot.
Since the timer can be configured only once, wdt_install_timeout
returns -ENOMEM
and a test failure is reported... despite the board getting reset by WDT after a little while. Replacing with CONFIG_WDT_DISABLE_AT_BOOT=y
allows the tests to succeed.
In these two applications, CONFIG_WDT_DISABLE_AT_BOOT=n
seems to have been set under the interpretation "do not disable the WDT if enabled by default", which breaks when the underlying implementation understands it as "enable and configure the WDT".