From ff53ef6538f19c2dc158200c34ace35eb32eb6ea Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Thu, 22 Aug 2024 20:28:18 +0700 Subject: [PATCH] Added support of Artery AT32 DFU for Windows --- readme.md | 2 +- windows/QMK Toolbox/MainWindow.cs | 2 +- windows/QMK Toolbox/Resources/drivers.txt | 1 + .../Usb/Bootloader/At32DfuDevice.cs | 30 +++++++++++++++++++ .../Usb/Bootloader/BootloaderType.cs | 1 + windows/QMK Toolbox/Usb/UsbListener.cs | 8 +++++ 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 windows/QMK Toolbox/Usb/Bootloader/At32DfuDevice.cs diff --git a/readme.md b/readme.md index 6aaf92f13f..5a768e7d1e 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ This is a collection of flashing tools packaged into one app. It supports auto-d QMK Toolbox supports the following bootloaders: - - ARM DFU (APM32, Kiibohd, STM32, STM32duino) via [dfu-util](http://dfu-util.sourceforge.net/) + - ARM DFU (APM32, AT32, Kiibohd, STM32, STM32duino) via [dfu-util](http://dfu-util.sourceforge.net/) - Atmel/LUFA/QMK DFU via [dfu-programmer](http://dfu-programmer.github.io/) - Atmel SAM-BA (Massdrop) via [Massdrop Loader](https://github.com/massdrop/mdloader) - BootloadHID (Atmel, PS2AVRGB) via [bootloadHID](https://www.obdev.at/products/vusb/bootloadhid.html) diff --git a/windows/QMK Toolbox/MainWindow.cs b/windows/QMK Toolbox/MainWindow.cs index 4ca7b4361f..4fee6a2755 100644 --- a/windows/QMK Toolbox/MainWindow.cs +++ b/windows/QMK Toolbox/MainWindow.cs @@ -61,7 +61,7 @@ private void MainWindow_Load(object sender, EventArgs e) logTextBox.LogInfo($"QMK Toolbox {Application.ProductVersion} (https://qmk.fm/toolbox)"); logTextBox.LogInfo("Supported bootloaders:"); - logTextBox.LogInfo(" - ARM DFU (APM32, Kiibohd, STM32, STM32duino) and RISC-V DFU (GD32V) via dfu-util (http://dfu-util.sourceforge.net/)"); + logTextBox.LogInfo(" - ARM DFU (APM32, AT32, Kiibohd, STM32, STM32duino) and RISC-V DFU (GD32V) via dfu-util (http://dfu-util.sourceforge.net/)"); logTextBox.LogInfo(" - Atmel/LUFA/QMK DFU via dfu-programmer (http://dfu-programmer.github.io/)"); logTextBox.LogInfo(" - Atmel SAM-BA (Massdrop) via Massdrop Loader (https://github.com/massdrop/mdloader)"); logTextBox.LogInfo(" - BootloadHID (Atmel, PS2AVRGB) via bootloadHID (https://www.obdev.at/products/vusb/bootloadhid.html)"); diff --git a/windows/QMK Toolbox/Resources/drivers.txt b/windows/QMK Toolbox/Resources/drivers.txt index 0490bfa4ab..314fc93fdb 100644 --- a/windows/QMK Toolbox/Resources/drivers.txt +++ b/windows/QMK Toolbox/Resources/drivers.txt @@ -6,6 +6,7 @@ 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,AT32 Bootloader,2E3C,DF11,04e7a875-779e-4fd5-90c1-57a5644bfc42 winusb,GD32V Bootloader,28E9,0189,e1421fd6-f799-4b6c-97e6-39e87d37f858 winusb,STM32duino Bootloader,1EAF,0003,746915ec-99d8-4a90-a722-3c85ba31e4fe libusbk,USBaspLoader,16C0,05DC,e69affdc-0ef0-427c-aefb-4e593c9d2724 diff --git a/windows/QMK Toolbox/Usb/Bootloader/At32DfuDevice.cs b/windows/QMK Toolbox/Usb/Bootloader/At32DfuDevice.cs new file mode 100644 index 0000000000..e5147e50fa --- /dev/null +++ b/windows/QMK Toolbox/Usb/Bootloader/At32DfuDevice.cs @@ -0,0 +1,30 @@ +using System.IO; +using System.Threading.Tasks; + +namespace QMK_Toolbox.Usb.Bootloader +{ + class At32DfuDevice : BootloaderDevice + { + public At32DfuDevice(UsbDevice d) : base(d) + { + Type = BootloaderType.At32Dfu; + Name = "AT32 DFU"; + PreferredDriver = "WinUSB"; + IsResettable = true; + } + + public async override Task Flash(string mcu, string file) + { + if (Path.GetExtension(file)?.ToLower() == ".bin") + { + await RunProcessAsync("dfu-util.exe", $"-a 0 -d 2E3C:DF11 -s 0x08000000:leave -D \"{file}\""); + } + else + { + PrintMessage("Only firmware files in .bin format can be flashed with dfu-util!", MessageType.Error); + } + } + + public async override Task Reset(string mcu) => await RunProcessAsync("dfu-util.exe", "-a 0 -d 2E3C:DF11 -s 0x08000000:leave"); + } +} diff --git a/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs b/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs index 13ade35513..406dc86696 100644 --- a/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs +++ b/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs @@ -5,6 +5,7 @@ public enum BootloaderType Apm32Dfu, AtmelDfu, AtmelSamBa, + At32Dfu, AvrIsp, BootloadHid, Caterina, diff --git a/windows/QMK Toolbox/Usb/UsbListener.cs b/windows/QMK Toolbox/Usb/UsbListener.cs index 58ddc0b62d..c3a17c6bb0 100644 --- a/windows/QMK Toolbox/Usb/UsbListener.cs +++ b/windows/QMK Toolbox/Usb/UsbListener.cs @@ -153,6 +153,8 @@ private static IUsbDevice CreateDevice(ManagementBaseObject d) return new AtmelDfuDevice(usbDevice); case BootloaderType.AtmelSamBa: return new AtmelSamBaDevice(usbDevice); + case BootloaderType.At32Dfu: + return new At32DfuDevice(usbDevice); case BootloaderType.AvrIsp: return new AvrIspDevice(usbDevice); case BootloaderType.BootloadHid: @@ -315,6 +317,12 @@ private static BootloaderType GetDeviceType(ushort vendorId, ushort productId, u return BootloaderType.Wb32Dfu; } break; + case 0x2E3C: // Artery Technology Co. Ltd. + if (productId == 0xDF11) + { + return BootloaderType.At32Dfu; + } + break; } return BootloaderType.None;