From b14a3c501ebd62afff251fb69169df6a6bcf9758 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 21 Oct 2011 18:25:14 -0400 Subject: [PATCH] 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 --- .../processing/app/debug/AvrdudeUploader.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/src/processing/app/debug/AvrdudeUploader.java b/app/src/processing/app/debug/AvrdudeUploader.java index 2fec8f6f6..d5db258ad 100755 --- a/app/src/processing/app/debug/AvrdudeUploader.java +++ b/app/src/processing/app/debug/AvrdudeUploader.java @@ -132,7 +132,8 @@ public class AvrdudeUploader extends Uploader { Map boardPreferences = Base.getBoardPreferences(); List fuses = new ArrayList(); fuses.add("-e"); // erase the chip - fuses.add("-Ulock:w:" + boardPreferences.get("bootloader.unlock_bits") + ":m"); + if (boardPreferences.get("bootloader.unlock_bits") != null) + fuses.add("-Ulock:w:" + boardPreferences.get("bootloader.unlock_bits") + ":m"); if (boardPreferences.get("bootloader.extended_fuses") != null) fuses.add("-Uefuse:w:" + boardPreferences.get("bootloader.extended_fuses") + ":m"); fuses.add("-Uhfuse:w:" + boardPreferences.get("bootloader.high_fuses") + ":m"); @@ -146,26 +147,32 @@ public class AvrdudeUploader extends Uploader { } catch (InterruptedException e) {} Target t; + List bootloader = new ArrayList(); String bootloaderPath = boardPreferences.get("bootloader.path"); - if (bootloaderPath.indexOf(':') == -1) { - t = Base.getTarget(); // the current target (associated with the board) - } else { - String targetName = bootloaderPath.substring(0, bootloaderPath.indexOf(':')); - t = Base.targetsTable.get(targetName); - bootloaderPath = bootloaderPath.substring(bootloaderPath.indexOf(':') + 1); + if (bootloaderPath != null) { + if (bootloaderPath.indexOf(':') == -1) { + t = Base.getTarget(); // the current target (associated with the board) + } else { + String targetName = bootloaderPath.substring(0, bootloaderPath.indexOf(':')); + t = Base.targetsTable.get(targetName); + bootloaderPath = bootloaderPath.substring(bootloaderPath.indexOf(':') + 1); + } + + File bootloadersFile = new File(t.getFolder(), "bootloaders"); + File bootloaderFile = new File(bootloadersFile, bootloaderPath); + bootloaderPath = bootloaderFile.getAbsolutePath(); + + bootloader.add("-Uflash:w:" + bootloaderPath + File.separator + + boardPreferences.get("bootloader.file") + ":i"); } - - File bootloadersFile = new File(t.getFolder(), "bootloaders"); - File bootloaderFile = new File(bootloadersFile, bootloaderPath); - bootloaderPath = bootloaderFile.getAbsolutePath(); - - List bootloader = new ArrayList(); - bootloader.add("-Uflash:w:" + bootloaderPath + File.separator + - boardPreferences.get("bootloader.file") + ":i"); - bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m"); + if (boardPreferences.get("bootloader.lock_bits") != null) + bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m"); - return avrdude(params, bootloader); + if (bootloader.size() > 0) + return avrdude(params, bootloader); + + return true; } public boolean avrdude(Collection p1, Collection p2) throws RunnerException {