1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-19 13:54:23 +01:00

Added upload with bossac

This commit is contained in:
Cristian Maglie 2011-10-06 01:56:31 +02:00
parent a33fb50d92
commit cb92a1d402
6 changed files with 131 additions and 16 deletions

View File

@ -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<String, String> 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);

View File

@ -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<String> commandDownloader = new ArrayList<String>();
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<String> 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;
}
}
}

View File

@ -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<File> objectFiles;
public Compiler(Map<String, String> 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;

View File

@ -331,6 +331,7 @@
</copy>
<chmod perm="755" file="linux/work/hardware/tools/avrdude" />
<chmod perm="755" file="linux/work/hardware/tools/bossac" />
<copy todir="linux/work" file="linux/dist/arduino" />
<chmod perm="755" file="linux/work/arduino" />

BIN
build/linux/dist/tools/bossac vendored Executable file

Binary file not shown.

View File

@ -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