mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
fixed starting Leonardo bootloader from sketch
AvrdudeUploader class opens and closes Leonardo port at the magic baudrate before starting avrdude; reduced reset timeout from 250 ms to 15 ms
This commit is contained in:
parent
086ed6382c
commit
1e0700b536
@ -75,6 +75,21 @@ public class AvrdudeUploader extends Uploader {
|
||||
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
||||
if (protocol.equals("stk500"))
|
||||
protocol = "stk500v1";
|
||||
|
||||
// need to do a little dance for Leonardo and derivatives:
|
||||
// open then close the port at the magic baudrate (usually 1200 bps) first to signal to the
|
||||
// sketch that it should reset into bootloader. after doing this wait a moment for the
|
||||
// bootloader to enumerate
|
||||
if (boardPreferences.get("bootloader.path").equals("caterina_LUFA")) {
|
||||
try {
|
||||
Serial serial = new Serial(Integer.parseInt(boardPreferences.get("upload.speed")));
|
||||
serial.dispose();
|
||||
serial = null;
|
||||
Thread.sleep(2000);
|
||||
} catch (SerialException ex) {
|
||||
} catch (InterruptedException ex) { }
|
||||
}
|
||||
|
||||
commandDownloader.add("-c" + protocol);
|
||||
commandDownloader.add(
|
||||
"-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
|
||||
|
@ -29,7 +29,7 @@ void Reboot()
|
||||
cli();
|
||||
|
||||
// Reset the microcontroller to run the bootloader
|
||||
wdt_enable(WDTO_250MS);
|
||||
wdt_enable(WDTO_15MS);
|
||||
for (;;);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user