Skip to content

Commit b14a3c5

Browse files
committed
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
1 parent ec09ead commit b14a3c5

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

app/src/processing/app/debug/AvrdudeUploader.java

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ protected boolean burnBootloader(Collection params)
132132
Map<String, String> boardPreferences = Base.getBoardPreferences();
133133
List fuses = new ArrayList();
134134
fuses.add("-e"); // erase the chip
135-
fuses.add("-Ulock:w:" + boardPreferences.get("bootloader.unlock_bits") + ":m");
135+
if (boardPreferences.get("bootloader.unlock_bits") != null)
136+
fuses.add("-Ulock:w:" + boardPreferences.get("bootloader.unlock_bits") + ":m");
136137
if (boardPreferences.get("bootloader.extended_fuses") != null)
137138
fuses.add("-Uefuse:w:" + boardPreferences.get("bootloader.extended_fuses") + ":m");
138139
fuses.add("-Uhfuse:w:" + boardPreferences.get("bootloader.high_fuses") + ":m");
@@ -146,26 +147,32 @@ protected boolean burnBootloader(Collection params)
146147
} catch (InterruptedException e) {}
147148

148149
Target t;
150+
List bootloader = new ArrayList();
149151
String bootloaderPath = boardPreferences.get("bootloader.path");
150152

151-
if (bootloaderPath.indexOf(':') == -1) {
152-
t = Base.getTarget(); // the current target (associated with the board)
153-
} else {
154-
String targetName = bootloaderPath.substring(0, bootloaderPath.indexOf(':'));
155-
t = Base.targetsTable.get(targetName);
156-
bootloaderPath = bootloaderPath.substring(bootloaderPath.indexOf(':') + 1);
153+
if (bootloaderPath != null) {
154+
if (bootloaderPath.indexOf(':') == -1) {
155+
t = Base.getTarget(); // the current target (associated with the board)
156+
} else {
157+
String targetName = bootloaderPath.substring(0, bootloaderPath.indexOf(':'));
158+
t = Base.targetsTable.get(targetName);
159+
bootloaderPath = bootloaderPath.substring(bootloaderPath.indexOf(':') + 1);
160+
}
161+
162+
File bootloadersFile = new File(t.getFolder(), "bootloaders");
163+
File bootloaderFile = new File(bootloadersFile, bootloaderPath);
164+
bootloaderPath = bootloaderFile.getAbsolutePath();
165+
166+
bootloader.add("-Uflash:w:" + bootloaderPath + File.separator +
167+
boardPreferences.get("bootloader.file") + ":i");
157168
}
158-
159-
File bootloadersFile = new File(t.getFolder(), "bootloaders");
160-
File bootloaderFile = new File(bootloadersFile, bootloaderPath);
161-
bootloaderPath = bootloaderFile.getAbsolutePath();
162-
163-
List bootloader = new ArrayList();
164-
bootloader.add("-Uflash:w:" + bootloaderPath + File.separator +
165-
boardPreferences.get("bootloader.file") + ":i");
166-
bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m");
169+
if (boardPreferences.get("bootloader.lock_bits") != null)
170+
bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m");
167171

168-
return avrdude(params, bootloader);
172+
if (bootloader.size() > 0)
173+
return avrdude(params, bootloader);
174+
175+
return true;
169176
}
170177

171178
public boolean avrdude(Collection p1, Collection p2) throws RunnerException {

0 commit comments

Comments
 (0)