Skip to content

Fix hardcrash from activating watchdog in boot.py on nordic - #11295

Merged
dhalbert merged 4 commits into
adafruit:mainfrom
FoamyGuy:nordic_watchdoog_bootpy_fix
Sep 4, 2026
Merged

Fix hardcrash from activating watchdog in boot.py on nordic#11295
dhalbert merged 4 commits into
adafruit:mainfrom
FoamyGuy:nordic_watchdoog_bootpy_fix

Conversation

@FoamyGuy

@FoamyGuy FoamyGuy commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

On nordic port it is not possible to stop the watchdog peripheral after it has been activated in RESET mode.

The existing implementation has two issues:

  1. It is trying to to handle raising an exception to the user from deinit(), but nothing in the python API was ever calling deinit(). Setting mode = None was seeming to succeed, it doesn't raise, and checking mode after setting to None does indeed return it as None but the watchdog is still activated and the bite will still reset.

  2. The way that the exception handling that is in deinit() works causes the path that calls it when the watchdog is activated from boot.py to hard crash with this error after boot.py runs:

You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
NLR jump failed. Likely memory corruption.
Please file an issue with your program at github.com/adafruit/circuitpython/issues.
Press reset to exit safe mode.

At this point the watchdog is still activated and the impending bite will reset the device again into safemode with reason WATCHDOG which will then prevent boot.py from running stopping the execution.

Fixed by removing the handling from deinit() and instead do it if/when the user attempts to set mode = None. With this change the user now gets a proper exception raised when they attempt to deactivate the watchdog from RESET mode, and the deinit() that happens after boot.py no longer causes the hard crash.

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One readability request.

Comment thread ports/nordic/common-hal/watchdog/WatchDogTimer.c Outdated

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dhalbert
dhalbert merged commit dece095 into adafruit:main Sep 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants