diff --git a/bin/dfuutil-aarch64/dfu-prefix b/bin/dfuutil-aarch64/dfu-prefix new file mode 100755 index 0000000..2f910e9 Binary files /dev/null and b/bin/dfuutil-aarch64/dfu-prefix differ diff --git a/bin/dfuutil-aarch64/dfu-suffix b/bin/dfuutil-aarch64/dfu-suffix new file mode 100755 index 0000000..33c37bd Binary files /dev/null and b/bin/dfuutil-aarch64/dfu-suffix differ diff --git a/bin/dfuutil-aarch64/dfu-util b/bin/dfuutil-aarch64/dfu-util new file mode 100755 index 0000000..195127c Binary files /dev/null and b/bin/dfuutil-aarch64/dfu-util differ diff --git a/bin/dfuutil-armhf/dfu-prefix b/bin/dfuutil-armhf/dfu-prefix new file mode 100755 index 0000000..2f910e9 Binary files /dev/null and b/bin/dfuutil-armhf/dfu-prefix differ diff --git a/bin/dfuutil-armhf/dfu-suffix b/bin/dfuutil-armhf/dfu-suffix new file mode 100755 index 0000000..33c37bd Binary files /dev/null and b/bin/dfuutil-armhf/dfu-suffix differ diff --git a/bin/dfuutil-armhf/dfu-util b/bin/dfuutil-armhf/dfu-util new file mode 100755 index 0000000..195127c Binary files /dev/null and b/bin/dfuutil-armhf/dfu-util differ diff --git a/bin/dfuutil-darwin-x86_64/dfu-prefix b/bin/dfuutil-darwin-x86_64/dfu-prefix new file mode 100755 index 0000000..3d7a4ec Binary files /dev/null and b/bin/dfuutil-darwin-x86_64/dfu-prefix differ diff --git a/bin/dfuutil-darwin-x86_64/dfu-suffix b/bin/dfuutil-darwin-x86_64/dfu-suffix new file mode 100755 index 0000000..ecc2b35 Binary files /dev/null and b/bin/dfuutil-darwin-x86_64/dfu-suffix differ diff --git a/bin/dfuutil-darwin-x86_64/dfu-util b/bin/dfuutil-darwin-x86_64/dfu-util new file mode 100755 index 0000000..d2785cf Binary files /dev/null and b/bin/dfuutil-darwin-x86_64/dfu-util differ diff --git a/bin/dfuutil-linux-i686/dfu-prefix b/bin/dfuutil-linux-i686/dfu-prefix new file mode 100755 index 0000000..3c3bf51 Binary files /dev/null and b/bin/dfuutil-linux-i686/dfu-prefix differ diff --git a/bin/dfuutil-linux-i686/dfu-suffix b/bin/dfuutil-linux-i686/dfu-suffix new file mode 100755 index 0000000..5da9f8d Binary files /dev/null and b/bin/dfuutil-linux-i686/dfu-suffix differ diff --git a/bin/dfuutil-linux-i686/dfu-util b/bin/dfuutil-linux-i686/dfu-util new file mode 100755 index 0000000..86ac4d5 Binary files /dev/null and b/bin/dfuutil-linux-i686/dfu-util differ diff --git a/bin/dfuutil-linux-x86_64/dfu-prefix b/bin/dfuutil-linux-x86_64/dfu-prefix new file mode 100755 index 0000000..277dcec Binary files /dev/null and b/bin/dfuutil-linux-x86_64/dfu-prefix differ diff --git a/bin/dfuutil-linux-x86_64/dfu-suffix b/bin/dfuutil-linux-x86_64/dfu-suffix new file mode 100755 index 0000000..8a53374 Binary files /dev/null and b/bin/dfuutil-linux-x86_64/dfu-suffix differ diff --git a/bin/dfuutil-linux-x86_64/dfu-util b/bin/dfuutil-linux-x86_64/dfu-util new file mode 100755 index 0000000..aa46ecc Binary files /dev/null and b/bin/dfuutil-linux-x86_64/dfu-util differ diff --git a/bin/dfuutil-linux-x86_64/dfu-util-static b/bin/dfuutil-linux-x86_64/dfu-util-static new file mode 100755 index 0000000..5d37a97 Binary files /dev/null and b/bin/dfuutil-linux-x86_64/dfu-util-static differ diff --git a/bin/dfuutil-windows/dfu-prefix.exe b/bin/dfuutil-windows/dfu-prefix.exe new file mode 100755 index 0000000..2367422 Binary files /dev/null and b/bin/dfuutil-windows/dfu-prefix.exe differ diff --git a/bin/dfuutil-windows/dfu-suffix.exe b/bin/dfuutil-windows/dfu-suffix.exe new file mode 100755 index 0000000..23a8208 Binary files /dev/null and b/bin/dfuutil-windows/dfu-suffix.exe differ diff --git a/bin/dfuutil-windows/dfu-util-static.exe b/bin/dfuutil-windows/dfu-util-static.exe new file mode 100755 index 0000000..0341c57 Binary files /dev/null and b/bin/dfuutil-windows/dfu-util-static.exe differ diff --git a/bin/dfuutil-windows/dfu-util.exe b/bin/dfuutil-windows/dfu-util.exe new file mode 100755 index 0000000..e2ffeb5 Binary files /dev/null and b/bin/dfuutil-windows/dfu-util.exe differ diff --git a/bin/dfuutil-windows/libusb-1.0.a b/bin/dfuutil-windows/libusb-1.0.a new file mode 100644 index 0000000..abe6c1b Binary files /dev/null and b/bin/dfuutil-windows/libusb-1.0.a differ diff --git a/bin/dfuutil-windows/libusb-1.0.dll b/bin/dfuutil-windows/libusb-1.0.dll new file mode 100755 index 0000000..aedb209 Binary files /dev/null and b/bin/dfuutil-windows/libusb-1.0.dll differ diff --git a/bin/dfuutil-windows/libusb-1.0.dll.a b/bin/dfuutil-windows/libusb-1.0.dll.a new file mode 100755 index 0000000..445a566 Binary files /dev/null and b/bin/dfuutil-windows/libusb-1.0.dll.a differ diff --git a/bin/dfuutil-windows/libusb-1.0.la b/bin/dfuutil-windows/libusb-1.0.la new file mode 100755 index 0000000..b28e44a --- /dev/null +++ b/bin/dfuutil-windows/libusb-1.0.la @@ -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' diff --git a/bin/dfuutil-windows/lsusb-static.exe b/bin/dfuutil-windows/lsusb-static.exe new file mode 100755 index 0000000..ad71cd2 Binary files /dev/null and b/bin/dfuutil-windows/lsusb-static.exe differ diff --git a/bin/dfuutil-windows/lsusb.exe b/bin/dfuutil-windows/lsusb.exe new file mode 100755 index 0000000..9d0c906 Binary files /dev/null and b/bin/dfuutil-windows/lsusb.exe differ diff --git a/main.js b/main.js index b10fa6d..c7daf3b 100644 --- a/main.js +++ b/main.js @@ -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) { diff --git a/renderer.js b/renderer.js index 063df17..f31b98c 100644 --- a/renderer.js +++ b/renderer.js @@ -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 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", {