Skip to content

Commit

Permalink
Set VID/PID dynamically for stm32 F4xx boards
Browse files Browse the repository at this point in the history
  • Loading branch information
noisymime committed Jun 11, 2024
1 parent 5e19016 commit d385644
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
/*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d385644

Please sign in to comment.