Improving third-party hardware support:

- moving back to multple cores per platform
- using target instead of platform
- moving per-board and per-programmer preferences out of Preferences.java and into a new Target class
- adding a new "target" preference
- support for platform:value values in board preferences for bootloader path and core
- XXX: need to support platform:value syntax for board upload.using preferences.
This commit is contained in:
David A. Mellis 2009-11-21 23:23:43 +00:00
parent 8720addcba
commit d2a38e4b5a
28 changed files with 205 additions and 203 deletions

View File

@ -30,6 +30,7 @@ import java.util.*;
import javax.swing.*;
import processing.app.debug.Compiler;
import processing.app.debug.Target;
import processing.core.*;
@ -85,7 +86,7 @@ public class Base {
// found in the sketchbook)
static public String librariesClassPath;
static public HashMap<String, File> platformsTable;
static public HashMap<String, Target> targetsTable;
// Location for untitled items
static File untitledFolder;
@ -278,7 +279,7 @@ public class Base {
}
}
platformsTable = new HashMap<String, File>();
targetsTable = new HashMap<String, Target>();
loadHardware(getHardwareFolder());
loadHardware(getSketchbookHardwareFolder());
@ -997,19 +998,26 @@ public class Base {
//System.out.println("rebuilding boards menu");
menu.removeAll();
ButtonGroup group = new ButtonGroup();
for (String board : Preferences.getSubKeys("boards")) {
AbstractAction action =
new AbstractAction(Preferences.get("boards." + board + ".name")) {
public void actionPerformed(ActionEvent actionevent) {
//System.out.println("Switching to " + board);
Preferences.set("board", (String) getValue("board"));
}
};
action.putValue("board", board);
JMenuItem item = new JRadioButtonMenuItem(action);
if (board.equals(Preferences.get("board"))) item.setSelected(true);
group.add(item);
menu.add(item);
for (Target target : targetsTable.values()) {
for (String board : target.getBoards().keySet()) {
AbstractAction action =
new AbstractAction(target.getBoards().get(board).get("name")) {
public void actionPerformed(ActionEvent actionevent) {
//System.out.println("Switching to " + target + ":" + board);
Preferences.set("target", (String) getValue("target"));
Preferences.set("board", (String) getValue("board"));
}
};
action.putValue("target", target.getName());
action.putValue("board", board);
JMenuItem item = new JRadioButtonMenuItem(action);
if (target.getName().equals(Preferences.get("target")) &&
board.equals(Preferences.get("board"))) {
item.setSelected(true);
}
group.add(item);
menu.add(item);
}
}
}
@ -1017,17 +1025,21 @@ public class Base {
public void rebuildBurnBootloaderMenu(JMenu menu) {
//System.out.println("rebuilding burn bootloader menu");
menu.removeAll();
for (String programmer : Preferences.getSubKeys("programmers")) {
AbstractAction action =
new AbstractAction(
"w/ " + Preferences.get("programmers." + programmer + ".name")) {
public void actionPerformed(ActionEvent actionevent) {
activeEditor.handleBurnBootloader((String) getValue("programmer"));
}
};
action.putValue("programmer", programmer);
JMenuItem item = new JMenuItem(action);
menu.add(item);
for (Target target : targetsTable.values()) {
for (String programmer : target.getProgrammers().keySet()) {
AbstractAction action =
new AbstractAction(
"w/ " + target.getProgrammers().get(programmer).get("name")) {
public void actionPerformed(ActionEvent actionevent) {
activeEditor.handleBurnBootloader((String) getValue("target"),
(String) getValue("programmer"));
}
};
action.putValue("target", target.getName());
action.putValue("programmer", programmer);
JMenuItem item = new JMenuItem(action);
menu.add(item);
}
}
}
@ -1228,30 +1240,9 @@ public class Base {
// replaced hella slow bubble sort with this feller for 0093
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
for (String platform : list) {
File subfolder = new File(folder, platform);
File boardsFile = new File(subfolder, "boards.txt");
try {
if (boardsFile.exists()) {
Preferences.load(new FileInputStream(boardsFile), "boards");
}
} catch (Exception e) {
System.err.println("Error loading boards from " +
boardsFile + ": " + e);
}
File programmersFile = new File(subfolder, "programmers.txt");
try {
if (programmersFile.exists()) {
Preferences.load(new FileInputStream(programmersFile), "programmers");
}
} catch (Exception e) {
System.err.println("Error loading programmers from " +
programmersFile + ": " + e);
}
platformsTable.put(platform, subfolder);
for (String target : list) {
File subfolder = new File(folder, target);
targetsTable.put(target, new Target(target, subfolder));
}
}
@ -1524,6 +1515,16 @@ public class Base {
}
}
static public Target getTarget() {
return Base.targetsTable.get(Preferences.get("target"));
}
static public Map<String, String> getBoardPreferences() {
return getTarget().getBoards().get(Preferences.get("board"));
}
static public File getSketchbookFolder() {
return new File(Preferences.get("sketchbook.path"));

View File

@ -2279,14 +2279,14 @@ public class Editor extends JFrame implements RunnerListener {
}
protected void handleBurnBootloader(final String programmer) {
protected void handleBurnBootloader(final String target, final String programmer) {
console.clear();
statusNotice("Burning bootloader to I/O Board (this may take a minute)...");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
Uploader uploader = new AvrdudeUploader();
if (uploader.burnBootloader(programmer)) {
if (uploader.burnBootloader(target, programmer)) {
statusNotice("Done burning bootloader.");
} else {
statusError("Error while burning bootloader.");

View File

@ -131,7 +131,6 @@ public class Preferences {
static Hashtable defaults;
static Hashtable table = new Hashtable();;
static Hashtable prefixes = new Hashtable();
static File preferencesFile;
@ -550,12 +549,7 @@ public class Preferences {
load(input, table);
}
static protected void load(InputStream input, String prefix) throws IOException {
if (!prefixes.containsKey(prefix)) prefixes.put(prefix, new LinkedHashMap());
load(input, (Map) prefixes.get(prefix));
}
static protected void load(InputStream input, Map table) throws IOException {
static public void load(InputStream input, Map table) throws IOException {
String[] lines = PApplet.loadStrings(input); // Reads as UTF-8
for (String line : lines) {
if ((line.length() == 0) ||
@ -609,24 +603,7 @@ public class Preferences {
//return get(attribute, null);
//}
static public String get(String prefix, String selector, String suffix) {
if (get(selector) == null) return null;
return get(prefix + "." + get(selector) + "." + suffix);
}
static public String get(String attribute /*, String defaultValue */) {
// if the attribute starts with a prefix used by one of our subsidiary
// preference files, look up the attribute in that file's Hashtable
// (don't override with or fallback to the main file). otherwise,
// look up the attribute in the main file's Hashtable.
Map table = Preferences.table;
if (attribute.indexOf('.') != -1) {
String prefix = attribute.substring(0, attribute.indexOf('.'));
if (prefixes.containsKey(prefix)) {
table = (Map) prefixes.get(prefix);
attribute = attribute.substring(attribute.indexOf('.') + 1);
}
}
return (String) table.get(attribute);
/*
//String value = (properties != null) ?
@ -639,28 +616,6 @@ public class Preferences {
}
/**
* Get the top-level key prefixes defined in the subsidiary file loaded with
* the given prefix. For example, if the file contains:
* foo.count=1
* bar.count=2
* baz.count=3
* this will return { "foo", "bar", "baz" }.
*/
static public Set<String> getSubKeys(String prefix) {
if (!prefixes.containsKey(prefix))
return null;
Set subkeys = new LinkedHashSet();
for (Iterator i = ((Map) prefixes.get(prefix)).keySet().iterator(); i.hasNext(); ) {
String subkey = (String) i.next();
if (subkey.indexOf('.') != -1)
subkey = subkey.substring(0, subkey.indexOf('.'));
subkeys.add(subkey);
}
return subkeys;
}
static public String getDefault(String attribute) {
return (String) defaults.get(attribute);
}

View File

@ -1447,7 +1447,7 @@ public class Sketch {
protected void size(String buildPath, String suggestedClassName)
throws RunnerException {
long size = 0;
long maxsize = Preferences.getInteger("boards." + Preferences.get("board") + ".upload.maximum_size");
long maxsize = Integer.parseInt(Base.getBoardPreferences().get("upload.maximum_size"));
Sizer sizer = new Sizer(buildPath, suggestedClassName);
try {
size = sizer.computeSize();

View File

@ -45,8 +45,8 @@ public class AvrdudeUploader extends Uploader {
public boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
throws RunnerException {
this.verbose = verbose;
String uploadUsing =
Preferences.get("boards." + Preferences.get("board") + ".upload.using");
Map<String, String> boardPreferences = Base.getBoardPreferences();
String uploadUsing = boardPreferences.get("upload.using");
if (uploadUsing == null) {
// fall back on global preference
uploadUsing = Preferences.get("upload.using");
@ -54,7 +54,8 @@ public class AvrdudeUploader extends Uploader {
if (uploadUsing.equals("bootloader")) {
return uploadViaBootloader(buildPath, className);
} else {
Collection params = getProgrammerCommands(uploadUsing);
// XXX: this needs to handle programmers in other targets.
Collection params = getProgrammerCommands(Base.getTarget().getName(), uploadUsing);
params.add("-Uflash:w:" + buildPath + File.separator + className + ".hex:i");
return avrdude(params);
}
@ -62,9 +63,9 @@ public class AvrdudeUploader extends Uploader {
private boolean uploadViaBootloader(String buildPath, String className)
throws RunnerException {
Map<String, String> boardPreferences = Base.getBoardPreferences();
List commandDownloader = new ArrayList();
String protocol =
Preferences.get("boards." + Preferences.get("board") + ".upload.protocol");
String protocol = boardPreferences.get("upload.protocol");
// avrdude wants "stk500v1" to distinguish it from stk500v2
if (protocol.equals("stk500"))
@ -73,56 +74,59 @@ public class AvrdudeUploader extends Uploader {
commandDownloader.add(
"-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
commandDownloader.add(
"-b" + Preferences.getInteger("boards." + Preferences.get("board") + ".upload.speed"));
"-b" + Integer.parseInt(boardPreferences.get("upload.speed")));
commandDownloader.add("-D"); // don't erase
commandDownloader.add("-Uflash:w:" + buildPath + File.separator + className + ".hex:i");
if (Preferences.get("boards", "board", "upload.disable_flushing") == null ||
Preferences.getBoolean("boards." + Preferences.get("board") + ".upload.disable_flushing") == false) {
if (boardPreferences.get("upload.disable_flushing") == null ||
boardPreferences.get("upload.disable_flushing").toLowerCase().equals("false")) {
flushSerialBuffer();
}
return avrdude(commandDownloader);
}
public boolean burnBootloader(String programmer) throws RunnerException {
return burnBootloader(getProgrammerCommands(programmer));
public boolean burnBootloader(String target, String programmer) throws RunnerException {
return burnBootloader(getProgrammerCommands(target, programmer));
}
private Collection getProgrammerCommands(String programmer) {
private Collection getProgrammerCommands(String targetName, String programmer) {
Target target = Base.targetsTable.get(targetName);
Map<String, String> programmerPreferences = target.getProgrammers().get(programmer);
List params = new ArrayList();
params.add("-c" + Preferences.get("programmers." + programmer + ".protocol"));
params.add("-c" + programmerPreferences.get("protocol"));
if ("usb".equals(Preferences.get("programmers." + programmer + ".communication"))) {
if ("usb".equals(programmerPreferences.get("communication"))) {
params.add("-Pusb");
} else if ("serial".equals(Preferences.get("programmers." + programmer + ".communication"))) {
} else if ("serial".equals(programmerPreferences.get("communication"))) {
params.add("-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
if (Preferences.get("programmers." + programmer + ".speed") != null) {
params.add("-b" + Preferences.getInteger("programmers." + programmer + ".speed"));
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 (Preferences.get("programmers." + programmer + ".force") != null &&
Preferences.getBoolean("programmers." + programmer + ".force"))
if (programmerPreferences.get("force") != null &&
programmerPreferences.get("force").toLowerCase().equals("true"))
params.add("-F");
if (Preferences.get("programmers." + programmer + ".delay") != null)
params.add("-i" + Preferences.get("programmers." + programmer + ".delay"));
if (programmerPreferences.get("delay") != null)
params.add("-i" + programmerPreferences.get("delay"));
return params;
}
protected boolean burnBootloader(Collection params)
throws RunnerException {
Map<String, String> boardPreferences = Base.getBoardPreferences();
List fuses = new ArrayList();
fuses.add("-e"); // erase the chip
fuses.add("-Ulock:w:" + Preferences.get("boards", "board", "bootloader.unlock_bits") + ":m");
if (Preferences.get("boards", "board", "bootloader.extended_fuses") != null)
fuses.add("-Uefuse:w:" + Preferences.get("boards", "board", "bootloader.extended_fuses") + ":m");
fuses.add("-Uhfuse:w:" + Preferences.get("boards", "board", "bootloader.high_fuses") + ":m");
fuses.add("-Ulfuse:w:" + Preferences.get("boards", "board", "bootloader.low_fuses") + ":m");
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(params, fuses))
return false;
@ -130,16 +134,26 @@ public class AvrdudeUploader extends Uploader {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
String platform = Preferences.get("boards", "board", "build.core");
File platformFile = Base.platformsTable.get(platform);
String bootloadersPath = new File(platformFile, "bootloaders").getAbsolutePath();
Target t;
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);
}
File bootloadersFile = new File(t.getFolder(), "bootloaders");
File bootloaderFile = new File(bootloadersFile, bootloaderPath);
bootloaderPath = bootloaderFile.getAbsolutePath();
List bootloader = new ArrayList();
bootloader.add("-Uflash:w:" + bootloadersPath + File.separator +
Preferences.get("boards", "board", "bootloader.path") + File.separator +
Preferences.get("boards", "board", "bootloader.file") + ":i");
bootloader.add("-Ulock:w:" + Preferences.get("boards", "board", "bootloader.lock_bits") + ":m");
bootloader.add("-Uflash:w:" + bootloaderPath + File.separator +
boardPreferences.get("bootloader.file") + ":i");
bootloader.add("-Ulock:w:" + boardPreferences.get("bootloader.lock_bits") + ":m");
return avrdude(params, bootloader);
}
@ -172,7 +186,7 @@ public class AvrdudeUploader extends Uploader {
commandDownloader.add("-q");
commandDownloader.add("-q");
}
commandDownloader.add("-p" + Preferences.get("boards", "board", "build.mcu"));
commandDownloader.add("-p" + Base.getBoardPreferences().get("build.mcu"));
commandDownloader.addAll(params);
return executeUploadCommand(commandDownloader);

View File

@ -71,9 +71,20 @@ public class Compiler implements MessageConsumer {
MessageStream pms = new MessageStream(this);
String avrBasePath = Base.getAvrBasePath();
String platform = Preferences.get("boards", "board", "build.core");
File platformFile = Base.platformsTable.get(platform);
String corePath = new File(platformFile, "core").getAbsolutePath();
Map<String, String> boardPreferences = Base.getBoardPreferences();
String core = boardPreferences.get("build.core");
String corePath;
if (core.indexOf(':') == -1) {
Target t = Base.getTarget();
File coreFolder = new File(new File(t.getFolder(), "cores"), core);
corePath = coreFolder.getAbsolutePath();
} else {
Target t = Base.targetsTable.get(core.substring(0, core.indexOf(':')));
File coresFolder = new File(t.getFolder(), "cores");
File coreFolder = new File(coresFolder, core.substring(core.indexOf(':') + 1));
corePath = coreFolder.getAbsolutePath();
}
List<File> objectFiles = new ArrayList<File>();
@ -89,7 +100,8 @@ public class Compiler implements MessageConsumer {
compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(corePath, "S", true),
findFilesInPath(corePath, "c", true),
findFilesInPath(corePath, "cpp", true));
findFilesInPath(corePath, "cpp", true),
boardPreferences);
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-ar",
@ -120,14 +132,16 @@ public class Compiler implements MessageConsumer {
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(libraryFolder, "S", false),
findFilesInFolder(libraryFolder, "c", false),
findFilesInFolder(libraryFolder, "cpp", false)));
findFilesInFolder(libraryFolder, "cpp", false),
boardPreferences));
outputFolder = new File(outputFolder, "utility");
createFolder(outputFolder);
objectFiles.addAll(
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(utilityFolder, "S", false),
findFilesInFolder(utilityFolder, "c", false),
findFilesInFolder(utilityFolder, "cpp", false)));
findFilesInFolder(utilityFolder, "cpp", false),
boardPreferences));
// other libraries should not see this library's utility/ folder
includePaths.remove(includePaths.size() - 1);
}
@ -138,7 +152,8 @@ public class Compiler implements MessageConsumer {
compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(buildPath, "S", false),
findFilesInPath(buildPath, "c", false),
findFilesInPath(buildPath, "cpp", false)));
findFilesInPath(buildPath, "cpp", false),
boardPreferences));
// 4. link it all together into the .elf file
@ -146,7 +161,7 @@ public class Compiler implements MessageConsumer {
avrBasePath + "avr-gcc",
"-Os",
"-Wl,--gc-sections",
"-mmcu=" + Preferences.get("boards", "board", "build.mcu"),
"-mmcu=" + boardPreferences.get("build.mcu"),
"-o",
buildPath + File.separator + primaryClassName + ".elf"
}));
@ -197,7 +212,8 @@ public class Compiler implements MessageConsumer {
private List<File> compileFiles(String avrBasePath,
String buildPath, List<File> includePaths,
List<File> sSources,
List<File> cSources, List<File> cppSources)
List<File> cSources, List<File> cppSources,
Map<String, String> boardPreferences)
throws RunnerException {
List<File> objectPaths = new ArrayList<File>();
@ -207,7 +223,8 @@ public class Compiler implements MessageConsumer {
objectPaths.add(new File(objectPath));
execAsynchronously(getCommandCompilerS(avrBasePath, includePaths,
file.getAbsolutePath(),
objectPath));
objectPath,
boardPreferences));
}
for (File file : cSources) {
@ -215,7 +232,8 @@ public class Compiler implements MessageConsumer {
objectPaths.add(new File(objectPath));
execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
file.getAbsolutePath(),
objectPath));
objectPath,
boardPreferences));
}
for (File file : cppSources) {
@ -223,7 +241,8 @@ public class Compiler implements MessageConsumer {
objectPaths.add(new File(objectPath));
execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
file.getAbsolutePath(),
objectPath));
objectPath,
boardPreferences));
}
return objectPaths;
@ -448,14 +467,14 @@ public class Compiler implements MessageConsumer {
/////////////////////////////////////////////////////////////////////////////
static private List getCommandCompilerS(String avrBasePath, List includePaths,
String sourceName, String objectName) {
String sourceName, String objectName, Map<String, String> boardPreferences) {
List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-gcc",
"-c", // compile, don't link
"-g", // include debugging info (so errors include line numbers)
"-assembler-with-cpp",
"-mmcu=" + Preferences.get("boards", "board", "build.mcu"),
"-DF_CPU=" + Preferences.get("boards", "board", "build.f_cpu"),
"-mmcu=" + boardPreferences.get("build.mcu"),
"-DF_CPU=" + boardPreferences.get("build.f_cpu"),
"-DARDUINO=" + Base.REVISION,
}));
@ -471,7 +490,7 @@ public class Compiler implements MessageConsumer {
static private List getCommandCompilerC(String avrBasePath, List includePaths,
String sourceName, String objectName) {
String sourceName, String objectName, Map<String, String> boardPreferences) {
List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-gcc",
@ -481,8 +500,8 @@ public class Compiler implements MessageConsumer {
"-w", // surpress all warnings
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards", "board", "build.mcu"),
"-DF_CPU=" + Preferences.get("boards", "board", "build.f_cpu"),
"-mmcu=" + boardPreferences.get("build.mcu"),
"-DF_CPU=" + boardPreferences.get("build.f_cpu"),
"-DARDUINO=" + Base.REVISION,
}));
@ -498,7 +517,8 @@ public class Compiler implements MessageConsumer {
static private List getCommandCompilerCPP(String avrBasePath,
List includePaths, String sourceName, String objectName) {
List includePaths, String sourceName, String objectName,
Map<String, String> boardPreferences) {
List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-g++",
@ -509,8 +529,8 @@ public class Compiler implements MessageConsumer {
"-fno-exceptions",
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards", "board", "build.mcu"),
"-DF_CPU=" + Preferences.get("boards", "board", "build.f_cpu"),
"-mmcu=" + boardPreferences.get("build.mcu"),
"-DF_CPU=" + boardPreferences.get("build.f_cpu"),
"-DARDUINO=" + Base.REVISION,
}));

View File

@ -1,11 +1,10 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Target - represents a target platform
Part of the Arduino project - http://arduino.berlios.de/
Target - represents a hardware platform
Part of the Arduino project - http://www.arduino.cc/
Copyright (c) 2005
David A. Mellis
Copyright (c) 2009 David A. Mellis
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
@ -21,59 +20,72 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: Target.java 85 2006-01-12 23:24:12Z mellis $
$Id$
*/
package processing.app.debug;
import java.io.*;
import java.util.*;
/**
* Represents a target platform (e.g. Wiring board, Arduino board).
*/
public class Target {
String path;
List sources = new ArrayList();
List objects = new ArrayList();
import processing.app.Preferences;
/**
* Create a Target.
* @param path the directory containing config, source, and object files for
* the target platform.
*/
public Target(String base, String target) throws IOException {
path = base + File.separator + target;
String[] files = (new File(path)).list();
public class Target {
private String name;
private File folder;
private Map boards;
private Map programmers;
public Target(String name, File folder) {
this.name = name;
this.folder = folder;
this.boards = new LinkedHashMap();
this.programmers = new LinkedHashMap();
if (files == null)
throw new IOException("Target platform: \"" + target + "\" not found.\n" +
"Make sure that \"build.target\" in the \n" +
"preferences file points to a subdirectory of \n" +
base);
for (int i = 0; i < files.length; i++) {
if (files[i].endsWith(".S") || files[i].endsWith(".c") || files[i].endsWith(".cpp"))
sources.add(files[i]);
if (files[i].endsWith(".o"))
objects.add(files[i]);
File boardsFile = new File(folder, "boards.txt");
try {
if (boardsFile.exists()) {
Map boardPreferences = new LinkedHashMap();
Preferences.load(new FileInputStream(boardsFile), boardPreferences);
for (Object k : boardPreferences.keySet()) {
String key = (String) k;
String board = key.substring(0, key.indexOf('.'));
if (!boards.containsKey(board)) boards.put(board, new HashMap());
((Map) boards.get(board)).put(
key.substring(key.indexOf('.') + 1),
boardPreferences.get(key));
}
}
} catch (Exception e) {
System.err.println("Error loading boards from " + boardsFile + ": " + e);
}
File programmersFile = new File(folder, "programmers.txt");
try {
if (programmersFile.exists()) {
Map programmerPreferences = new LinkedHashMap();
Preferences.load(new FileInputStream(programmersFile), programmerPreferences);
for (Object k : programmerPreferences.keySet()) {
String key = (String) k;
String programmer = key.substring(0, key.indexOf('.'));
if (!programmers.containsKey(programmer)) programmers.put(programmer, new HashMap());
((Map) programmers.get(programmer)).put(
key.substring(key.indexOf('.') + 1),
programmerPreferences.get(key));
}
}
} catch (Exception e) {
System.err.println("Error loading programmers from " +
programmersFile + ": " + e);
}
}
public String getPath() { return path; }
/**
* The source files in the library for the target platform.
* @return A read-only collection of strings containing the name of each source file.
*/
public Collection getSourceFilenames() {
return Collections.unmodifiableList(sources);
public String getName() { return name; }
public File getFolder() { return folder; }
public Map<String, Map<String, String>> getBoards() {
return boards;
}
/**
* The object files in the library for the target platform.
* @return A read-only collection of strings containing the name of each object file.
*/
public Collection getObjectFilenames() {
return Collections.unmodifiableList(objects);
public Map<String, Map<String, String>> getProgrammers() {
return programmers;
}
}
}

View File

@ -65,7 +65,7 @@ public abstract class Uploader implements MessageConsumer {
public abstract boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
throws RunnerException;
public abstract boolean burnBootloader(String programmer) throws RunnerException;
public abstract boolean burnBootloader(String target, String programmer) throws RunnerException;
protected void flushSerialBuffer() throws RunnerException {
// Cleanup the serial buffer