diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 9147043d7..498459fc0 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -24,6 +24,7 @@ package processing.app; import processing.app.debug.AvrdudeUploader; +import processing.app.debug.BossaCUploader; import processing.app.debug.Compiler; import processing.app.debug.RunnerException; import processing.app.debug.Sizer; @@ -1625,14 +1626,19 @@ public class Sketch { } - protected String upload(String buildPath, String suggestedClassName, boolean usingProgrammer) - throws RunnerException, SerialException { + protected String upload(String buildPath, String suggestedClassName, + boolean usingProgrammer) throws RunnerException, + SerialException { + + // upload the program + Map boardPreferences = Base.getBoardPreferences(); + String uploaderName = boardPreferences.get("uploader"); Uploader uploader; - - // download the program - // - uploader = new AvrdudeUploader(); + if (uploaderName != null && uploaderName.equals("bossac")) + uploader = new BossaCUploader(); + else + uploader = new AvrdudeUploader(); boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer); diff --git a/app/src/processing/app/debug/BossaCUploader.java b/app/src/processing/app/debug/BossaCUploader.java new file mode 100644 index 000000000..ebe9995de --- /dev/null +++ b/app/src/processing/app/debug/BossaCUploader.java @@ -0,0 +1,107 @@ +/* -*- 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) 2011 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 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; + +public class BossaCUploader extends Uploader { + + public boolean uploadUsingPreferences(String buildPath, String className, + boolean usingProgrammer) + throws RunnerException, SerialException { + List commandDownloader = new ArrayList(); + String port = Preferences.get("serial.port"); + if (port.startsWith("/dev/")) + port = port.substring(5); + commandDownloader.add("--port=" + (Base.isWindows() ? "\\\\.\\" : "") + + port); + commandDownloader.add("-e"); + commandDownloader.add("-w"); + commandDownloader.add("-v"); + commandDownloader.add("-b"); + commandDownloader.add(buildPath + File.separator + className + ".bin"); + + return bossac(commandDownloader); + } + + public boolean burnBootloader() { + return true; + } + + public boolean bossac(Collection params) throws RunnerException { + List commandDownloader = new ArrayList(); + commandDownloader.add("bossac"); + + if (verbose || Preferences.getBoolean("upload.verbose")) { + commandDownloader.add("-i"); + commandDownloader.add("-d"); + } + commandDownloader.addAll(params); + + return executeUploadCommand(commandDownloader); + } + + protected boolean executeUploadCommand(List cmdParams) + throws RunnerException { + + try { + String avrBasePath = Base.getHardwarePath() + "/tools/"; + if (!Base.isLinux()) + avrBasePath += "avr/bin/"; + + String[] cmdArray = cmdParams.toArray(new String[0]); + cmdArray[0] = avrBasePath + cmdArray[0]; + + if (verbose || Preferences.getBoolean("upload.verbose")) { + for (String cmd : cmdArray) + System.out.print(cmd + " "); + System.out.println(); + } + + Process bossac = Runtime.getRuntime().exec(cmdArray); + new MessageSiphon(bossac.getInputStream(), this); + new MessageSiphon(bossac.getErrorStream(), this); + + // wait for the process to finish. if interrupted + // before waitFor returns, continue waiting + int result = bossac.waitFor(); + if (result != 0) + return false; + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + +} diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 10c474087..f44afd020 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import processing.app.Base; +import processing.app.Preferences; import processing.app.Sketch; import processing.app.SketchCode; import processing.core.PApplet; @@ -63,7 +64,7 @@ public class Compiler implements MessageConsumer { List objectFiles; public Compiler(Map preferences) { - // Merge all the preferences file in the correct order of precedence + // Merge all the preferences file in the correct order of precedence // into a new map. configPreferences = preferences; avrBasePath = configPreferences.get("compiler.path"); @@ -309,12 +310,12 @@ public class Compiler implements MessageConsumer { int result = 0; - // if (verbose || Preferences.getBoolean("build.verbose")) { - System.out.print("EXEC: "); - for (String c : command) - System.out.print(c + " "); - System.out.println(); - // } + if (verbose || Preferences.getBoolean("build.verbose")) { + System.out.print("EXEC: "); + for (String c : command) + System.out.print(c + " "); + System.out.println(); + } firstErrorFound = false; // haven't found any errors yet secondErrorFound = false; diff --git a/build/build.xml b/build/build.xml index 0775a3975..5c328ab28 100644 --- a/build/build.xml +++ b/build/build.xml @@ -331,6 +331,7 @@ + diff --git a/build/linux/dist/tools/bossac b/build/linux/dist/tools/bossac new file mode 100755 index 000000000..1bef9218e Binary files /dev/null and b/build/linux/dist/tools/bossac differ diff --git a/hardware/sam/boards.txt b/hardware/sam/boards.txt index 7852a52ff..ec43dd61b 100644 --- a/hardware/sam/boards.txt +++ b/hardware/sam/boards.txt @@ -30,11 +30,11 @@ sam3u_ek.build.pins=sam3u_ek arduino_due.name=Arduino Due arduino_due.platform=sam -arduino_due.upload.protocol=sam-ba +arduino_due.uploader=bossac arduino_due.upload.maximum_size=49152 arduino_due.upload.speed=115200 -arduino_due.bootloader.path=sam3u_boot -arduino_due.bootloader.file=sam3u_boot.bin +#arduino_due.bootloader.path=sam3u_boot +#arduino_due.bootloader.file=sam3u_boot.bin arduino_due.build.mcu=cortex-m3 arduino_due.build.f_cpu=96000000L arduino_due.build.core=sam