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

[macOS][Windows] Add support for sn32 targets #413

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
8 changes: 8 additions & 0 deletions macos/QMK Toolbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
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, ); }; };
0D742A3B2A3B0AF600637C14 /* SN32DFUDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D742A3A2A3B0AF600637C14 /* SN32DFUDevice.swift */; };
0D742A3F2A3B0B8600637C14 /* sonixflasher in Resources */ = {isa = PBXBuildFile; fileRef = 0D742A3E2A3B0B8600637C14 /* sonixflasher */; };
3066649428392281007C93C8 /* libftdi.1.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 3A7770D822BD3B8200398C40 /* libftdi.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
3066649628392281007C93C8 /* libhidapi.0.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 3AFD4BCF281AB83C00ADCB65 /* libhidapi.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 @@ -109,6 +111,8 @@
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>"; };
0D742A3A2A3B0AF600637C14 /* SN32DFUDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SN32DFUDevice.swift; sourceTree = "<group>"; };
0D742A3E2A3B0B8600637C14 /* sonixflasher */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = sonixflasher; sourceTree = "<group>"; };
300641B328359D3E00F58C4B /* QMK ToolboxRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "QMK ToolboxRelease.entitlements"; 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>"; };
Expand Down Expand Up @@ -225,6 +229,7 @@
3A53FB5B268A33F10020BAB0 /* Resources */ = {
isa = PBXGroup;
children = (
0D742A3E2A3B0B8600637C14 /* sonixflasher */,
09522BBA1F6216BA00AEBC5E /* avrdude.conf */,
09522BB21F61E32700AEBC5E /* mcu-list.txt */,
C93A0FF32292232D0006C88F /* reset.eep */,
Expand Down Expand Up @@ -283,6 +288,7 @@
3A32CF5A284142300016D7B7 /* KiibohdDevice.swift */,
3A32CF5C2841427E0016D7B7 /* LUFAHIDDevice.swift */,
3A32CF68284145900016D7B7 /* LUFAMSDevice.swift */,
0D742A3A2A3B0AF600637C14 /* SN32DFUDevice.swift */,
3A32CF5E284142D10016D7B7 /* STM32DFUDevice.swift */,
3A32CF60284143990016D7B7 /* STM32DuinoDevice.swift */,
3A32CF62284143EC0016D7B7 /* USBAspDevice.swift */,
Expand Down Expand Up @@ -355,6 +361,7 @@
files = (
092964021F5C8B2C004F2D3F /* Assets.xcassets in Resources */,
3AA5D3472803FCE1008121E4 /* Colors.xcassets in Resources */,
0D742A3F2A3B0B8600637C14 /* sonixflasher in Resources */,
092964051F5C8B2C004F2D3F /* MainMenu.xib in Resources */,
3A928718292CA8770015D961 /* HIDConsoleWindow.xib in Resources */,
3A8F9EFF26E75012007480A7 /* KeyTesterWindow.xib in Resources */,
Expand Down Expand Up @@ -386,6 +393,7 @@
3A32CF4B28412C420016D7B7 /* BootloaderDevice.swift in Sources */,
3A32CF512841403B0016D7B7 /* BootloadHIDDevice.swift in Sources */,
3AA7F96B283BCD2E009FFDD5 /* BootloaderType.swift in Sources */,
0D742A3B2A3B0AF600637C14 /* SN32DFUDevice.swift in Sources */,
3A32CF4F28413F900016D7B7 /* CaterinaDevice.swift in Sources */,
3AB09F1D28B46672006CC212 /* GD32VDFUDevice.swift in Sources */,
3A32CF4D28413E6B0016D7B7 /* HalfKayDevice.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions macos/QMK Toolbox/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, USBListenerDelegate {
logTextView.logInfo(" - HalfKay (Teensy, Ergodox EZ) via Teensy Loader (https://pjrc.com/teensy/loader_cli.html)")
logTextView.logInfo(" - LUFA/QMK HID via hid_bootloader_cli (https://github.com/abcminiuser/lufa)")
logTextView.logInfo(" - WB32 DFU via wb32-dfu-updater_cli (https://github.com/WestberryTech/wb32-dfu-updater)")
logTextView.logInfo(" - SN32 DFU via sonixflasher (https://github.com/SonixQMK/SonixFlasherC)")
logTextView.logInfo(" - LUFA Mass Storage")
logTextView.logInfo("Supported ISP flashers:")
logTextView.logInfo(" - AVRISP (Arduino ISP)")
Expand Down
Binary file added macos/QMK Toolbox/Resources/sonixflasher
Binary file not shown.
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 sn32Dfu
case none
}
17 changes: 17 additions & 0 deletions macos/QMK Toolbox/USB/Bootloader/SN32DFUDevice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation

class SN32DFUDevice: BootloaderDevice {
override init(usbDevice: USBDevice) {
super.init(usbDevice: usbDevice)
name = "SN32 DFU"
type = .sn32Dfu
}

override func flash(_ mcu: String, file: String) {
if productID == 0x7010 {
runProcess("sonixflasher", args: ["-v", String(format: "%04X:%04X", vendorID, productID), "-o", "0x200", "-f", file])
} else {
runProcess("sonixflasher", args: ["-v", String(format: "%04X:%04X", vendorID, productID), "-f", file])
}
}
}
10 changes: 10 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 .sn32Dfu:
return SN32DFUDevice(usbDevice: usbDevice)
case .none:
return usbDevice
}
Expand Down Expand Up @@ -161,6 +163,14 @@ class USBListener: BootloaderDeviceDelegate {
if productID == 0xDF11 {
return .stm32Dfu
}
case 0x0c45: // Sonix
switch productID {
// SN32F260, SN32F240b, SN32F240
case 0x7010, 0x7040, 0x7900:
return .sn32Dfu
default:
break
}
case 0x1209: // pid.codes
if productID == 0x2302 { // Keyboardio Atreus 2 Bootloader
return .caterina
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ QMK Toolbox supports the following bootloaders:
- 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)
- WB32 DFU (WB32) via [wb32-dfu-updater_cli](https://github.com/WestberryTech/wb32-dfu-updater)
- SN32 DFU (SN32) via [sonixflasher](https://github.com/SonixQMK/SonixFlasherC)
- LUFA Mass Storage

And the following ISP flashers:
Expand Down
2 changes: 2 additions & 0 deletions windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static class EmbeddedResourceHelper
"mdloader.exe",
"teensy_loader_cli.exe",
"wb32-dfu-updater_cli.exe",
"sonixflasher.exe",
"libhidapi-0.dll",
"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 @@ -71,6 +71,7 @@ private void MainWindow_Load(object sender, EventArgs e)
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(" - WB32 DFU via wb32-dfu-updater_cli (https://github.com/WestberryTech/wb32-dfu-updater)");
logTextBox.LogInfo(" - SN32 DFU via sonixflasher (https://github.com/SonixQMK/SonixFlasherC)");
logTextBox.LogInfo(" - LUFA Mass Storage");
logTextBox.LogInfo("Supported ISP flashers:");
logTextBox.LogInfo(" - AVRISP (Arduino ISP)");
Expand Down
3 changes: 3 additions & 0 deletions windows/QMK Toolbox/QMK Toolbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<Compile Include="Usb\Bootloader\UsbAspDevice.cs" />
<Compile Include="Usb\Bootloader\UsbTinyIspDevice.cs" />
<Compile Include="Usb\Bootloader\Wb32DfuDevice.cs" />
<Compile Include="Usb\Bootloader\Sn32DfuDevice.cs" />
<Compile Include="Usb\IUsbDevice.cs" />
<Compile Include="Usb\UsbDevice.cs" />
<Compile Include="Usb\UsbListener.cs" />
Expand Down Expand Up @@ -201,6 +202,8 @@
<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\sonixflasher.exe" />
<EmbeddedResource Include="Resources\libhidapi-0.dll" />
<EmbeddedResource Include="Resources\libftdi1.dll" />
<EmbeddedResource Include="Resources\libusb0.dll" />
<EmbeddedResource Include="Resources\libusb-0-1-4.dll" />
Expand Down
Binary file added windows/QMK Toolbox/Resources/libhidapi-0.dll
Binary file not shown.
Binary file added windows/QMK Toolbox/Resources/sonixflasher.exe
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 @@ -20,6 +20,7 @@ public enum BootloaderType
UsbAsp,
UsbTinyIsp,
Wb32Dfu,
Sn32Dfu,
None
}
}
26 changes: 26 additions & 0 deletions windows/QMK Toolbox/Usb/Bootloader/Sn32DfuDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.IO;
using System.Threading.Tasks;

namespace QMK_Toolbox.Usb.Bootloader
{
class Sn32DfuDevice : BootloaderDevice
{
public Sn32DfuDevice(UsbDevice d) : base(d)
{
Type = BootloaderType.Sn32Dfu;
Name = "SN32 DFU";
PreferredDriver = "HidUsb";
}

public async override Task Flash(string mcu, string file)
{
if (ProductId == 0x7010) // SN32F260
{
await RunProcessAsync("sonixflasher.exe", $"-v {VendorId:x4}:{ProductId:x4} -o 0x200 -f \"{file}\"");
return;
}

await RunProcessAsync("sonixflasher.exe", $"-v {VendorId:x4}:{ProductId:x4} -f \"{file}\"");
}
}
}
13 changes: 13 additions & 0 deletions windows/QMK Toolbox/Usb/UsbListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ private static IUsbDevice CreateDevice(ManagementBaseObject d)
return new UsbTinyIspDevice(usbDevice);
case BootloaderType.Wb32Dfu:
return new Wb32DfuDevice(usbDevice);
case BootloaderType.Sn32Dfu:
return new Sn32DfuDevice(usbDevice);
}

return usbDevice;
Expand Down Expand Up @@ -231,6 +233,17 @@ private static BootloaderType GetDeviceType(ushort vendorId, ushort productId, u
return BootloaderType.Stm32Dfu;
}
break;
case 0x0c45: // Sonix
switch (productId)
{
case 0x7010: // SN32F260
return BootloaderType.Sn32Dfu;
case 0x7040: // SN32F240b
return BootloaderType.Sn32Dfu;
case 0x7900: // SN32F240
return BootloaderType.Sn32Dfu;
}
break;
case 0x1209: // pid.codes
if (productId == 0x2302) // Keyboardio Atreus 2 Bootloader
{
Expand Down