Skip to content

Commit

Permalink
Added support of WB32 DFU for Windows. (#321)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan <[email protected]>
  • Loading branch information
Joy Lee and fauxpark authored May 20, 2022
1 parent ba1cfbe commit 7b113f5
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ QMK Toolbox supports the following bootloaders:
- Caterina (Arduino, Pro Micro) via [avrdude](http://nongnu.org/avrdude/)
- HalfKay (Teensy, Ergodox EZ) via [Teensy Loader](https://pjrc.com/teensy/loader_cli.html)
- LUFA/QMK HID via [hid_bootloader_cli](https://github.com/abcminiuser/lufa)
- WB32 DFU (WB32) via [wb32-dfu-updater_cli](https://github.com/WestberryTech/wb32-dfu-updater)
- LUFA Mass Storage

And the following ISP flashers:
Expand Down
1 change: 1 addition & 0 deletions windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static class EmbeddedResourceHelper
"hid_bootloader_cli.exe",
"mdloader.exe",
"teensy_loader_cli.exe",
"wb32-dfu-updater_cli.exe",
"libftdi1.dll",
"libusb0.dll",
"libusb-0-1-4.dll",
Expand Down
1 change: 1 addition & 0 deletions windows/QMK Toolbox/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private void MainWindow_Load(object sender, EventArgs e)
logTextBox.LogInfo(" - Caterina (Arduino, Pro Micro) via avrdude (http://nongnu.org/avrdude/)");
logTextBox.LogInfo(" - HalfKay (Teensy, Ergodox EZ) via Teensy Loader (https://pjrc.com/teensy/loader_cli.html)");
logTextBox.LogInfo(" - LUFA/QMK HID via hid_bootloader_cli (https://github.com/abcminiuser/lufa)");
logTextBox.LogInfo(" - WB32 DFU via wb32-dfu-updater_cli (https://github.com/WestberryTech/wb32-dfu-updater)");
logTextBox.LogInfo(" - LUFA Mass Storage");
logTextBox.LogInfo("Supported ISP flashers:");
logTextBox.LogInfo(" - AVRISP (Arduino ISP)");
Expand Down
2 changes: 2 additions & 0 deletions windows/QMK Toolbox/QMK Toolbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<Compile Include="Usb\Bootloader\Stm32DuinoDevice.cs" />
<Compile Include="Usb\Bootloader\UsbAspDevice.cs" />
<Compile Include="Usb\Bootloader\UsbTinyIspDevice.cs" />
<Compile Include="Usb\Bootloader\Wb32DfuDevice.cs" />
<Compile Include="Usb\IUsbDevice.cs" />
<Compile Include="Usb\UsbDevice.cs" />
<Compile Include="Usb\UsbListener.cs" />
Expand Down Expand Up @@ -188,6 +189,7 @@
<EmbeddedResource Include="Resources\mdloader.exe" />
<EmbeddedResource Include="Resources\qmk_driver_installer.exe" />
<EmbeddedResource Include="Resources\teensy_loader_cli.exe" />
<EmbeddedResource Include="Resources\wb32-dfu-updater_cli.exe" />
<EmbeddedResource Include="Resources\libftdi1.dll" />
<EmbeddedResource Include="Resources\libusb0.dll" />
<EmbeddedResource Include="Resources\libusb-0-1-4.dll" />
Expand Down
1 change: 1 addition & 0 deletions windows/QMK Toolbox/Resources/drivers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Use Windows Powershell and type [guid]::NewGuid() to generate guids
winusb,STM32 Bootloader,0483,DF11,6d98a87f-4ecf-464d-89ed-8c684d857a75
winusb,APM32 Bootloader,314B,0106,9ff3cc31-6772-4a3f-a492-a80d91f7a853
winusb,WB32 Bootloader,342D,DFA0,89b0fdf0-3d22-4408-8393-32147ba508ce
winusb,STM32duino Bootloader,1EAF,0003,746915ec-99d8-4a90-a722-3c85ba31e4fe
libusbk,USBaspLoader,16C0,05DC,e69affdc-0ef0-427c-aefb-4e593c9d2724
winusb,Kiibohd DFU Bootloader,1C11,B007,aa5a3f86-b81e-4416-89ad-0c1ea1ed63af
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum BootloaderType
Stm32Duino,
UsbAsp,
UsbTinyIsp,
Wb32Dfu,
None
}
}
34 changes: 34 additions & 0 deletions windows/QMK Toolbox/Usb/Bootloader/Wb32DfuDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.IO;
using System.Threading.Tasks;

namespace QMK_Toolbox.Usb.Bootloader
{
class Wb32DfuDevice : BootloaderDevice
{
public Wb32DfuDevice(UsbDevice d) : base(d)
{
Type = BootloaderType.Wb32Dfu;
Name = "WB32 DFU";
PreferredDriver = "WinUSB";
IsResettable = true;
}

public async override Task Flash(string mcu, string file)
{
if (Path.GetExtension(file)?.ToLower() == ".bin")
{
await RunProcessAsync("wb32-dfu-updater_cli.exe", $"--toolbox-mode --dfuse-address 0x08000000 --download \"{file}\"");
}
else if (Path.GetExtension(file)?.ToLower() == ".hex")
{
await RunProcessAsync("wb32-dfu-updater_cli.exe", $"--toolbox-mode --download \"{file}\"");
}
else
{
PrintMessage("Only firmware files in .bin or .hex format can be flashed with wb32-dfu-updater_cli!", MessageType.Error);
}
}

public async override Task Reset(string mcu) => await RunProcessAsync("wb32-dfu-updater_cli.exe", $"--reset");
}
}
8 changes: 8 additions & 0 deletions windows/QMK Toolbox/Usb/UsbListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ private static IUsbDevice CreateDevice(ManagementBaseObject d)
return new UsbAspDevice(usbDevice);
case BootloaderType.UsbTinyIsp:
return new UsbTinyIspDevice(usbDevice);
case BootloaderType.Wb32Dfu:
return new Wb32DfuDevice(usbDevice);
}

return usbDevice;
Expand Down Expand Up @@ -303,6 +305,12 @@ private static BootloaderType GetDeviceType(ushort vendorId, ushort productId, u
return BootloaderType.Apm32Dfu;
}
break;
case 0x342D: // WestBerryTech
if (productId == 0xDFA0)
{
return BootloaderType.Wb32Dfu;
}
break;
}

return BootloaderType.None;
Expand Down

0 comments on commit 7b113f5

Please sign in to comment.