Initial addition of stm32f407 uploads

VERY rough, but functional. Only tested on Mac, but in theory should work on Windows and linux (i686, x64, arm/arm64)
This commit is contained in:
Josh Stewart 2024-02-12 17:44:45 +11:00
parent ab1364436c
commit ce49bec4a3
28 changed files with 176 additions and 3 deletions

BIN
bin/dfuutil-aarch64/dfu-prefix Executable file

Binary file not shown.

BIN
bin/dfuutil-aarch64/dfu-suffix Executable file

Binary file not shown.

BIN
bin/dfuutil-aarch64/dfu-util Executable file

Binary file not shown.

BIN
bin/dfuutil-armhf/dfu-prefix Executable file

Binary file not shown.

BIN
bin/dfuutil-armhf/dfu-suffix Executable file

Binary file not shown.

BIN
bin/dfuutil-armhf/dfu-util Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/dfuutil-linux-i686/dfu-prefix Executable file

Binary file not shown.

BIN
bin/dfuutil-linux-i686/dfu-suffix Executable file

Binary file not shown.

BIN
bin/dfuutil-linux-i686/dfu-util Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/dfuutil-linux-x86_64/dfu-util Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/dfuutil-windows/dfu-util.exe Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,41 @@
# libusb-1.0.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-14
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='../bin/libusb-1.0.dll'
# Names of this library.
library_names='libusb-1.0.dll.a'
# The name of the static archive.
old_library='libusb-1.0.a'
# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libusb-1.0.
current=3
age=3
revision=0
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/media/tormod/4c35d599-6799-49e1-93de-6e7a1139613f/home/tormod/MAINT/dfu-util/mingw/libusb-git/../build-win32/lib'

Binary file not shown.

BIN
bin/dfuutil-windows/lsusb.exe Executable file

Binary file not shown.

94
main.js
View File

@ -11,7 +11,9 @@ let win
var avrdudeErr = "";
var avrdudeIsRunning = false;
var teensyLoaderIsRunning = false;
var dfuutilIsRunning = false;
var teensyLoaderErr = ""
var dfuutilErr = ""
function createWindow ()
{
@ -233,6 +235,92 @@ ipcMain.on('uploadFW', (e, args) => {
}
});
});
ipcMain.on("uploadFW_stm32", (e, args) => {
//"dfu-util" -d 0x0483:0xDF11 -a 0 -s 0x08000000:leave -D"
if(dfuutilIsRunning == true) { return; }
dfuutilIsRunning = true; //Indicate that an avrdude process has started
var platform;
var burnStarted = false;
//All Windows builds use the 32-bit binary
if(process.platform == "win32")
{
platform = "dfuutil-windows";
}
//All Mac builds use the 64-bit binary
else if(process.platform == "darwin")
{
platform = "dfuutil-darwin-x86_64";
}
else if(process.platform == "linux")
{
if(process.arch == "x32") { platform = "dfuutil-linux-i686"; }
else if(process.arch == "x64") { platform = "dfuutil-linux-x86_64"; }
else if(process.arch == "arm") { platform = "dfuutil-armhf"; }
else if(process.arch == "arm64") { platform = "dfuutil-aarch64"; }
}
var executableName = __dirname + "/bin/" + platform + "/dfu-util";
executableName = executableName.replace('app.asar',''); //This is important for allowing the binary to be found once the app is packaed into an asar
//console.log(executableName);
var execArgs = ['-d', '0x0483:0xDF11', '-a', '0', '-s', '0x08000000:leave', '-D', args.firmwareFile];
//console.log(execArgs);
if(process.platform == "win32") { executableName = executableName + '.exe'; } //This must come after the configName line above
console.log(executableName);
const child = execFile(executableName, execArgs);
child.stdout.on('data', (data) => {
console.log(`dfu-util stdout:\n${data}`);
});
child.stderr.on('data', (data) => {
console.log(`dfu-util stderr: ${data}`);
dfuutilErr = dfuutilErr + data;
//Check if avrdude has started the actual burn yet, and if so, track the '#' characters that it prints. Each '#' represents 1% of the total burn process (50 for write and 50 for read)
if (burnStarted == true)
{
if(data=="#") { burnPercent += 1; }
e.sender.send( "upload percent", burnPercent );
}
else
{
//This is a hack, but basically watch the output from teensy loader for the term 'Writing | ', everything after that is the #s indicating 1% of burn.
if(dfuutilErr.includes("Erase done."))
{
burnStarted = true;
}
}
});
child.on('error', (err) =>
{
console.log('Failed to start subprocess.');
console.log(err);
dfuutilIsRunning = false;
});
child.on('close', (code) =>
{
dfuutilIsRunning = false;
if (code !== 0)
{
console.log(`dfu-util process exited with code ${code}`);
e.sender.send( "upload error", dfuutilErr )
teensyLoaderErr = "";
}
else
{
e.sender.send( "upload completed", code )
}
});
});
ipcMain.on('uploadFW_teensy', (e, args) => {
@ -300,13 +388,15 @@ ipcMain.on('uploadFW', (e, args) => {
});
child.on('error', (err) => {
child.on('error', (err) =>
{
console.log('Failed to start subprocess.');
console.log(err);
teensyLoaderIsRunning = false;
});
child.on('close', (code) => {
child.on('close', (code) =>
{
teensyLoaderIsRunning = false;
if (code !== 0)
{

View File

@ -85,6 +85,13 @@ function refreshSerialPorts()
newOption.innerHTML = newOption.innerHTML + " (Arduino Mega CH340)";
newOption.setAttribute("board", "ATMEGA2560");
}
else if(ports[i].vendorId == "0483" && ports[i].productId == "5740")
{
//STM32F407
newOption.innerHTML = newOption.innerHTML + " (STM32F407 - Serial Mode)";
newOption.setAttribute("board", "STM32F407_serial");
console.log(ports[i].productId)
}
else
{
//Unknown device, assume it's a mega2560
@ -108,6 +115,28 @@ function refreshSerialPorts()
newOption.setAttribute("board", "TEENSY"+teensyVersion);
select.add(newOption);
})
//Look for any STM32 devices in DFU mode
var uninitialisedTeensyDevices = usb.getDeviceList().filter( function(d) {
return d.deviceDescriptor.idVendor===0x0483 && d.deviceDescriptor.bcdDevice===0x2200; //Interface class 3 is HID
});
uninitialisedTeensyDevices.forEach((device, index) => {
console.log("STM32 in DFU mode found: ", getTeensyVersion(device.deviceDescriptor.bcdDevice))
var newOption = document.createElement('option');
newOption.value = "STM32F407_DFU";
var teensyVersion = getTeensyVersion(device.deviceDescriptor.bcdDevice);
newOption.innerHTML = "STM32F407 in DFU mode";
teensyVersion = teensyVersion.replace(".", "");
newOption.setAttribute("board", "STM32F407_DFU");
select.add(newOption);
})
/*
for(x=0; x<usb.getDeviceList().length; x++)
{
console.log("Vendor: " + usb.getDeviceList()[x].deviceDescriptor.idVendor + " Device Descriptor: " + usb.getDeviceList()[x].deviceDescriptor.bcdDevice);
}
*/
var button = document.getElementById("btnInstall")
if(ports.length > 0)
@ -424,6 +453,10 @@ function downloadHex(board, localFile="")
DLurl = "http://speeduino.com/fw/bin/" + e.options[e.selectedIndex].value + ".hex";
console.log("Downloading AVR firmware: " + DLurl);
break;
case "STM32F407_DFU":
DLurl = "http://speeduino.com/fw/stm32f407/" + e.options[e.selectedIndex].value + "-stm32f407.bin";
console.log("Downloading STM32F407 firmware: " + DLurl);
break;
default:
DLurl = "http://speeduino.com/fw/bin/" + e.options[e.selectedIndex].value + ".hex";
console.log("Downloading AVR firmware: " + DLurl);
@ -526,7 +559,7 @@ function uploadFW()
document.getElementById('iniFileLocation').innerHTML = file
downloadHex(uploadBoard);
}
else if(extension == "hex")
else if(extension == "hex" || extension == "bin")
{
console.log("Uploading da file!!");
statusText.innerHTML = "Beginning upload..."
@ -550,6 +583,15 @@ function uploadFW()
board: uploadBoard
});
}
else if(uploadBoard.includes("STM32F407"))
{
console.log("Uploading using DFU Util")
ipcRenderer.send("uploadFW_stm32", {
port: uploadPort,
firmwareFile: file,
board: uploadBoard
});
}
else
{
ipcRenderer.send("uploadFW", {