From 9edfa8bbfeba256b10fe054aa39e3473a791b3ba Mon Sep 17 00:00:00 2001 From: sheltonyu Date: Tue, 13 Aug 2024 10:02:28 +0800 Subject: [PATCH 1/3] [macOS] add support ArteryTek device --- macos/QMK Toolbox.xcodeproj/project.pbxproj | 4 ++++ .../USB/Bootloader/AT32DFUDevice.swift | 23 +++++++++++++++++++ .../USB/Bootloader/BootloaderType.swift | 1 + macos/QMK Toolbox/USB/USBListener.swift | 6 +++++ 4 files changed, 34 insertions(+) create mode 100644 macos/QMK Toolbox/USB/Bootloader/AT32DFUDevice.swift diff --git a/macos/QMK Toolbox.xcodeproj/project.pbxproj b/macos/QMK Toolbox.xcodeproj/project.pbxproj index b3c6f6e014..3e80840415 100644 --- a/macos/QMK Toolbox.xcodeproj/project.pbxproj +++ b/macos/QMK Toolbox.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 09522BB31F61E32700AEBC5E /* mcu-list.txt in Resources */ = {isa = PBXBuildFile; fileRef = 09522BB21F61E32700AEBC5E /* mcu-list.txt */; }; 09522BBB1F6216BA00AEBC5E /* avrdude.conf in Resources */ = {isa = PBXBuildFile; fileRef = 09522BBA1F6216BA00AEBC5E /* avrdude.conf */; }; 098AEDFB1F5E45C300CA054D /* dfu-util in CopyFiles */ = {isa = PBXBuildFile; fileRef = 098AEDFA1F5E45C300CA054D /* dfu-util */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2D412F102C634F6300507AE9 /* AT32DFUDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D412F0F2C634F6300507AE9 /* AT32DFUDevice.swift */; }; 3066649428392281007C93C8 /* libftdi1.2.5.0.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 3A7770D822BD3B8200398C40 /* libftdi1.2.5.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3066649628392281007C93C8 /* libhidapi.0.14.0.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 3AFD4BCF281AB83C00ADCB65 /* libhidapi.0.14.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3066649828392281007C93C8 /* libusb-0.1.4.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 09D79CBB1FB8A6490086ABF6 /* libusb-0.1.4.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -110,6 +111,7 @@ 098AEDFA1F5E45C300CA054D /* dfu-util */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = "dfu-util"; sourceTree = ""; }; 09D79CB51FB0DD7F0086ABF6 /* libusb-1.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = "libusb-1.0.0.dylib"; sourceTree = ""; }; 09D79CBB1FB8A6490086ABF6 /* libusb-0.1.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = "libusb-0.1.4.dylib"; sourceTree = ""; }; + 2D412F0F2C634F6300507AE9 /* AT32DFUDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AT32DFUDevice.swift; sourceTree = ""; }; 3A128566283D3F0800173A80 /* MicrocontrollerSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrocontrollerSelector.swift; sourceTree = ""; }; 3A32CF4A28412C420016D7B7 /* BootloaderDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BootloaderDevice.swift; sourceTree = ""; }; 3A32CF4C28413E6B0016D7B7 /* HalfKayDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HalfKayDevice.swift; sourceTree = ""; }; @@ -280,6 +282,7 @@ 3A32CF56284141680016D7B7 /* AVRISPDevice.swift */, 3A32CF4A28412C420016D7B7 /* BootloaderDevice.swift */, 3A32CF502841403B0016D7B7 /* BootloadHIDDevice.swift */, + 2D412F0F2C634F6300507AE9 /* AT32DFUDevice.swift */, 3AA7F96A283BCD2E009FFDD5 /* BootloaderType.swift */, 3A32CF4E28413F900016D7B7 /* CaterinaDevice.swift */, 3AB09F1C28B46672006CC212 /* GD32VDFUDevice.swift */, @@ -397,6 +400,7 @@ 3A32CF5F284142D10016D7B7 /* STM32DFUDevice.swift in Sources */, 3A32CF61284143990016D7B7 /* STM32DuinoDevice.swift in Sources */, 3A32CF63284143EC0016D7B7 /* USBAspDevice.swift in Sources */, + 2D412F102C634F6300507AE9 /* AT32DFUDevice.swift in Sources */, 3AB657122B9EAC34007805DD /* HIDDevice.swift in Sources */, 3A32CF652841445E0016D7B7 /* USBTinyISPDevice.swift in Sources */, 3A32CF672841451D0016D7B7 /* WB32DFUDevice.swift in Sources */, diff --git a/macos/QMK Toolbox/USB/Bootloader/AT32DFUDevice.swift b/macos/QMK Toolbox/USB/Bootloader/AT32DFUDevice.swift new file mode 100644 index 0000000000..26520ea37d --- /dev/null +++ b/macos/QMK Toolbox/USB/Bootloader/AT32DFUDevice.swift @@ -0,0 +1,23 @@ +import Foundation + +class AT32DFUDevice: BootloaderDevice { + override init(usbDevice: USBDevice) { + super.init(usbDevice: usbDevice) + name = "AT32 DFU" + type = .at32Dfu + resettable = true + } + + override func flash(_ mcu: String, file: String) { + guard file.lowercased().hasSuffix(".bin") else { + print(message: "Only firmware files in .bin format can be flashed with dfu-util!", type: .error) + return + } + + runProcess("dfu-util", args: ["-a", "0", "-d", "2E3C:DF11", "-s", "0x08000000:leave", "-D", file]) + } + + override func reset(_ mcu: String) { + runProcess("dfu-util", args: ["-a", "0", "-d", "2E3C:DF11", "-s", "0x08000000:leave"]) + } +} diff --git a/macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift b/macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift index d1398c1d12..d1e81e472d 100644 --- a/macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift +++ b/macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift @@ -19,5 +19,6 @@ enum BootloaderType { case usbAsp case usbTinyIsp case wb32Dfu + case at32Dfu case none } diff --git a/macos/QMK Toolbox/USB/USBListener.swift b/macos/QMK Toolbox/USB/USBListener.swift index a124eedf64..83ac570732 100644 --- a/macos/QMK Toolbox/USB/USBListener.swift +++ b/macos/QMK Toolbox/USB/USBListener.swift @@ -134,6 +134,8 @@ class USBListener: BootloaderDeviceDelegate { return USBTinyISPDevice(usbDevice: usbDevice) case .wb32Dfu: return WB32DFUDevice(usbDevice: usbDevice) + case .at32Dfu: + return AT32DFUDevice(usbDevice: usbDevice) case .none: return usbDevice } @@ -228,6 +230,10 @@ class USBListener: BootloaderDeviceDelegate { if productID == 0xDFA0 { return .wb32Dfu } + case 0x2E3C: // ArteryTech + if productID == 0xDF11 { + return .at32Dfu + } default: break } From 64681456a3e2cd3e10a0268fcd9fb693ca741c5f Mon Sep 17 00:00:00 2001 From: sheltonyu Date: Tue, 13 Aug 2024 11:14:11 +0800 Subject: [PATCH 2/3] [windows] add support ArteryTek device --- .../PublishProfiles/FolderProfile.pubxml | 19 ++++++++++++ windows/QMK Toolbox/QMK Toolbox.csproj | 14 +++++++-- 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, 71 insertions(+), 2 deletions(-) create mode 100644 windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 windows/QMK Toolbox/Usb/Bootloader/AT32DfuDevice.cs diff --git a/windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml b/windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000000..08de6b1fc4 --- /dev/null +++ b/windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,19 @@ + + + + + Release + x86 + bin\Release\publish\win-x86\ + FileSystem + <_TargetId>Folder + net6.0-windows10.0.18362.0 + win-x86 + true + true + false + false + + \ No newline at end of file diff --git a/windows/QMK Toolbox/QMK Toolbox.csproj b/windows/QMK Toolbox/QMK Toolbox.csproj index 879c18f938..2a1ac6e054 100644 --- a/windows/QMK Toolbox/QMK Toolbox.csproj +++ b/windows/QMK Toolbox/QMK Toolbox.csproj @@ -1,14 +1,15 @@  - net6.0-windows10.0.19041.0 + net6.0-windows10.0.18362.0 WinExe qmk_toolbox true true true false - true + FALSE false + AnyCPU;x86 Resources\output.ico @@ -26,6 +27,8 @@ A flashing/debug utility for devices running QMK Firmware 0.3.3 QMK Toolbox + True + False @@ -90,6 +93,10 @@ 5.7.0 all + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + 3.3.40 @@ -111,4 +118,7 @@ Settings.Designer.cs + + + \ No newline at end of file diff --git a/windows/QMK Toolbox/Resources/drivers.txt b/windows/QMK Toolbox/Resources/drivers.txt index 0490bfa4ab..c3734cd219 100644 --- a/windows/QMK Toolbox/Resources/drivers.txt +++ b/windows/QMK Toolbox/Resources/drivers.txt @@ -7,6 +7,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,GD32V Bootloader,28E9,0189,e1421fd6-f799-4b6c-97e6-39e87d37f858 +winusb,AT32 Bootloader,2E3C,DF11,d70683b3-0498-4979-9a17-e1c62fa6b85d 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 diff --git a/windows/QMK Toolbox/Usb/Bootloader/AT32DfuDevice.cs b/windows/QMK Toolbox/Usb/Bootloader/AT32DfuDevice.cs new file mode 100644 index 0000000000..3dadd8e84c --- /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..3af4e303e3 100644 --- a/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs +++ b/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs @@ -20,6 +20,7 @@ public enum BootloaderType UsbAsp, UsbTinyIsp, Wb32Dfu, + AT32Dfu, None } } diff --git a/windows/QMK Toolbox/Usb/UsbListener.cs b/windows/QMK Toolbox/Usb/UsbListener.cs index 58ddc0b62d..b918b9960f 100644 --- a/windows/QMK Toolbox/Usb/UsbListener.cs +++ b/windows/QMK Toolbox/Usb/UsbListener.cs @@ -180,6 +180,8 @@ private static IUsbDevice CreateDevice(ManagementBaseObject d) return new UsbTinyIspDevice(usbDevice); case BootloaderType.Wb32Dfu: return new Wb32DfuDevice(usbDevice); + case BootloaderType.AT32Dfu: + return new AT32DfuDevice(usbDevice); default: break; } @@ -315,6 +317,12 @@ private static BootloaderType GetDeviceType(ushort vendorId, ushort productId, u return BootloaderType.Wb32Dfu; } break; + case 0x2E3C: // ArteryTech + if (productId == 0xDF11) + { + return BootloaderType.AT32Dfu; + } + break; } return BootloaderType.None; From 6644db13e8ef1fc82239504ac4fb309e803efb3b Mon Sep 17 00:00:00 2001 From: sheltonyu Date: Tue, 13 Aug 2024 11:19:31 +0800 Subject: [PATCH 3/3] delete unused folder --- .../PublishProfiles/FolderProfile.pubxml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml diff --git a/windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml b/windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml deleted file mode 100644 index 08de6b1fc4..0000000000 --- a/windows/QMK Toolbox/Properties/PublishProfiles/FolderProfile.pubxml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Release - x86 - bin\Release\publish\win-x86\ - FileSystem - <_TargetId>Folder - net6.0-windows10.0.18362.0 - win-x86 - true - true - false - false - - \ No newline at end of file