From e8c8945650e462a64a92a07905c2d3eea1fd7008 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 16 Dec 2022 12:25:40 +0100 Subject: [PATCH] Disable the watchdog early in the program --- Firmware/Marlin_main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a9331cef8..36ca6b364 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -685,6 +685,18 @@ void failstats_reset_print() eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); } +extern "C" { +void __attribute__ ((naked)) __attribute__ ((section (".init3"))) stopWatchdogOnInit(void) { + // Regardless if the watchdog support is enabled or not, disable the watchdog very early + // after the program starts since there's no danger in doing this. + // The reason for this is because old bootloaders might not handle the watchdog timer at all, + // leaving it enabled when jumping to the program. This could cause another watchdog reset + // during setup() if not handled properly. So to avoid any issue of this kind, stop the + // watchdog timer manually. + wdt_disable(); +} +} + void softReset() { cli();