New dfu (#3392)
* Better Windows build-in DFU #3338 * Better Windows build-in DFU #3338 some time to read from dead process, also TOOLS_PATH support * Better Windows build-in DFU #3338 Co-authored-by: rusefillc <sdfsdfqsf2334234234>
This commit is contained in:
parent
5eeded86c2
commit
36ba375a94
|
@ -10,7 +10,6 @@ import com.rusefi.io.DfuHelper;
|
|||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
@ -25,8 +24,8 @@ import static com.rusefi.StartupFrame.appendBundleName;
|
|||
* @see FirmwareFlasher
|
||||
*/
|
||||
public class DfuFlasher {
|
||||
private static final String DFU_BINARY = Launcher.TOOLS_PATH + File.separator + "DfuSe/DfuSeCommand.exe";
|
||||
private static final String DFU_SETUP_EXE = "https://github.com/rusefi/rusefi_external_utils/raw/master/DFU_mode/DfuSe_Demo_V3.0.6_Setup.exe";
|
||||
private static final String DFU_BINARY_LOCATION = Launcher.TOOLS_PATH + File.separator + "STM32_Programmer_CLI/bin";
|
||||
private static final String DFU_BINARY = "STM32_Programmer_CLI.exe";
|
||||
|
||||
public static void doAutoDfu(Object selectedItem, JComponent parent) {
|
||||
if (selectedItem == null) {
|
||||
|
@ -96,42 +95,15 @@ public class DfuFlasher {
|
|||
}
|
||||
|
||||
private static void executeDFU(StatusWindow wnd) {
|
||||
AtomicBoolean errorReported = new AtomicBoolean();
|
||||
StringBuffer stdout = new StringBuffer();
|
||||
String errorResponse = ExecHelper.executeCommand(FirmwareFlasher.BINARY_LOCATION,
|
||||
FirmwareFlasher.BINARY_LOCATION + File.separator + getDfuCommand(),
|
||||
DFU_BINARY, s -> {
|
||||
if (s.contains("0x12340005") && errorReported.compareAndSet(false, true)) {
|
||||
wnd.appendMsg(" ***************");
|
||||
wnd.appendMsg(" ***************");
|
||||
wnd.appendMsg("ERROR: Maybe DFU device not attached? Please check Device Manager.");
|
||||
wnd.appendMsg("ERROR: Maybe ST DFU Driver is missing?");
|
||||
wnd.appendMsg("ERROR: Maybe driver conflict with STM32Cube?");
|
||||
wnd.appendMsg("ERROR: Reminder about 'Install Drivers' button on top of rusEFI splash screen");
|
||||
wnd.appendMsg(System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
|
||||
wnd.appendMsg(" ***************");
|
||||
wnd.appendMsg(" ***************");
|
||||
}
|
||||
wnd.appendMsg(s);
|
||||
}, stdout);
|
||||
if (stdout.toString().contains("Matching not good")) {
|
||||
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
||||
wnd.appendMsg("VERIFICATION ERROR maybe nDBANK issue?");
|
||||
wnd.appendMsg("https://github.com/rusefi/rusefi/wiki/HOWTO-nDBANK");
|
||||
} else if (stdout.toString().contains("Verify successful") || stdout.toString().contains("Upgrade successful")) {
|
||||
String errorResponse = ExecHelper.executeCommand(DFU_BINARY_LOCATION,
|
||||
getDfuCommand(),
|
||||
DFU_BINARY, wnd, stdout);
|
||||
if (stdout.toString().contains("Download verified successfully")) {
|
||||
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
||||
wnd.appendMsg("SUCCESS!");
|
||||
} else {
|
||||
if (stdout.length() == 0 && errorResponse.length() == 0) {
|
||||
// looks like DFU util is not installed properly?
|
||||
// ugly temporary solution
|
||||
// see https://github.com/rusefi/rusefi/issues/1170
|
||||
// see https://github.com/rusefi/rusefi/issues/1182
|
||||
URLLabel.open(DFU_SETUP_EXE);
|
||||
wnd.appendMsg("Please install DfuSe_Demo_V3.0.6_Setup.exe, power cycle your device and try again.");
|
||||
} else {
|
||||
wnd.appendMsg(stdout.length() + " / " + errorResponse.length());
|
||||
}
|
||||
wnd.appendMsg(stdout.length() + " / " + errorResponse.length());
|
||||
wnd.appendMsg("ERROR: does not look like DFU has worked!");
|
||||
}
|
||||
wnd.appendMsg("Please power cycle device to exit DFU mode");
|
||||
|
@ -147,8 +119,11 @@ public class DfuFlasher {
|
|||
}
|
||||
|
||||
private static String getDfuCommand() {
|
||||
String fileName = IniFileModel.findFile(Launcher.INPUT_FILES_PATH, "rusefi", ".dfu");
|
||||
String fileName = IniFileModel.findFile(Launcher.INPUT_FILES_PATH, "rusefi", ".hex");
|
||||
if (fileName == null)
|
||||
return "File not found";
|
||||
String absolutePath = new File(fileName).getAbsolutePath();
|
||||
|
||||
return DFU_BINARY + " -c -d --v --fn " + fileName;
|
||||
return DFU_BINARY_LOCATION + "/" + DFU_BINARY + " -c port=usb1 -w " + absolutePath + " -v -s";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ import java.io.File;
|
|||
|
||||
/**
|
||||
* This code automates drivers unpacking and installation
|
||||
* Both Virtual Comport and ST-Link drivers are installed
|
||||
* new, DFU Virtual Comport and ST-Link drivers are installed
|
||||
* <p>
|
||||
* See https://github.com/rusefi/rusefi/tree/master/misc/install_st
|
||||
*/
|
||||
public class DriverInstall {
|
||||
private static final String FOLDER = "../drivers";
|
||||
private static final String ARCHIVE = "silent_st_drivers.exe";
|
||||
private static final String ARCHIVE = "silent_st_drivers2.exe";
|
||||
private static final String YES = " -y";
|
||||
private static final String UNPACKED_FOLDER = FOLDER + File.separator + "silent_st_drivers";
|
||||
private static final String WINDOWS7_BATCH = "silent_install_windows7.bat";
|
||||
|
@ -34,7 +34,7 @@ public class DriverInstall {
|
|||
return;
|
||||
|
||||
final StatusWindow wnd = new StatusWindow();
|
||||
wnd.showFrame("Windows rusEfi ST Drivers");
|
||||
wnd.showFrame("Windows rusEFI ST Drivers");
|
||||
|
||||
ExecHelper.submitAction(() -> installDrivers(wnd), getClass() + " thread");
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.ui.StatusConsumer;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +29,7 @@ public class ExecHelper {
|
|||
private static void startStreamThread(final Process p, final InputStream stream, final StringBuffer buffer, final StatusConsumer wnd) {
|
||||
final Thread t = new Thread(() -> {
|
||||
try {
|
||||
BufferedReader bis = new BufferedReader(new InputStreamReader(stream));
|
||||
BufferedReader bis = new BufferedReader(new InputStreamReader(stream, StandardCharsets.ISO_8859_1));
|
||||
/*
|
||||
* Sometimes process has already finished but we still want to read output, so give it extra half a second
|
||||
* TODO: are we supposed to just NOT check process status and just wait for 'null' from readLine?
|
||||
|
|
|
@ -24,7 +24,7 @@ public class FirmwareFlasher {
|
|||
*/
|
||||
private static final String OPENOCD_EXE = Launcher.TOOLS_PATH + File.separator + "openocd/openocd.exe";
|
||||
// todo: combine this with Launcher#TOOLS_PATH?
|
||||
static final String BINARY_LOCATION = ".";
|
||||
private static final String OPENOCD_BINARY_LOCATION = ".";
|
||||
private static final String SUCCESS_MESSAGE_TAG = "shutdown command invoked";
|
||||
private static final String FAILED_MESSAGE_TAG = "failed";
|
||||
private static final String NO_DRIVER_MESSAGE_TAG = "failed with LIBUSB_ERROR_NOT_SUPPORTED";
|
||||
|
@ -57,8 +57,8 @@ public class FirmwareFlasher {
|
|||
}
|
||||
|
||||
protected static String executeOpenOCDCommand(String command, StatusWindow wnd) {
|
||||
return ExecHelper.executeCommand(BINARY_LOCATION,
|
||||
BINARY_LOCATION + File.separator + command,
|
||||
return ExecHelper.executeCommand(OPENOCD_BINARY_LOCATION,
|
||||
OPENOCD_BINARY_LOCATION + File.separator + command,
|
||||
OPENOCD_EXE, wnd);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,9 @@ public class StatusWindow implements StatusConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendMsg(final String s) {
|
||||
public void appendMsg(final String string) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
String s = string.replaceAll(Character.toString((char)219), "");
|
||||
FileLog.MAIN.logLine(s);
|
||||
logTextArea.append(s + "\r\n");
|
||||
UiUtils.trueLayout(logTextArea);
|
||||
|
|
|
@ -1,4 +1,34 @@
|
|||
@echo off
|
||||
|
||||
:: BatchGotAdmin
|
||||
:-------------------------------------
|
||||
REM --> Check for permissions
|
||||
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
|
||||
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
|
||||
) ELSE (
|
||||
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
|
||||
)
|
||||
|
||||
REM --> If error flag set, we do not have admin.
|
||||
if '%errorlevel%' NEQ '0' (
|
||||
echo Requesting administrative privileges...
|
||||
goto UACPrompt
|
||||
) else ( goto gotAdmin )
|
||||
|
||||
:UACPrompt
|
||||
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
|
||||
set params= %*
|
||||
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
|
||||
|
||||
"%temp%\getadmin.vbs"
|
||||
del "%temp%\getadmin.vbs"
|
||||
exit /B
|
||||
|
||||
:gotAdmin
|
||||
pushd "%CD%"
|
||||
CD /D "%~dp0"
|
||||
:--------------------------------------
|
||||
|
||||
cd "Virtual comport driver"
|
||||
cd Win7
|
||||
|
||||
|
@ -27,5 +57,12 @@ goto ST_END
|
|||
start "" dpinst_amd64.exe /sw
|
||||
:ST_END
|
||||
|
||||
cd ..
|
||||
echo Done installing ST-Link silently
|
||||
pwd
|
||||
|
||||
cd DFU_Driver
|
||||
STM32Bootloader.bat
|
||||
cd ..
|
||||
|
||||
exit
|
|
@ -1,4 +1,34 @@
|
|||
@echo off
|
||||
|
||||
:: BatchGotAdmin
|
||||
:-------------------------------------
|
||||
REM --> Check for permissions
|
||||
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
|
||||
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
|
||||
) ELSE (
|
||||
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
|
||||
)
|
||||
|
||||
REM --> If error flag set, we do not have admin.
|
||||
if '%errorlevel%' NEQ '0' (
|
||||
echo Requesting administrative privileges...
|
||||
goto UACPrompt
|
||||
) else ( goto gotAdmin )
|
||||
|
||||
:UACPrompt
|
||||
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
|
||||
set params= %*
|
||||
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
|
||||
|
||||
"%temp%\getadmin.vbs"
|
||||
del "%temp%\getadmin.vbs"
|
||||
exit /B
|
||||
|
||||
:gotAdmin
|
||||
pushd "%CD%"
|
||||
CD /D "%~dp0"
|
||||
:--------------------------------------
|
||||
|
||||
cd "Virtual comport driver"
|
||||
cd Win8
|
||||
|
||||
|
@ -27,5 +57,12 @@ goto ST_END
|
|||
start "" dpinst_amd64.exe /sw
|
||||
:ST_END
|
||||
|
||||
cd ..
|
||||
echo Done installing ST-Link silently
|
||||
pwd
|
||||
|
||||
cd DFU_Driver
|
||||
STM32Bootloader.bat
|
||||
cd ..
|
||||
|
||||
exit
|
|
@ -27,8 +27,8 @@ mkdir $CONSOLE_FOLDER
|
|||
mkdir $DRIVERS_FOLDER
|
||||
ls -l $FOLDER
|
||||
|
||||
wget https://rusefi.com/build_server/st_files/silent_st_drivers.exe -P $DRIVERS_FOLDER
|
||||
[ -e $DRIVERS_FOLDER/silent_st_drivers.exe ] || { echo "$SCRIPT_NAME: ERROR DOWNLOADING silent_st_drivers.exe"; exit 1; }
|
||||
wget https://rusefi.com/build_server/st_files/silent_st_drivers2.exe -P $DRIVERS_FOLDER
|
||||
[ -e $DRIVERS_FOLDER/silent_st_drivers2.exe ] || { echo "$SCRIPT_NAME: ERROR DOWNLOADING silent_st_drivers2.exe"; exit 1; }
|
||||
|
||||
if [ "$INI_FILE_OVERRIDE" = "no" ]; then
|
||||
INI_FILE_OVERRIDE="rusefi.ini"
|
||||
|
|
Loading…
Reference in New Issue