From 2e02dafdfda257535a56f25571ad3fc10fc727b5 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 2 Sep 2026 16:04:04 -0500 Subject: [PATCH] nordic watchdog fix boot.py hardcrash, and raise on setting mode to None after RESET --- ports/nordic/common-hal/watchdog/WatchDogTimer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/nordic/common-hal/watchdog/WatchDogTimer.c b/ports/nordic/common-hal/watchdog/WatchDogTimer.c index b20aa0c0629..48db5014800 100644 --- a/ports/nordic/common-hal/watchdog/WatchDogTimer.c +++ b/ports/nordic/common-hal/watchdog/WatchDogTimer.c @@ -75,9 +75,6 @@ void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { if (self->mode == WATCHDOGMODE_RESET) { - if (gc_alloc_possible()) { - mp_raise_RuntimeError(MP_ERROR_TEXT("WatchDogTimer cannot be deinitialized once mode is set to RESET")); - } // Don't change anything because RESET cannot be undone. return; } @@ -164,6 +161,10 @@ void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_w } nrfx_wdt_enable(&wdt); nrfx_wdt_feed(&wdt); + } else if (current_mode == WATCHDOGMODE_RESET) { + // raise exception on attempt to set mode back from RESET to None + mp_raise_RuntimeError(MP_ERROR_TEXT("WatchDogTimer cannot be deinitialized once mode is set to RESET")); + } // If we just switched away from RAISE, disable the timmer.