From 15a964bb902d274cde3c397188f6d7c8f72521eb Mon Sep 17 00:00:00 2001 From: Kaspar Emanuel Date: Sun, 12 Mar 2017 17:46:00 +0000 Subject: [PATCH] Add infinite loop after wdt_enable call Currently when using Leonardo and derivatives reseting the watchdog in the main sketch code will interfere with the bootloader reset. This solution was proposed [by pjanco in the arduino.cc](http://forum.arduino.cc/index.php?topic=401628.msg2782592#msg2782592) forums. --- hardware/arduino/avr/cores/arduino/CDC.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hardware/arduino/avr/cores/arduino/CDC.cpp b/hardware/arduino/avr/cores/arduino/CDC.cpp index 0a743e1ea95..b460edf8b04 100644 --- a/hardware/arduino/avr/cores/arduino/CDC.cpp +++ b/hardware/arduino/avr/cores/arduino/CDC.cpp @@ -128,6 +128,8 @@ bool CDC_Setup(USBSetup& setup) // Store boot key *(uint16_t *)magic_key_pos = MAGIC_KEY; wdt_enable(WDTO_120MS); + // Go into infinite loop to avoid any watchdog resets or disable calls + while(1); } else {