manual DFU mode

This commit is contained in:
rusEfi 2019-08-31 20:17:32 -04:00
parent 47bbd6ebe4
commit 32b08332b7
2 changed files with 25 additions and 7 deletions

View File

@ -149,7 +149,8 @@ public class StartupFrame {
if (FileLog.isWindows()) { if (FileLog.isWindows()) {
realHardwarePanel.add(new HorizontalLine()); realHardwarePanel.add(new HorizontalLine());
realHardwarePanel.add(new DfuFlasher(comboPorts).getButton()); realHardwarePanel.add(new DfuFlasher(comboPorts).getAutoButton());
realHardwarePanel.add(new DfuFlasher(comboPorts).getManualButton());
// for F7 builds we just build one file at the moment // for F7 builds we just build one file at the moment
realHardwarePanel.add(new FirmwareFlasher(FirmwareFlasher.IMAGE_FILE, "ST-LINK Program Firmware", "Default firmware version for most users").getButton()); realHardwarePanel.add(new FirmwareFlasher(FirmwareFlasher.IMAGE_FILE, "ST-LINK Program Firmware", "Default firmware version for most users").getButton());
if (new File(FirmwareFlasher.IMAGE_NO_ASSERTS_FILE).exists()) { if (new File(FirmwareFlasher.IMAGE_NO_ASSERTS_FILE).exists()) {

View File

@ -27,7 +27,8 @@ public class DfuFlasher {
static final String DFU_COMMAND = DFU_BINARY + " -c -d --v --fn " + Launcher.INPUT_FILES_PATH + File.separator + static final String DFU_COMMAND = DFU_BINARY + " -c -d --v --fn " + Launcher.INPUT_FILES_PATH + File.separator +
"rusefi.dfu"; "rusefi.dfu";
private final JButton button = new JButton("Program via DFU"); private final JButton button = new JButton("Auto Program via DFU");
private final JButton manualButton = new JButton("Manual Program via DFU");
public DfuFlasher(JComboBox<String> comboPorts) { public DfuFlasher(JComboBox<String> comboPorts) {
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@ -35,8 +36,10 @@ public class DfuFlasher {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
String port = comboPorts.getSelectedItem().toString(); String port = comboPorts.getSelectedItem().toString();
port = PortDetector.autoDetectSerialIfNeeded(port); port = PortDetector.autoDetectSerialIfNeeded(port);
if (port == null) if (port == null) {
JOptionPane.showMessageDialog(Launcher.getFrame(), "rusEfi serial port not detected");
return; return;
}
IoStream stream = SerialIoStreamJSerialComm.open(port, PortHolder.BAUD_RATE, FileLog.LOGGER); IoStream stream = SerialIoStreamJSerialComm.open(port, PortHolder.BAUD_RATE, FileLog.LOGGER);
byte[] command = BinaryProtocol.getTextCommandBytes(Fields.CMD_REBOOT_DFU); byte[] command = BinaryProtocol.getTextCommandBytes(Fields.CMD_REBOOT_DFU);
try { try {
@ -46,12 +49,18 @@ public class DfuFlasher {
e.printStackTrace(); e.printStackTrace();
} }
runDfuProgramming();
}
});
manualButton.addActionListener(e -> runDfuProgramming());
}
private void runDfuProgramming() {
StatusWindow wnd = new StatusWindow(); StatusWindow wnd = new StatusWindow();
wnd.showFrame("DFU status"); wnd.showFrame("DFU status");
ExecHelper.submitAction(() -> executeDFU(wnd), getClass() + " thread"); ExecHelper.submitAction(() -> executeDFU(wnd), getClass() + " thread");
} }
});
}
private void executeDFU(StatusWindow wnd) { private void executeDFU(StatusWindow wnd) {
wnd.appendMsg("Giving time for USB enumeration..."); wnd.appendMsg("Giving time for USB enumeration...");
@ -66,7 +75,15 @@ public class DfuFlasher {
wnd.appendMsg("Please power cycle device to exit DFU mode"); wnd.appendMsg("Please power cycle device to exit DFU mode");
} }
public Component getButton() { /**
* connect via serial + initiate software DFU jump + program
*/
public Component getAutoButton() {
return button; return button;
} }
// todo: maybe not couple these two different buttons in same class?
public Component getManualButton() {
return manualButton;
}
} }