mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Modified bootloader burning: AvrdudeUploader now can burn bootloader with avrispmkii (but not parallel port), and the bootloader burning commands take a target. And the menu items are there, but wrong.
This commit is contained in:
parent
f64b201e73
commit
d0c55e79c7
@ -39,15 +39,16 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
public boolean uploadUsingPreferences(String buildPath, String className)
|
public boolean uploadUsingPreferences(String buildPath, String className)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
List commandDownloader = new ArrayList();
|
List commandDownloader = new ArrayList();
|
||||||
|
|
||||||
|
// avrdude doesn't want to read device signatures (it always gets
|
||||||
|
// 0x000000); force it to continue uploading anyway
|
||||||
|
commandDownloader.add("-F");
|
||||||
|
|
||||||
String programmer = Preferences.get("upload.programmer");
|
String programmer = Preferences.get("upload.programmer");
|
||||||
|
|
||||||
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
||||||
if (programmer.equals("stk500"))
|
if (programmer.equals("stk500"))
|
||||||
programmer = "stk500v1";
|
programmer = "stk500v1";
|
||||||
|
|
||||||
// avrdude doesn't want to read device signatures (it always gets
|
|
||||||
// 0x000000); force it to continue uploading anyway
|
|
||||||
commandDownloader.add("-F");
|
|
||||||
commandDownloader.add("-c" + programmer);
|
commandDownloader.add("-c" + programmer);
|
||||||
if (Preferences.get("upload.programmer").equals("dapa")) {
|
if (Preferences.get("upload.programmer").equals("dapa")) {
|
||||||
// avrdude doesn't need to be told the address of the parallel port
|
// avrdude doesn't need to be told the address of the parallel port
|
||||||
@ -70,45 +71,48 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
return uisp(commandDownloader);
|
return uisp(commandDownloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean burnBootloaderAVRISP() throws RunnerException {
|
public boolean burnBootloaderAVRISP(String target) throws RunnerException {
|
||||||
List commandDownloader = new ArrayList();
|
List commandDownloader = new ArrayList();
|
||||||
commandDownloader.add("-dprog=" + Preferences.get("bootloader.programmer"));
|
commandDownloader.add("-c" +
|
||||||
commandDownloader.add(
|
Preferences.get("bootloader." + target + ".programmer"));
|
||||||
"-dserial=" + (Base.isWindows() ?
|
|
||||||
"/dev/" + Preferences.get("serial.port").toLowerCase() :
|
if (Preferences.get("bootloader." + target + ".communication").equals("usb")) {
|
||||||
Preferences.get("serial.port")));
|
commandDownloader.add("-Pusb");
|
||||||
commandDownloader.add("-dspeed=" + Preferences.get("serial.burn_rate"));
|
} else {
|
||||||
return burnBootloader(commandDownloader);
|
commandDownloader.add(
|
||||||
|
"-P" + (Base.isWindows() ?
|
||||||
|
"/dev/" + Preferences.get("serial.port").toLowerCase() :
|
||||||
|
Preferences.get("serial.port")));
|
||||||
|
}
|
||||||
|
commandDownloader.add("-b" + Preferences.get("serial.burn_rate"));
|
||||||
|
return burnBootloader(target, commandDownloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean burnBootloaderParallel() throws RunnerException {
|
public boolean burnBootloaderParallel(String target) throws RunnerException {
|
||||||
List commandDownloader = new ArrayList();
|
List commandDownloader = new ArrayList();
|
||||||
commandDownloader.add("-dprog=dapa");
|
commandDownloader.add("-dprog=dapa");
|
||||||
commandDownloader.add("-dlpt=" + Preferences.get("parallel.port"));
|
commandDownloader.add("-dlpt=" + Preferences.get("parallel.port"));
|
||||||
return burnBootloader(commandDownloader);
|
return burnBootloader(target, commandDownloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean burnBootloader(Collection params) throws RunnerException {
|
protected boolean burnBootloader(String target, Collection params)
|
||||||
// I know this is ugly; apologies - that's what happens when you try to
|
throws RunnerException
|
||||||
// write Lisp-style code in Java.
|
{
|
||||||
return
|
return
|
||||||
// unlock bootloader segment of flash memory
|
// unlock bootloader segment of flash memory and write fuses
|
||||||
uisp(params, Arrays.asList(new String[] {
|
uisp(params, Arrays.asList(new String[] {
|
||||||
"--wr_lock=" + Preferences.get("bootloader.unlock_bits") })) &&
|
"-e",
|
||||||
// write fuses:
|
"-Ulock:w:" + Preferences.get("bootloader." + target + ".unlock_bits") + ":m",
|
||||||
// bootloader size of 512 words; from 0xE00-0xFFF
|
"-Uefuse:w:" + Preferences.get("bootloader." + target + ".extended_fuses") + ":m",
|
||||||
// clock speed of 16 MHz, external quartz
|
"-Uhfuse:w:" + Preferences.get("bootloader." + target + ".high_fuses") + ":m",
|
||||||
|
"-Ulfuse:w:" + Preferences.get("bootloader." + target + ".low_fuses") + ":m",
|
||||||
|
})) &&
|
||||||
|
// upload bootloader and lock bootloader segment
|
||||||
uisp(params, Arrays.asList(new String[] {
|
uisp(params, Arrays.asList(new String[] {
|
||||||
"--wr_fuse_l=" + Preferences.get("bootloader.low_fuses"),
|
"-Uflash:w:" + Preferences.get("bootloader." + target + ".path") +
|
||||||
"--wr_fuse_h=" + Preferences.get("bootloader.high_fuses") })) &&
|
File.separator + Preferences.get("bootloader." + target + ".file") + ":i",
|
||||||
// upload bootloader
|
"-Ulock:w:" + Preferences.get("bootloader." + target + ".lock_bits") + ":m"
|
||||||
uisp(params, Arrays.asList(new String[] {
|
}));
|
||||||
"--erase", "--upload", "--verify",
|
|
||||||
"if=" + Preferences.get("bootloader.path") + File.separator +
|
|
||||||
Preferences.get("bootloader.file") })) &&
|
|
||||||
// lock bootloader segment
|
|
||||||
uisp(params, Arrays.asList(new String[] {
|
|
||||||
"--wr_lock=" + Preferences.get("bootloader.lock_bits") }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean uisp(Collection p1, Collection p2) throws RunnerException {
|
public boolean uisp(Collection p1, Collection p2) throws RunnerException {
|
||||||
|
109
app/Editor.java
109
app/Editor.java
@ -104,8 +104,13 @@ public class Editor extends JFrame
|
|||||||
//Runner runtime;
|
//Runner runtime;
|
||||||
|
|
||||||
|
|
||||||
JMenuItem burnBootloaderItem = null;
|
JMenuItem burnBootloader8Item = null;
|
||||||
JMenuItem burnBootloaderParallelItem = null;
|
JMenuItem burnBootloader8ParallelItem = null;
|
||||||
|
JMenuItem burnBootloader168DiecimilaItem = null;
|
||||||
|
JMenuItem burnBootloader168DiecimilaParallelItem = null;
|
||||||
|
JMenuItem burnBootloader168NGItem = null;
|
||||||
|
JMenuItem burnBootloader168NGParallelItem = null;
|
||||||
|
|
||||||
JMenuItem exportAppItem;
|
JMenuItem exportAppItem;
|
||||||
JMenuItem saveMenuItem;
|
JMenuItem saveMenuItem;
|
||||||
JMenuItem saveAsMenuItem;
|
JMenuItem saveAsMenuItem;
|
||||||
@ -732,31 +737,65 @@ public class Editor extends JFrame
|
|||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
burnBootloaderItem = new JMenuItem("Burn Bootloader");
|
burnBootloader8Item = new JMenuItem("Burn Bootloader");
|
||||||
burnBootloaderItem.addActionListener(new ActionListener() {
|
burnBootloader8Item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
handleBurnBootloader(false);
|
handleBurnBootloader("atmega8", false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(burnBootloaderItem);
|
menu.add(burnBootloader8Item);
|
||||||
|
|
||||||
if (!Preferences.get("build.mcu").equals("atmega8"))
|
|
||||||
burnBootloaderItem.setEnabled(false);
|
|
||||||
|
|
||||||
if (!Base.isMacOS()) {
|
if (!Base.isMacOS()) {
|
||||||
burnBootloaderParallelItem =
|
burnBootloader8ParallelItem =
|
||||||
new JMenuItem("Burn Bootloader (parallel port)");
|
new JMenuItem("Burn Bootloader (parallel port)");
|
||||||
burnBootloaderParallelItem.addActionListener(new ActionListener() {
|
burnBootloader8ParallelItem.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
handleBurnBootloader(true);
|
handleBurnBootloader("atmega8", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(burnBootloaderParallelItem);
|
menu.add(burnBootloader8ParallelItem);
|
||||||
|
|
||||||
if (!Preferences.get("build.mcu").equals("atmega8"))
|
|
||||||
burnBootloaderParallelItem.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
burnBootloader168DiecimilaItem = new JMenuItem("Burn Diecimila Bootloader");
|
||||||
|
burnBootloader168DiecimilaItem.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
handleBurnBootloader("atmega168-diecimila", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(burnBootloader168DiecimilaItem);
|
||||||
|
|
||||||
|
if (!Base.isMacOS()) {
|
||||||
|
burnBootloader168DiecimilaParallelItem =
|
||||||
|
new JMenuItem("Burn Diecimila Bootloader (parallel port)");
|
||||||
|
burnBootloader168DiecimilaParallelItem.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
handleBurnBootloader("atmega168-diecimila", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(burnBootloader168DiecimilaParallelItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
burnBootloader168NGItem = new JMenuItem("Burn NG/Mini Bootloader");
|
||||||
|
burnBootloader168NGItem.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
handleBurnBootloader("atmega168-ng", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(burnBootloader168NGItem);
|
||||||
|
|
||||||
|
if (!Base.isMacOS()) {
|
||||||
|
burnBootloader168NGParallelItem =
|
||||||
|
new JMenuItem("Burn NG/Mini Bootloader (parallel port)");
|
||||||
|
burnBootloader168NGParallelItem.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
handleBurnBootloader("atmega168-ng", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(burnBootloader168NGParallelItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
showBootloaderMenuItemsForCurrentMCU();
|
||||||
|
|
||||||
menu.addMenuListener(new MenuListener() {
|
menu.addMenuListener(new MenuListener() {
|
||||||
public void menuCanceled(MenuEvent e) {}
|
public void menuCanceled(MenuEvent e) {}
|
||||||
public void menuDeselected(MenuEvent e) {}
|
public void menuDeselected(MenuEvent e) {}
|
||||||
@ -801,6 +840,22 @@ public class Editor extends JFrame
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showBootloaderMenuItemsForCurrentMCU() {
|
||||||
|
boolean onATmega8 =
|
||||||
|
Preferences.get("build.mcu").equals("atmega8");
|
||||||
|
|
||||||
|
burnBootloader8Item.setEnabled(onATmega8);
|
||||||
|
if (burnBootloader8ParallelItem != null)
|
||||||
|
burnBootloader8ParallelItem.setEnabled(onATmega8);
|
||||||
|
|
||||||
|
burnBootloader168DiecimilaItem.setEnabled(!onATmega8);
|
||||||
|
if (burnBootloader168DiecimilaParallelItem != null)
|
||||||
|
burnBootloader168DiecimilaParallelItem.setEnabled(!onATmega8);
|
||||||
|
burnBootloader168NGItem.setEnabled(!onATmega8);
|
||||||
|
if (burnBootloader168NGParallelItem != null)
|
||||||
|
burnBootloader168NGParallelItem.setEnabled(!onATmega8);
|
||||||
|
}
|
||||||
|
|
||||||
class McuMenuListener implements ActionListener {
|
class McuMenuListener implements ActionListener {
|
||||||
McuMenuListener() {}
|
McuMenuListener() {}
|
||||||
@ -813,13 +868,9 @@ public class Editor extends JFrame
|
|||||||
((JCheckBoxMenuItem) actionevent.getSource()).setState(true);
|
((JCheckBoxMenuItem) actionevent.getSource()).setState(true);
|
||||||
Preferences.set("build.mcu",
|
Preferences.set("build.mcu",
|
||||||
((JCheckBoxMenuItem) actionevent.getSource()).getLabel());
|
((JCheckBoxMenuItem) actionevent.getSource()).getLabel());
|
||||||
|
|
||||||
boolean bootloadingEnabled =
|
showBootloaderMenuItemsForCurrentMCU();
|
||||||
Preferences.get("build.mcu").equals("atmega8");
|
|
||||||
burnBootloaderItem.setEnabled(bootloadingEnabled);
|
|
||||||
if (burnBootloaderParallelItem != null)
|
|
||||||
burnBootloaderParallelItem.setEnabled(bootloadingEnabled);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LibraryManager libraryManager = new LibraryManager();
|
LibraryManager libraryManager = new LibraryManager();
|
||||||
libraryManager.rebuildAllBuilt();
|
libraryManager.rebuildAllBuilt();
|
||||||
@ -1997,14 +2048,10 @@ public class Editor extends JFrame
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleBurnBootloader(final boolean parallel) {
|
protected void handleBurnBootloader(final String target, final boolean parallel) {
|
||||||
if(debugging)
|
if(debugging)
|
||||||
doStop();
|
doStop();
|
||||||
console.clear();
|
console.clear();
|
||||||
if (!Preferences.get("build.mcu").equals("atmega8")) {
|
|
||||||
error("Burn bootloader only works on ATmega8s. See the Arduino FAQ for more info.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//String what = sketch.isLibrary() ? "Applet" : "Library";
|
//String what = sketch.isLibrary() ? "Applet" : "Library";
|
||||||
//message("Exporting " + what + "...");
|
//message("Exporting " + what + "...");
|
||||||
message("Burning bootloader to I/O Board (this may take a minute)...");
|
message("Burning bootloader to I/O Board (this may take a minute)...");
|
||||||
@ -2013,10 +2060,10 @@ public class Editor extends JFrame
|
|||||||
try {
|
try {
|
||||||
//boolean success = sketch.isLibrary() ?
|
//boolean success = sketch.isLibrary() ?
|
||||||
//sketch.exportLibrary() : sketch.exportApplet();
|
//sketch.exportLibrary() : sketch.exportApplet();
|
||||||
Uploader uploader = new UispUploader();
|
Uploader uploader = new AvrdudeUploader();
|
||||||
boolean success = parallel ?
|
boolean success = parallel ?
|
||||||
uploader.burnBootloaderParallel() :
|
uploader.burnBootloaderParallel(target) :
|
||||||
uploader.burnBootloaderAVRISP();
|
uploader.burnBootloaderAVRISP(target);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
message("Done burning bootloader.");
|
message("Done burning bootloader.");
|
||||||
|
@ -72,7 +72,7 @@ public class UispUploader extends Uploader {
|
|||||||
return uisp(commandDownloader);
|
return uisp(commandDownloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean burnBootloaderAVRISP() throws RunnerException {
|
public boolean burnBootloaderAVRISP(String target) throws RunnerException {
|
||||||
List commandDownloader = new ArrayList();
|
List commandDownloader = new ArrayList();
|
||||||
commandDownloader.add("-dprog=" + Preferences.get("bootloader.programmer"));
|
commandDownloader.add("-dprog=" + Preferences.get("bootloader.programmer"));
|
||||||
commandDownloader.add(
|
commandDownloader.add(
|
||||||
@ -83,7 +83,7 @@ public class UispUploader extends Uploader {
|
|||||||
return burnBootloader(commandDownloader);
|
return burnBootloader(commandDownloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean burnBootloaderParallel() throws RunnerException {
|
public boolean burnBootloaderParallel(String target) throws RunnerException {
|
||||||
List commandDownloader = new ArrayList();
|
List commandDownloader = new ArrayList();
|
||||||
commandDownloader.add("-dprog=dapa");
|
commandDownloader.add("-dprog=dapa");
|
||||||
commandDownloader.add("-dlpt=" + Preferences.get("parallel.port"));
|
commandDownloader.add("-dlpt=" + Preferences.get("parallel.port"));
|
||||||
|
@ -58,9 +58,9 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
public abstract boolean uploadUsingPreferences(String buildPath, String className)
|
public abstract boolean uploadUsingPreferences(String buildPath, String className)
|
||||||
throws RunnerException;
|
throws RunnerException;
|
||||||
|
|
||||||
public abstract boolean burnBootloaderAVRISP() throws RunnerException;
|
public abstract boolean burnBootloaderAVRISP(String target) throws RunnerException;
|
||||||
|
|
||||||
public abstract boolean burnBootloaderParallel() throws RunnerException;
|
public abstract boolean burnBootloaderParallel(String target) throws RunnerException;
|
||||||
|
|
||||||
protected void flushSerialBuffer() {
|
protected void flushSerialBuffer() {
|
||||||
// Cleanup the serial buffer
|
// Cleanup the serial buffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user