Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify expected behavior when CONFIG_WDT_DISABLE_AT_BOOT=n #86223

Open
mathieuchopstm opened this issue Feb 24, 2025 · 0 comments
Open

Clarify expected behavior when CONFIG_WDT_DISABLE_AT_BOOT=n #86223

mathieuchopstm opened this issue Feb 24, 2025 · 0 comments
Assignees
Labels
area: Watchdog Watchdog Enhancement Changes/Updates/Additions to existing features

Comments

@mathieuchopstm
Copy link
Collaborator

Is your enhancement proposal related to a problem? Please describe.
The current description for Kconfig symbol CONFIG_WDT_DISABLE_AT_BOOT is:

config WDT_DISABLE_AT_BOOT
bool "Disable at boot"
depends on HAS_WDT_DISABLE_AT_BOOT
help
Disable watchdog at Zephyr system startup.

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

  1. Keep expected behavior when CONFIG_WDT_DISABLE_AT_BOOT=n undocumented.

  2. Replace WDT_DISABLE_AT_BOOT with more generic and explicit choice 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".

@mathieuchopstm mathieuchopstm added area: Watchdog Watchdog Enhancement Changes/Updates/Additions to existing features labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Watchdog Watchdog Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

3 participants