From a141a1dc1e9575d0b8d277838d03d48a73a19469 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Sun, 5 Feb 2012 23:17:15 +0100 Subject: [PATCH] Upload/Program with configurable generic command line tools (wip) --- app/src/processing/app/Base.java | 13 +- app/src/processing/app/Editor.java | 2 +- app/src/processing/app/Sketch.java | 4 +- .../processing/app/debug/AvrdudeUploader.java | 242 ------------------ .../processing/app/debug/BasicUploader.java | 153 +++++++++++ .../processing/app/debug/TargetPlatform.java | 4 + app/src/processing/app/debug/Uploader.java | 2 +- .../app/helpers/PreferencesMap.java | 226 ++++++++-------- hardware/arduino/avr/boards.txt | 11 +- hardware/arduino/avr/platform.txt | 35 +-- hardware/arduino/avr/programmers.txt | 2 +- 11 files changed, 297 insertions(+), 397 deletions(-) delete mode 100644 app/src/processing/app/debug/AvrdudeUploader.java create mode 100644 app/src/processing/app/debug/BasicUploader.java diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index fa9313ec4..cbfc8811e 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1031,7 +1031,6 @@ public class Base { } - @SuppressWarnings("serial") public void rebuildBoardsMenu(JMenu menu) { String selPackage = Preferences.get("target_package"); String selPlatform = Preferences.get("target_platform"); @@ -1053,6 +1052,7 @@ public class Base { // Setup a menu item for the current board String boardName = boards.get(board).get("name"); + @SuppressWarnings("serial") AbstractAction action = new AbstractAction(boardName) { public void actionPerformed(ActionEvent actionevent) { Preferences.set("target_package", (String) getValue("package")); @@ -1080,7 +1080,6 @@ public class Base { } } - @SuppressWarnings("serial") public void rebuildProgrammerMenu(JMenu menu) { menu.removeAll(); ButtonGroup group = new ButtonGroup(); @@ -1088,8 +1087,10 @@ public class Base { for (TargetPlatform targetPlatform : targetPackage.platforms()) { for (String programmer : targetPlatform.getProgrammers().keySet()) { String id = targetPackage.getName() + ":" + programmer; + + @SuppressWarnings("serial") AbstractAction action = new AbstractAction(targetPlatform - .getProgrammers().get(programmer).get("name")) { + .getProgrammer(programmer).get("name")) { public void actionPerformed(ActionEvent actionevent) { Preferences.set("programmer", "" + getValue("id")); } @@ -1565,7 +1566,11 @@ public class Base { String platformName) { return packages.get(packageName).get(platformName); } - + + static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) { + return getTargetPlatform(pack, Preferences.get("target_platform")); + } + static public PreferencesMap getBoardPreferences() { TargetPlatform target = getTargetPlatform(); String board = Preferences.get("board"); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 9e52a021b..86b6b5b7e 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -2446,7 +2446,7 @@ public class Editor extends JFrame implements RunnerListener { SwingUtilities.invokeLater(new Runnable() { public void run() { try { - Uploader uploader = new AvrdudeUploader(); + Uploader uploader = new BasicUploader(); if (uploader.burnBootloader()) { statusNotice(_("Done burning bootloader.")); } else { diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index d6e5338f4..687f5666f 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -23,7 +23,7 @@ package processing.app; -import processing.app.debug.AvrdudeUploader; +import processing.app.debug.BasicUploader; import processing.app.debug.Compiler; import processing.app.debug.RunnerException; import processing.app.debug.Sizer; @@ -1700,7 +1700,7 @@ public class Sketch { // download the program // - uploader = new AvrdudeUploader(); + uploader = new BasicUploader(); boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer); diff --git a/app/src/processing/app/debug/AvrdudeUploader.java b/app/src/processing/app/debug/AvrdudeUploader.java deleted file mode 100644 index d9ff99a43..000000000 --- a/app/src/processing/app/debug/AvrdudeUploader.java +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - AvrdudeUploader - uploader implementation using avrdude - Part of the Arduino project - http://www.arduino.cc/ - - Copyright (c) 2004-05 - Hernando Barragan - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - $Id$ -*/ - -package processing.app.debug; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import processing.app.Base; -import processing.app.Preferences; -import processing.app.SerialException; -import processing.app.helpers.PreferencesMap; -import processing.app.helpers.StringReplacer; - -public class AvrdudeUploader extends Uploader { - - public boolean uploadUsingPreferences(String buildPath, String className, boolean usingProgrammer) - throws RunnerException, SerialException { - // FIXME: Preferences should be reorganized - PreferencesMap prefs = Preferences.getMap(); - prefs.putAll(Base.getBoardPreferences()); - - // if no protocol is specified for this board, assume it lacks a - // bootloader and upload using the selected programmer. - if (usingProgrammer || prefs.get("upload.protocol") == null) { - return uploadUsingProgrammer(buildPath, className); - } - - prefs.put("build.path", buildPath); - prefs.put("build.project_name", className); - - TargetPlatform targetPlatform = Base.getTargetPlatform(); - - prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool"))); - if (verbose) - prefs.put("upload.verbose", prefs.get("upload.params.verbose")); - else - prefs.put("upload.verbose", prefs.get("upload.params.quiet")); - - String pattern = prefs.get("upload.pattern"); - try { - if (prefs.get("upload.disable_flushing") == null - || prefs.get("upload.disable_flushing").toLowerCase().equals("false")) { - flushSerialBuffer(); - } - - String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); - return executeUploadCommand(cmd); - } catch (Exception e) { - throw new RunnerException(e); - } - } - - public boolean uploadUsingProgrammer(String buildPath, String className) - throws RunnerException { - - String programmer = Preferences.get("programmer"); - TargetPlatform targetPlatform = Base.getTargetPlatform(); - if (programmer.contains(":")) { - String[] split = programmer.split(":", 2); - targetPlatform = Base.getTargetPlatform(split[0], Preferences - .get("target_platform")); - programmer = split[1]; - } - - PreferencesMap prefs = Preferences.getMap(); - prefs.putAll(Base.getBoardPreferences()); - prefs.putAll(targetPlatform.getProgrammers().get(programmer)); - - prefs.put("build.path", buildPath); - prefs.put("build.project_name", className); - - PreferencesMap programmers = targetPlatform.getPreferences() - .createSubTree("programmers"); - prefs.putAll(programmers.createSubTree(prefs.get("program.tool"))); - - if (verbose) - prefs.put("program.verbose", prefs.get("program.params.verbose")); - else - prefs.put("program.verbose", prefs.get("program.params.quiet")); - - String pattern = prefs.get("program.pattern"); - try { - if (prefs.get("program.disable_flushing") == null - || prefs.get("program.disable_flushing").toLowerCase().equals("false")) { - flushSerialBuffer(); - } - - String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); - return executeUploadCommand(cmd); - } catch (Exception e) { - throw new RunnerException(e); - } - } - - public boolean burnBootloader() throws RunnerException { - String programmer = Preferences.get("programmer"); - TargetPlatform targetPlatform = Base.getTargetPlatform(); - if (programmer.contains(":")) { - String[] split = programmer.split(":", 2); - targetPlatform = Base.getTargetPlatform(split[0], Preferences - .get("target_platform")); - programmer = split[1]; - } - return burnBootloader(getProgrammerCommands(targetPlatform, programmer)); - } - - private Collection getProgrammerCommands(TargetPlatform target, String programmer) { - PreferencesMap programmerPreferences = target.getProgrammers().get(programmer); - List params = new ArrayList(); - params.add("-c" + programmerPreferences.get("protocol")); - - if ("usb".equals(programmerPreferences.get("communication"))) { - params.add("-Pusb"); - } else if ("serial".equals(programmerPreferences.get("communication"))) { - params.add("-P" + (Base.isWindows() ? "\\\\.\\" : "") - + Preferences.get("serial.port")); - if (programmerPreferences.get("speed") != null) { - params.add("-b" + Integer.parseInt(programmerPreferences.get("speed"))); - } - } - // XXX: add support for specifying the port address for parallel - // programmers, although avrdude has a default that works in most cases. - - if (programmerPreferences.get("force") != null && - programmerPreferences.get("force").toLowerCase().equals("true")) - params.add("-F"); - - if (programmerPreferences.get("delay") != null) - params.add("-i" + programmerPreferences.get("delay")); - - return params; - } - - protected boolean burnBootloader(Collection params) - throws RunnerException { - PreferencesMap boardPreferences = Base.getBoardPreferences(); - List fuses = new ArrayList(params); - fuses.add("-e"); // erase the chip - 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"); - fuses.add("-Ulfuse:w:" + boardPreferences.get("bootloader.low_fuses") + ":m"); - - if (!avrdude(fuses)) - return false; - - try { - Thread.sleep(1000); - } catch (InterruptedException e) {} - - List bootloader = new ArrayList(); - String bootloaderPath = boardPreferences.get("bootloader.path"); - - if (bootloaderPath != null) { - TargetPlatform targetPlatform; - if (bootloaderPath.contains(":")) { - // the current target (associated with the board) - targetPlatform = Base.getTargetPlatform(); - } else { - String[] split = bootloaderPath.split(":", 2); - targetPlatform = Base.getTargetPlatform(split[0], Preferences - .get("target_platform")); - bootloaderPath = split[1]; - } - - File bootloadersFile = new File(targetPlatform.getFolder(), "bootloaders"); - File bootloaderFile = new File(bootloadersFile, bootloaderPath); - bootloaderPath = bootloaderFile.getAbsolutePath(); - - bootloader.add("-Uflash:w:" + bootloaderPath + File.separator + - boardPreferences.get("bootloader.file") + ":i"); - } - if (boardPreferences.get("bootloader.lock_bits") != null) - bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m"); - - if (bootloader.size() > 0) { - params.addAll(bootloader); - return avrdude(params); - } - - return true; - } - - public boolean avrdude(Collection params) throws RunnerException { - List commandDownloader = new ArrayList(); - - if(Base.isLinux()) { - if ((new File(Base.getHardwarePath() + "/tools/" + "avrdude")).exists()) { - commandDownloader.add(Base.getHardwarePath() + "/tools/" + "avrdude"); - commandDownloader.add("-C" + Base.getHardwarePath() + "/tools/avrdude.conf"); - } else { - commandDownloader.add("avrdude"); - } - } - else { - commandDownloader.add(Base.getHardwarePath() + "/tools/avr/bin/" + "avrdude"); - commandDownloader.add("-C" + Base.getHardwarePath() + "/tools/avr/etc/avrdude.conf"); - } - - if (verbose || Preferences.getBoolean("upload.verbose")) { - commandDownloader.add("-v"); - commandDownloader.add("-v"); - commandDownloader.add("-v"); - commandDownloader.add("-v"); - } else { - commandDownloader.add("-q"); - commandDownloader.add("-q"); - } - commandDownloader.add("-p" + Base.getBoardPreferences().get("build.mcu")); - commandDownloader.addAll(params); - - return executeUploadCommand(commandDownloader); - } -} diff --git a/app/src/processing/app/debug/BasicUploader.java b/app/src/processing/app/debug/BasicUploader.java new file mode 100644 index 000000000..76a4aea19 --- /dev/null +++ b/app/src/processing/app/debug/BasicUploader.java @@ -0,0 +1,153 @@ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + BasicUploader - generic command line uploader implementation + Part of the Arduino project - http://www.arduino.cc/ + + Copyright (c) 2004-05 + Hernando Barragan + Copyright (c) 2012 + Cristian Maglie + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id$ +*/ + +package processing.app.debug; + +import processing.app.Base; +import processing.app.Preferences; +import processing.app.SerialException; +import processing.app.helpers.PreferencesMap; +import processing.app.helpers.StringReplacer; + +public class BasicUploader extends Uploader { + + public boolean uploadUsingPreferences(String buildPath, String className, + boolean usingProgrammer) + throws RunnerException, SerialException { + // FIXME: Preferences should be reorganized + TargetPlatform targetPlatform = Base.getTargetPlatform(); + PreferencesMap prefs = Preferences.getMap(); + prefs.putAll(Base.getBoardPreferences()); + prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool"))); + + // if no protocol is specified for this board, assume it lacks a + // bootloader and upload using the selected programmer. + if (usingProgrammer || prefs.get("upload.protocol") == null) { + return uploadUsingProgrammer(buildPath, className); + } + + prefs.put("build.path", buildPath); + prefs.put("build.project_name", className); + if (verbose) + prefs.put("upload.verbose", prefs.get("upload.params.verbose")); + else + prefs.put("upload.verbose", prefs.get("upload.params.quiet")); + + try { +// if (prefs.get("upload.disable_flushing") == null +// || prefs.get("upload.disable_flushing").toLowerCase().equals("false")) { +// flushSerialBuffer(); +// } + + String pattern = prefs.get("upload.pattern"); + String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); + return executeUploadCommand(cmd); + } catch (Exception e) { + throw new RunnerException(e); + } + } + + public boolean uploadUsingProgrammer(String buildPath, String className) + throws RunnerException { + + TargetPlatform targetPlatform = Base.getTargetPlatform(); + String programmer = Preferences.get("programmer"); + if (programmer.contains(":")) { + String[] split = programmer.split(":", 2); + targetPlatform = Base.getCurrentTargetPlatformFromPackage(split[0]); + programmer = split[1]; + } + + PreferencesMap prefs = Preferences.getMap(); + prefs.putAll(Base.getBoardPreferences()); + prefs.putAll(targetPlatform.getProgrammer(programmer)); + prefs.putAll(targetPlatform.getTool(prefs.get("program.tool"))); + + prefs.put("build.path", buildPath); + prefs.put("build.project_name", className); + + if (verbose) + prefs.put("program.verbose", prefs.get("program.params.verbose")); + else + prefs.put("program.verbose", prefs.get("program.params.quiet")); + + try { + // if (prefs.get("program.disable_flushing") == null + // || prefs.get("program.disable_flushing").toLowerCase().equals("false")) + // { + // flushSerialBuffer(); + // } + + String pattern = prefs.get("program.pattern"); + String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); + return executeUploadCommand(cmd); + } catch (Exception e) { + throw new RunnerException(e); + } + } + + public boolean burnBootloader() throws RunnerException { + String programmer = Preferences.get("programmer"); + TargetPlatform targetPlatform = Base.getTargetPlatform(); + if (programmer.contains(":")) { + String[] split = programmer.split(":", 2); + targetPlatform = Base.getCurrentTargetPlatformFromPackage(split[0]); + programmer = split[1]; + } + + PreferencesMap prefs = Preferences.getMap(); + prefs.putAll(Base.getBoardPreferences()); + prefs.putAll(targetPlatform.getProgrammer(programmer)); + prefs.putAll(targetPlatform.getTool(prefs.get("bootloader.tool"))); + if (verbose) + prefs.put("bootloader.verbose", prefs.get("bootloader.params.verbose")); + else + prefs.put("bootloader.verbose", prefs.get("bootloader.params.quiet")); + + try { + // if (prefs.get("program.disable_flushing") == null + // || prefs.get("program.disable_flushing").toLowerCase().equals("false")) + // { + // flushSerialBuffer(); + // } + + prefs.put("bootloader.params", prefs.get("bootloader.erase.params")); + String pattern = prefs.get("bootloader.pattern"); + String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); + if (!executeUploadCommand(cmd)) + return false; + + prefs.put("bootloader.params", prefs.get("bootloader.write.params")); + pattern = prefs.get("bootloader.pattern"); + cmd = StringReplacer.formatAndSplit(pattern, prefs, true); + return executeUploadCommand(cmd); + } catch (Exception e) { + throw new RunnerException(e); + } + } +} diff --git a/app/src/processing/app/debug/TargetPlatform.java b/app/src/processing/app/debug/TargetPlatform.java index 5abc5fcd4..65b9f459d 100644 --- a/app/src/processing/app/debug/TargetPlatform.java +++ b/app/src/processing/app/debug/TargetPlatform.java @@ -92,6 +92,10 @@ public class TargetPlatform { return programmers; } + public PreferencesMap getProgrammer(String programmer) { + return getProgrammers().get(programmer); + } + public PreferencesMap getTool(String tool) { return getPreferences().createSubTree("tools").createSubTree(tool); } diff --git a/app/src/processing/app/debug/Uploader.java b/app/src/processing/app/debug/Uploader.java index 0e79871a3..fb98bc497 100644 --- a/app/src/processing/app/debug/Uploader.java +++ b/app/src/processing/app/debug/Uploader.java @@ -86,7 +86,7 @@ public abstract class Uploader implements MessageConsumer { } } - protected boolean executeUploadCommand(Collection commandDownloader) + protected boolean executeUploadCommand(Collection commandDownloader) throws RunnerException { String[] commandArray = new String[commandDownloader.size()]; commandDownloader.toArray(commandArray); diff --git a/app/src/processing/app/helpers/PreferencesMap.java b/app/src/processing/app/helpers/PreferencesMap.java index 13b4bd049..301f5a701 100644 --- a/app/src/processing/app/helpers/PreferencesMap.java +++ b/app/src/processing/app/helpers/PreferencesMap.java @@ -36,127 +36,127 @@ import processing.core.PApplet; public class PreferencesMap extends HashMap { - public PreferencesMap(Hashtable table) { - super(table); - } + public PreferencesMap(Hashtable table) { + super(table); + } - public PreferencesMap(PreferencesMap prefs) { - super(prefs); - } - - public PreferencesMap() { - super(); - } + public PreferencesMap(PreferencesMap prefs) { + super(prefs); + } + + public PreferencesMap() { + super(); + } /** - * Parse a property list file and put kev/value pairs into the Map - * - * @param file - * @throws FileNotFoundException - * @throws IOException - */ - public void load(File file) throws FileNotFoundException, IOException { - load(new FileInputStream(file)); - } + * Parse a property list file and put kev/value pairs into the Map + * + * @param file + * @throws FileNotFoundException + * @throws IOException + */ + public void load(File file) throws FileNotFoundException, IOException { + load(new FileInputStream(file)); + } - /** - * Parse a property list stream and put key/value pairs into the Map - * - * @param input - * @throws IOException - */ - public void load(InputStream input) throws IOException { - String[] lines = PApplet.loadStrings(input); - for (String line : lines) { - if (line.length() == 0 || line.charAt(0) == '#') - continue; + /** + * Parse a property list stream and put key/value pairs into the Map + * + * @param input + * @throws IOException + */ + public void load(InputStream input) throws IOException { + String[] lines = PApplet.loadStrings(input); + for (String line : lines) { + if (line.length() == 0 || line.charAt(0) == '#') + continue; - int equals = line.indexOf('='); - if (equals != -1) { - String key = line.substring(0, equals); - String value = line.substring(equals + 1); - put(key.trim(), value.trim()); - } - } - } + int equals = line.indexOf('='); + if (equals != -1) { + String key = line.substring(0, equals); + String value = line.substring(equals + 1); + put(key.trim(), value.trim()); + } + } + } - /** - * Create a new Map where the keys are the first level - * of the current mapping. E.g. the folowing mapping:
- * - *
-	 * Map (
-	 *     alpha.some.keys = v1
-	 *     alpha.other.keys = v2
-	 *     beta.some.keys = v3
-	 *   )
-	 * 
- * - * will generate the following result: - * - *
-	 * alpha = Map(
-	 *     some.keys = v1
-	 *     other.keys = v2
-	 *   )
-	 * beta = Map(
-	 *     some.keys = v3
-	 *   )
-	 * 
- * - * @return - */ - public Map createFirstLevelMap() { - Map res = new HashMap(); - for (String key : keySet()) { - int dot = key.indexOf('.'); - if (dot == -1) - continue; + /** + * Create a new Map where the keys are the first level + * of the current mapping. E.g. the folowing mapping:
+ * + *
+   * Map (
+   *     alpha.some.keys = v1
+   *     alpha.other.keys = v2
+   *     beta.some.keys = v3
+   *   )
+   * 
+ * + * will generate the following result: + * + *
+   * alpha = Map(
+   *     some.keys = v1
+   *     other.keys = v2
+   *   )
+   * beta = Map(
+   *     some.keys = v3
+   *   )
+   * 
+ * + * @return + */ + public Map createFirstLevelMap() { + Map res = new HashMap(); + for (String key : keySet()) { + int dot = key.indexOf('.'); + if (dot == -1) + continue; - String parent = key.substring(0, dot); - String child = key.substring(dot + 1); + String parent = key.substring(0, dot); + String child = key.substring(dot + 1); - if (!res.containsKey(parent)) - res.put(parent, new PreferencesMap()); - res.get(parent).put(child, get(key)); - } - return res; - } + if (!res.containsKey(parent)) + res.put(parent, new PreferencesMap()); + res.get(parent).put(child, get(key)); + } + return res; + } - /** - * Create a new PreferenceMap using a subtree of the current mapping. E.g. - * with the folowing mapping:
- * - *
-	 * Map (
-	 *     alpha.some.keys = v1
-	 *     alpha.other.keys = v2
-	 *     beta.some.keys = v3
-	 *   )
-	 * 
- * - * a call to createSubTree("alpha") will generate the following result: - * - *
-	 * Map(
-	 *     some.keys = v1
-	 *     other.keys = v2
-	 *   )
-	 * 
- * - * @param parent - * @return - */ - public PreferencesMap createSubTree(String parent) { - PreferencesMap res = new PreferencesMap(); - parent += "."; - int parentLen = parent.length(); - for (String key : keySet()) { - if (key.startsWith(parent)) - res.put(key.substring(parentLen), get(key)); - } - return res; - } + /** + * Create a new PreferenceMap using a subtree of the current mapping. E.g. + * with the folowing mapping:
+ * + *
+   * Map (
+   *     alpha.some.keys = v1
+   *     alpha.other.keys = v2
+   *     beta.some.keys = v3
+   *   )
+   * 
+ * + * a call to createSubTree("alpha") will generate the following result: + * + *
+   * Map(
+   *     some.keys = v1
+   *     other.keys = v2
+   *   )
+   * 
+ * + * @param parent + * @return + */ + public PreferencesMap createSubTree(String parent) { + PreferencesMap res = new PreferencesMap(); + parent += "."; + int parentLen = parent.length(); + for (String key : keySet()) { + if (key.startsWith(parent)) + res.put(key.substring(parentLen), get(key)); + } + return res; + } - private static final long serialVersionUID = 2330591567444282843L; + private static final long serialVersionUID = 2330591567444282843L; } diff --git a/hardware/arduino/avr/boards.txt b/hardware/arduino/avr/boards.txt index 32063cbd7..690309812 100644 --- a/hardware/arduino/avr/boards.txt +++ b/hardware/arduino/avr/boards.txt @@ -5,13 +5,10 @@ uno.upload.tool=avrdude uno.upload.protocol=arduino uno.upload.maximum_size=32256 uno.upload.speed=115200 -uno.bootloader.low_fuses=0xff -uno.bootloader.high_fuses=0xde -uno.bootloader.extended_fuses=0x05 -uno.bootloader.path=optiboot -uno.bootloader.file=optiboot_atmega328.hex -uno.bootloader.unlock_bits=0x3F -uno.bootloader.lock_bits=0x0F +uno.bootloader.tool=avrdude +uno.bootloader.erase.params=-e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m +uno.bootloader.write.params=-Uflash:w:{bootloader.file}:i -Ulock:w:0x0F:m +uno.bootloader.file={runtime.ide.path}/hardware/arduino/avr/optiboot/optiboot_atmega328.hex uno.build.mcu=atmega328p uno.build.f_cpu=16000000L uno.build.core=arduino diff --git a/hardware/arduino/avr/platform.txt b/hardware/arduino/avr/platform.txt index 59e2d16fb..9664c20f8 100644 --- a/hardware/arduino/avr/platform.txt +++ b/hardware/arduino/avr/platform.txt @@ -47,35 +47,18 @@ recipe.objcopy.hex.pattern={compiler.path}{compiler.elf2hex.cmd} {compiler.elf2h # AVR Uploader/Programmers tools # ------------------- -tools.avrdude.upload.cmd=avrdude -tools.avrdude.upload.path={runtime.ide.path}/hardware/tools -tools.avrdude.upload.config.path={upload.path}/avrdude.conf +tools.avrdude.cmd=avrdude +tools.avrdude.path={runtime.ide.path}/hardware/tools +tools.avrdude.config.path={path}/avrdude.conf + tools.avrdude.upload.params.verbose=-v -v -v -v tools.avrdude.upload.params.quiet=-q -q -tools.avrdude.upload.pattern={upload.path}/{upload.cmd} -C{upload.config.path} {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D -Uflash:w:{build.path}/{build.project_name}.hex:i +tools.avrdude.upload.pattern={path}/{cmd} -C{config.path} {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D -Uflash:w:{build.path}/{build.project_name}.hex:i -# /home/megabug/git/ARM-merged/build/linux/work/hardware/tools/avrdude -# -C/home/megabug/git/ARM-merged/build/linux/work/hardware/tools/avrdude.conf -# -q -q -# -patmega328p -# -carduino -# -P/dev/ttyACM0 -# -b115200 -# -D -# -Uflash:w:/tmp/build366783256629686367.tmp/Blink.cpp.hex:i - -tools.avrdude.program.cmd=avrdude -tools.avrdude.program.path={runtime.ide.path}/hardware/tools -tools.avrdude.program.config.path={program.path}/avrdude.conf tools.avrdude.program.params.verbose=-v -v -v -v tools.avrdude.program.params.quiet=-q -q -tools.avrdude.program.pattern={program.path}/{program.cmd} -C{program.config.path} {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -Uflash:w:{build.path}/{build.project_name}.hex:i - -# /home/megabug/git/ARM-merged/build/linux/work/hardware/tools/avrdude -# -C/home/megabug/git/ARM-merged/build/linux/work/hardware/tools/avrdude.conf -# -q -q -# -patmega328p -# -cusbasp -# -Pusb -# -Uflash:w:/tmp/build8190214930979711138.tmp/Blink.cpp.hex:i +tools.avrdude.program.pattern={path}/{cmd} -C{config.path} {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -Uflash:w:{build.path}/{build.project_name}.hex:i +tools.avrdude.bootloader.params.verbose=-v -v -v -v +tools.avrdude.bootloader.params.quiet=-q -q +tools.avrdude.bootloader.pattern={path}/{cmd} -C{config.path} {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} {bootloader.params} diff --git a/hardware/arduino/avr/programmers.txt b/hardware/arduino/avr/programmers.txt index a05519378..65d8cdbbd 100644 --- a/hardware/arduino/avr/programmers.txt +++ b/hardware/arduino/avr/programmers.txt @@ -29,7 +29,7 @@ parallel.protocol=dapa parallel.force=true # parallel.delay=200 parallel.program.tool=avrdude -parallel.program.extra_params= +parallel.program.extra_params=-F arduinoisp.name=Arduino as ISP arduinoisp.communication=serial