Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support of WB32 DFU for Windows. #321

Merged
merged 12 commits into from
May 20, 2022
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Check binary permissions
working-directory: ./macos/QMK Toolbox/Resources
env:
QMK_BINARIES: avrdude bootloadHID dfu-programmer dfu-util mdloader teensy_loader_cli
QMK_BINARIES: avrdude bootloadHID dfu-programmer dfu-util mdloader teensy_loader_cli wb32-dfu-updater_cli
itarze marked this conversation as resolved.
Show resolved Hide resolved
run: |
status=0
for b in $QMK_BINARIES; do
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ QMK Toolbox supports the following bootloaders:
- BootloadHID (Atmel, PS2AVRGB) via [bootloadHID](https://www.obdev.at/products/vusb/bootloadhid.html)
- Caterina (Arduino, Pro Micro) via [avrdude](http://nongnu.org/avrdude/)
- HalfKay (Teensy, Ergodox EZ) via [Teensy Loader](https://pjrc.com/teensy/loader_cli.html)
- 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 @@ -19,6 +19,7 @@ public static class EmbeddedResourceHelper
"dfu-util.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 @@ -72,6 +72,7 @@ private void MainWindow_Load(object sender, EventArgs e)
logTextBox.LogInfo(" - BootloadHID (Atmel, PS2AVRGB) via bootloadHID (https://www.obdev.at/products/vusb/bootloadhid.html)");
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(" - 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 @@ -123,6 +123,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 @@ -16,6 +16,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 @@ -180,6 +180,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 @@ -293,6 +295,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