mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-19 09:42:11 +03: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:
@ -75,6 +75,21 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
||||||
if (protocol.equals("stk500"))
|
if (protocol.equals("stk500"))
|
||||||
protocol = "stk500v1";
|
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("-c" + protocol);
|
||||||
commandDownloader.add(
|
commandDownloader.add(
|
||||||
"-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
|
"-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
|
||||||
|
@ -29,7 +29,7 @@ void Reboot()
|
|||||||
cli();
|
cli();
|
||||||
|
|
||||||
// Reset the microcontroller to run the bootloader
|
// Reset the microcontroller to run the bootloader
|
||||||
wdt_enable(WDTO_250MS);
|
wdt_enable(WDTO_15MS);
|
||||||
for (;;);
|
for (;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user