Skip to content

Commit 4f89f35

Browse files
pennamaentinger
authored andcommitted
Trigger a watchdog reset to start SFU
1 parent 0e386a1 commit 4f89f35

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/utility/ota/OTA-nano-rp2040.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ int rp2040_connect_onOTARequest(char const * ota_url)
237237
/* Perform the reset to reboot to SFU. */
238238
DEBUG_INFO("%s: %d bytes received", __FUNCTION__, ftell(file));
239239
fclose(file);
240-
NVIC_SystemReset();
240+
//NVIC_SystemReset();
241+
mbed_watchdog_trigger_reset();
241242

242243
return static_cast<int>(OTAError::None);
243244
}

src/utility/watchdog/Watchdog.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,25 @@ void mbed_watchdog_reset()
110110
hal_watchdog_kick();
111111
}
112112
}
113+
114+
void mbed_watchdog_trigger_reset()
115+
{
116+
watchdog_config_t cfg;
117+
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
118+
cfg.timeout_ms = 1;
119+
#elif defined(ARDUINO_NANO_RP2040_CONNECT)
120+
cfg.timeout_ms = 1;
121+
#else
122+
# error "You need to define the maximum possible timeout for this architecture."
123+
#endif
124+
125+
if (hal_watchdog_init(&cfg) == WATCHDOG_STATUS_OK) {
126+
is_watchdog_enabled = true;
127+
}
128+
else {
129+
DEBUG_WARNING("%s: watchdog could not be reconfigured", __FUNCTION__);
130+
}
131+
132+
while(1){}
133+
}
113134
#endif /* ARDUINO_ARCH_MBED */

src/utility/watchdog/Watchdog.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void samd_watchdog_reset();
3030
#ifdef ARDUINO_ARCH_MBED
3131
void mbed_watchdog_enable();
3232
void mbed_watchdog_reset();
33+
void mbed_watchdog_trigger_reset();
3334
#endif /* ARDUINO_ARCH_MBED */
3435

3536
#endif /* ARDUINO_AIOTC_UTILITY_WATCHDOG_H_ */

0 commit comments

Comments
 (0)