1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

Lock / unlock fuses and hex file now optional for burn bootloader command.

This allows the "burn bootloader" command to be used, for example, to set the fuses on a microcontroller without actually loading a bootloader onto it.

http://code.google.com/p/arduino/issues/detail?id=683
http://code.google.com/p/arduino/issues/detail?id=684
This commit is contained in:
David A. Mellis 2011-10-21 18:25:14 -04:00
parent ec09ead6ac
commit b14a3c501e

View File

@ -132,6 +132,7 @@ public class AvrdudeUploader extends Uploader {
Map<String, String> boardPreferences = Base.getBoardPreferences(); Map<String, String> boardPreferences = Base.getBoardPreferences();
List fuses = new ArrayList(); List fuses = new ArrayList();
fuses.add("-e"); // erase the chip fuses.add("-e"); // erase the chip
if (boardPreferences.get("bootloader.unlock_bits") != null)
fuses.add("-Ulock:w:" + boardPreferences.get("bootloader.unlock_bits") + ":m"); fuses.add("-Ulock:w:" + boardPreferences.get("bootloader.unlock_bits") + ":m");
if (boardPreferences.get("bootloader.extended_fuses") != null) if (boardPreferences.get("bootloader.extended_fuses") != null)
fuses.add("-Uefuse:w:" + boardPreferences.get("bootloader.extended_fuses") + ":m"); fuses.add("-Uefuse:w:" + boardPreferences.get("bootloader.extended_fuses") + ":m");
@ -146,8 +147,10 @@ public class AvrdudeUploader extends Uploader {
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
Target t; Target t;
List bootloader = new ArrayList();
String bootloaderPath = boardPreferences.get("bootloader.path"); String bootloaderPath = boardPreferences.get("bootloader.path");
if (bootloaderPath != null) {
if (bootloaderPath.indexOf(':') == -1) { if (bootloaderPath.indexOf(':') == -1) {
t = Base.getTarget(); // the current target (associated with the board) t = Base.getTarget(); // the current target (associated with the board)
} else { } else {
@ -160,12 +163,16 @@ public class AvrdudeUploader extends Uploader {
File bootloaderFile = new File(bootloadersFile, bootloaderPath); File bootloaderFile = new File(bootloadersFile, bootloaderPath);
bootloaderPath = bootloaderFile.getAbsolutePath(); bootloaderPath = bootloaderFile.getAbsolutePath();
List bootloader = new ArrayList();
bootloader.add("-Uflash:w:" + bootloaderPath + File.separator + bootloader.add("-Uflash:w:" + bootloaderPath + File.separator +
boardPreferences.get("bootloader.file") + ":i"); boardPreferences.get("bootloader.file") + ":i");
}
if (boardPreferences.get("bootloader.lock_bits") != null)
bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m"); bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m");
if (bootloader.size() > 0)
return avrdude(params, bootloader); return avrdude(params, bootloader);
return true;
} }
public boolean avrdude(Collection p1, Collection p2) throws RunnerException { public boolean avrdude(Collection p1, Collection p2) throws RunnerException {