rusEFI console to has "Erase via DFU" button #2250
This commit is contained in:
parent
44754607ef
commit
61849c6da7
|
@ -6,7 +6,7 @@ import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20211122;
|
public static final int CONSOLE_VERSION = 20211123;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static long classBuildTimeMillis() {
|
public static long classBuildTimeMillis() {
|
||||||
|
|
|
@ -52,15 +52,19 @@ public class DfuFlasher {
|
||||||
wnd.appendMsg("rusEFI console can only program on Windows");
|
wnd.appendMsg("rusEFI console can only program on Windows");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ExecHelper.submitAction(() -> {
|
submitAction(() -> {
|
||||||
timeForDfuSwitch(wnd);
|
timeForDfuSwitch(wnd);
|
||||||
executeDFU(wnd);
|
executeDFU(wnd);
|
||||||
}, DfuFlasher.class + " thread");
|
});
|
||||||
} else {
|
} else {
|
||||||
wnd.appendMsg("Please use manual DFU to change bundle type.");
|
wnd.appendMsg("Please use manual DFU to change bundle type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void submitAction(Runnable r) {
|
||||||
|
ExecHelper.submitAction(r, DfuFlasher.class + " thread");
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static AtomicBoolean rebootToDfu(JComponent parent, String port, StatusWindow wnd) {
|
public static AtomicBoolean rebootToDfu(JComponent parent, String port, StatusWindow wnd) {
|
||||||
AtomicBoolean isSignatureValidated = new AtomicBoolean(true);
|
AtomicBoolean isSignatureValidated = new AtomicBoolean(true);
|
||||||
|
@ -108,15 +112,22 @@ public class DfuFlasher {
|
||||||
return wnd;
|
return wnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void runDfuErase() {
|
||||||
|
StatusWindow wnd = createStatusWindow();
|
||||||
|
submitAction(() -> ExecHelper.executeCommand(DFU_BINARY_LOCATION,
|
||||||
|
getDfuEraseCommand(),
|
||||||
|
DFU_BINARY, wnd, new StringBuffer()));
|
||||||
|
}
|
||||||
|
|
||||||
public static void runDfuProgramming() {
|
public static void runDfuProgramming() {
|
||||||
StatusWindow wnd = createStatusWindow();
|
StatusWindow wnd = createStatusWindow();
|
||||||
ExecHelper.submitAction(() -> executeDFU(wnd), DfuFlasher.class + " thread");
|
submitAction(() -> executeDFU(wnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void executeDFU(StatusWindow wnd) {
|
private static void executeDFU(StatusWindow wnd) {
|
||||||
StringBuffer stdout = new StringBuffer();
|
StringBuffer stdout = new StringBuffer();
|
||||||
String errorResponse = ExecHelper.executeCommand(DFU_BINARY_LOCATION,
|
String errorResponse = ExecHelper.executeCommand(DFU_BINARY_LOCATION,
|
||||||
getDfuCommand(),
|
getDfuWriteCommand(),
|
||||||
DFU_BINARY, wnd, stdout);
|
DFU_BINARY, wnd, stdout);
|
||||||
if (stdout.toString().contains("Download verified successfully")) {
|
if (stdout.toString().contains("Download verified successfully")) {
|
||||||
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
||||||
|
@ -157,13 +168,17 @@ public class DfuFlasher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDfuCommand() {
|
private static String getDfuWriteCommand() {
|
||||||
String fileName = IniFileModel.findFile(Launcher.INPUT_FILES_PATH, "rusefi", ".hex");
|
String hexFileName = IniFileModel.findFile(Launcher.INPUT_FILES_PATH, "rusefi", ".hex");
|
||||||
if (fileName == null)
|
if (hexFileName == null)
|
||||||
return "File not found";
|
return "File not found";
|
||||||
String absolutePath = new File(fileName).getAbsolutePath();
|
String hexAbsolutePath = new File(hexFileName).getAbsolutePath();
|
||||||
|
|
||||||
return DFU_BINARY_LOCATION + "/" + DFU_BINARY + " -c port=usb1 -w " + absolutePath + " -v -s";
|
return DFU_BINARY_LOCATION + "/" + DFU_BINARY + " -c port=usb1 -w " + hexAbsolutePath + " -v -s";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getDfuEraseCommand() {
|
||||||
|
return DFU_BINARY_LOCATION + "/" + DFU_BINARY + " -c port=usb1 -e all";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|
|
@ -70,6 +70,8 @@ public class ProgramSelector {
|
||||||
Object selected = comboPorts.getSelectedItem();
|
Object selected = comboPorts.getSelectedItem();
|
||||||
String port = selected == null ? PortDetector.AUTO : selected.toString();
|
String port = selected == null ? PortDetector.AUTO : selected.toString();
|
||||||
DfuFlasher.rebootToDfu(comboPorts, port, wnd);
|
DfuFlasher.rebootToDfu(comboPorts, port, wnd);
|
||||||
|
} else if (selectedMode.equals(DFU_ERASE)) {
|
||||||
|
DfuFlasher.runDfuErase();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("How did you " + selectedMode);
|
throw new IllegalArgumentException("How did you " + selectedMode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue