Add forced full erase to STM32F7 firmware update

This commit is contained in:
Matthew Kennedy 2023-05-05 16:20:28 -07:00
parent fd98124304
commit a53b09c01e
1 changed files with 31 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import com.rusefi.Launcher;
import com.rusefi.Timeouts;
import com.rusefi.autodetect.PortDetector;
import com.rusefi.autodetect.SerialAutoChecker;
import com.rusefi.core.io.BundleUtil;
import com.rusefi.io.DfuHelper;
import com.rusefi.io.IoStream;
import com.rusefi.io.serial.BufferedSerialIoStream;
@ -44,6 +45,18 @@ public class DfuFlasher {
StatusWindow wnd = createStatusWindow();
boolean needsEraseFirst = false;
if (BundleUtil.getBundleTarget().contains("f7")) {
int result = JOptionPane.showConfirmDialog(parent, "Firmware update requires a full erase of the ECU. If your tune is not saved in TunerStudio, it will be lost.\nEnsure that TunerStudio has your current tune saved!\n\nAfter updating, re-connect TunerStudio to restore your tune.\n\nPress OK to continue with the update, or Cancel to abort so you can save your tune.", "WARNING", JOptionPane.OK_CANCEL_OPTION);
// 0 means they clicked "OK", 1 means they clicked "Cancel"
if (result != 0) {
return;
}
needsEraseFirst = true;
}
AtomicBoolean isSignatureValidated = rebootToDfu(parent, port, wnd);
if (isSignatureValidated == null)
return;
@ -53,9 +66,11 @@ public class DfuFlasher {
wnd.append("FOME console can only program on Windows");
return;
}
boolean finalNeedsEraseFirst = needsEraseFirst;
submitAction(() -> {
timeForDfuSwitch(wnd);
executeDFU(wnd);
executeDFU(wnd, finalNeedsEraseFirst);
});
} else {
wnd.append("Please use manual DFU to change bundle type.");
@ -119,20 +134,24 @@ public class DfuFlasher {
public static void runDfuErase() {
StatusWindow wnd = createStatusWindow();
submitAction(() -> {
ExecHelper.executeCommand(DFU_BINARY_LOCATION,
getDfuEraseCommand(),
DFU_BINARY, wnd, new StringBuffer());
runDfuErase(wnd);
// it's a lengthy operation let's signal end
Toolkit.getDefaultToolkit().beep();
});
}
public static void runDfuProgramming() {
StatusWindow wnd = createStatusWindow();
submitAction(() -> executeDFU(wnd));
private static void runDfuErase(StatusWindow wnd) {
ExecHelper.executeCommand(DFU_BINARY_LOCATION,
getDfuEraseCommand(),
DFU_BINARY, wnd, new StringBuffer());
}
private static void executeDFU(StatusWindow wnd) {
public static void runDfuProgramming() {
StatusWindow wnd = createStatusWindow();
submitAction(() -> executeDFU(wnd, false));
}
private static void executeDFU(StatusWindow wnd, boolean fullErase) {
boolean driverIsHappy = detectSTM32BootloaderDriverState(wnd);
if (!driverIsHappy) {
wnd.append("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of FOME console start screen?");
@ -140,6 +159,10 @@ public class DfuFlasher {
return;
}
if (fullErase) {
runDfuErase(wnd);
}
StringBuffer stdout = new StringBuffer();
String errorResponse;
try {