Skip to content

Commit

Permalink
[Windows] Add support for LUFA-HID/QMK-HID (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Apr 20, 2022
1 parent 15990cb commit 22628a7
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
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)
- LUFA/QMK HID via [hid_bootloader_cli](https://github.com/abcminiuser/lufa)
- 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 @@ -17,6 +17,7 @@ public static class EmbeddedResourceHelper
"bootloadHID.exe",
"dfu-programmer.exe",
"dfu-util.exe",
"hid_bootloader_cli.exe",
"mdloader.exe",
"teensy_loader_cli.exe",
"libftdi1.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(" - LUFA/QMK HID via hid_bootloader_cli (https://github.com/abcminiuser/lufa)");
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 @@ -118,6 +118,7 @@
<Compile Include="Usb\Bootloader\CaterinaDevice.cs" />
<Compile Include="Usb\Bootloader\HalfKayDevice.cs" />
<Compile Include="Usb\Bootloader\KiibohdDfuDevice.cs" />
<Compile Include="Usb\Bootloader\LufaHidDevice.cs" />
<Compile Include="Usb\Bootloader\LufaMsDevice.cs" />
<Compile Include="Usb\Bootloader\Stm32DfuDevice.cs" />
<Compile Include="Usb\Bootloader\Stm32DuinoDevice.cs" />
Expand Down Expand Up @@ -185,6 +186,7 @@
<EmbeddedResource Include="Resources\bootloadHID.exe" />
<EmbeddedResource Include="Resources\dfu-programmer.exe" />
<EmbeddedResource Include="Resources\dfu-util.exe" />
<EmbeddedResource Include="Resources\hid_bootloader_cli.exe" />
<EmbeddedResource Include="Resources\mdloader.exe" />
<EmbeddedResource Include="Resources\qmk_driver_installer.exe" />
<EmbeddedResource Include="Resources\teensy_loader_cli.exe" />
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ public enum BootloaderType
Caterina,
HalfKay,
KiibohdDfu,
LufaHid,
LufaMs,
QmkDfu,
QmkHid,
Stm32Dfu,
Stm32Duino,
UsbAsp,
Expand Down
29 changes: 29 additions & 0 deletions windows/QMK Toolbox/Usb/Bootloader/LufaHidDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Threading.Tasks;

namespace QMK_Toolbox.Usb.Bootloader
{
class LufaHidDevice : BootloaderDevice
{
public LufaHidDevice(UsbDevice d) : base(d)
{
if (d.RevisionBcd == 0x0936)
{
Type = BootloaderType.QmkHid;
Name = "QMK HID";
}
else
{
Type = BootloaderType.LufaHid;
Name = "LUFA HID";
}
PreferredDriver = "HidUsb";
//IsResettable = true;
}

public async override Task Flash(string mcu, string file) => await RunProcessAsync("hid_bootloader_cli.exe", $"-mmcu={mcu} \"{file}\" -v");

// hid_bootloader_cli 210130 lacks -b flag
// Next LUFA release should have it thanks to abcminiuser/lufa#173
//public async override Task Reset(string mcu) => await RunProcessAsync("hid_bootloader_cli.exe", $"-mmcu={mcu} -bv");
}
}
10 changes: 10 additions & 0 deletions windows/QMK Toolbox/Usb/UsbListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ private static IUsbDevice CreateDevice(ManagementBaseObject d)
return new HalfKayDevice(usbDevice);
case BootloaderType.KiibohdDfu:
return new KiibohdDfuDevice(usbDevice);
case BootloaderType.LufaHid:
case BootloaderType.QmkHid:
return new LufaHidDevice(usbDevice);
case BootloaderType.LufaMs:
return new LufaMsDevice(usbDevice);
case BootloaderType.Stm32Dfu:
Expand All @@ -194,6 +197,13 @@ private static BootloaderType GetDeviceType(ushort vendorId, ushort productId, u
{
case 0x2045:
return BootloaderType.LufaMs;
case 0x2067:
if (revisionBcd == 0x0936) // Unicode Ψ
{
return BootloaderType.QmkHid;
}

return BootloaderType.LufaHid;
case 0x2FEF: // ATmega16U2
case 0x2FF0: // ATmega32U2
case 0x2FF3: // ATmega16U4
Expand Down

0 comments on commit 22628a7

Please sign in to comment.