From d385644f262883c37012dd5f4be94bcafe2558ef Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 12 Jun 2024 09:55:32 +1000 Subject: [PATCH] Set VID/PID dynamically for stm32 F4xx boards --- main.js | 3 ++- renderer.js | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index 01c738c..e733f91 100644 --- a/main.js +++ b/main.js @@ -266,7 +266,8 @@ ipcMain.on("uploadFW_stm32", (e, args) => { 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]; + var deviceString = args.vid + ":" + args.pid; + var execArgs = ['-d', deviceString, '-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 diff --git a/renderer.js b/renderer.js index d25b34e..bd9babd 100644 --- a/renderer.js +++ b/renderer.js @@ -119,17 +119,18 @@ function refreshSerialPorts() }) //Look for any STM32 devices in DFU mode - var uninitialisedTeensyDevices = usb.getDeviceList().filter( function(d) { + var stmDFUDevices = 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)) + stmDFUDevices.forEach((device, index) => { + console.log("STM32 in DFU mode found: ", device.deviceDescriptor.bcdDevice) + console.log("STM32 PID: ", device.deviceDescriptor.idProduct.toString(16).toUpperCase()) 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"); + newOption.setAttribute("vid", device.deviceDescriptor.idVendor.toString(16).toUpperCase()); + newOption.setAttribute("pid", device.deviceDescriptor.idProduct.toString(16).toUpperCase()); select.add(newOption); }) /* @@ -571,7 +572,9 @@ function downloadComplete(file) ipcRenderer.send("uploadFW_stm32", { port: uploadPort, firmwareFile: file, - board: uploadBoard + board: uploadBoard, + vid: portSelect.options[portSelect.selectedIndex].getAttribute("vid"), + pid: portSelect.options[portSelect.selectedIndex].getAttribute("pid") }); } else