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

add support arterytek at32 dfu #482

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions macos/QMK Toolbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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, ); }; };
Expand Down Expand Up @@ -110,6 +111,7 @@
098AEDFA1F5E45C300CA054D /* dfu-util */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = "dfu-util"; sourceTree = "<group>"; };
09D79CB51FB0DD7F0086ABF6 /* libusb-1.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = "libusb-1.0.0.dylib"; sourceTree = "<group>"; };
09D79CBB1FB8A6490086ABF6 /* libusb-0.1.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = "libusb-0.1.4.dylib"; sourceTree = "<group>"; };
2D412F0F2C634F6300507AE9 /* AT32DFUDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AT32DFUDevice.swift; sourceTree = "<group>"; };
3A128566283D3F0800173A80 /* MicrocontrollerSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrocontrollerSelector.swift; sourceTree = "<group>"; };
3A32CF4A28412C420016D7B7 /* BootloaderDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BootloaderDevice.swift; sourceTree = "<group>"; };
3A32CF4C28413E6B0016D7B7 /* HalfKayDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HalfKayDevice.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
23 changes: 23 additions & 0 deletions macos/QMK Toolbox/USB/Bootloader/AT32DFUDevice.swift
Original file line number Diff line number Diff line change
@@ -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"])
}
}
1 change: 1 addition & 0 deletions macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ enum BootloaderType {
case usbAsp
case usbTinyIsp
case wb32Dfu
case at32Dfu
case none
}
6 changes: 6 additions & 0 deletions macos/QMK Toolbox/USB/USBListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -228,6 +230,10 @@ class USBListener: BootloaderDeviceDelegate {
if productID == 0xDFA0 {
return .wb32Dfu
}
case 0x2E3C: // ArteryTech
if productID == 0xDF11 {
return .at32Dfu
}
default:
break
}
Expand Down
14 changes: 12 additions & 2 deletions windows/QMK Toolbox/QMK Toolbox.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<OutputType>WinExe</OutputType>
<AssemblyName>qmk_toolbox</AssemblyName>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PublishSingleFile>true</PublishSingleFile>
<PublishSingleFile>FALSE</PublishSingleFile>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\output.ico</ApplicationIcon>
Expand All @@ -26,6 +27,8 @@
<Description>A flashing/debug utility for devices running QMK Firmware</Description>
<Version>0.3.3</Version>
<Product>QMK Toolbox</Product>
<PackAsTool>True</PackAsTool>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<Compile Update="BetterComboBox.cs">
Expand Down Expand Up @@ -90,6 +93,10 @@
<Version>5.7.0</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Fody" Version="6.5.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="hidlibrary">
<Version>3.3.40</Version>
</PackageReference>
Expand All @@ -111,4 +118,7 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xsd" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions windows/QMK Toolbox/Resources/drivers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions windows/QMK Toolbox/Usb/Bootloader/AT32DfuDevice.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}
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 @@ -20,6 +20,7 @@ public enum BootloaderType
UsbAsp,
UsbTinyIsp,
Wb32Dfu,
AT32Dfu,
None
}
}
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 UsbTinyIspDevice(usbDevice);
case BootloaderType.Wb32Dfu:
return new Wb32DfuDevice(usbDevice);
case BootloaderType.AT32Dfu:
return new AT32DfuDevice(usbDevice);
default:
break;
}
Expand Down Expand Up @@ -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;
Expand Down