diff --git a/macos/QMK Toolbox.xcodeproj/project.pbxproj b/macos/QMK Toolbox.xcodeproj/project.pbxproj index 52e0cbefad..cec9068e16 100644 --- a/macos/QMK Toolbox.xcodeproj/project.pbxproj +++ b/macos/QMK Toolbox.xcodeproj/project.pbxproj @@ -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, ); }; }; @@ -109,6 +111,8 @@ 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 = ""; }; + 0D742A3A2A3B0AF600637C14 /* SN32DFUDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SN32DFUDevice.swift; sourceTree = ""; }; + 0D742A3E2A3B0B8600637C14 /* sonixflasher */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = sonixflasher; sourceTree = ""; }; 300641B328359D3E00F58C4B /* QMK ToolboxRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "QMK ToolboxRelease.entitlements"; 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 = ""; }; @@ -225,6 +229,7 @@ 3A53FB5B268A33F10020BAB0 /* Resources */ = { isa = PBXGroup; children = ( + 0D742A3E2A3B0B8600637C14 /* sonixflasher */, 09522BBA1F6216BA00AEBC5E /* avrdude.conf */, 09522BB21F61E32700AEBC5E /* mcu-list.txt */, C93A0FF32292232D0006C88F /* reset.eep */, @@ -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 */, @@ -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 */, @@ -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 */, diff --git a/macos/QMK Toolbox/AppDelegate.swift b/macos/QMK Toolbox/AppDelegate.swift index 0fbc9ce316..5123851490 100644 --- a/macos/QMK Toolbox/AppDelegate.swift +++ b/macos/QMK Toolbox/AppDelegate.swift @@ -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)") diff --git a/macos/QMK Toolbox/Resources/sonixflasher b/macos/QMK Toolbox/Resources/sonixflasher new file mode 100755 index 0000000000..dc1bbab8b6 Binary files /dev/null and b/macos/QMK Toolbox/Resources/sonixflasher differ diff --git a/macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift b/macos/QMK Toolbox/USB/Bootloader/BootloaderType.swift index d1398c1d12..761865408a 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 sn32Dfu case none } diff --git a/macos/QMK Toolbox/USB/Bootloader/SN32DFUDevice.swift b/macos/QMK Toolbox/USB/Bootloader/SN32DFUDevice.swift new file mode 100644 index 0000000000..143dbbda5d --- /dev/null +++ b/macos/QMK Toolbox/USB/Bootloader/SN32DFUDevice.swift @@ -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]) + } + } +} diff --git a/macos/QMK Toolbox/USB/USBListener.swift b/macos/QMK Toolbox/USB/USBListener.swift index 81666151f7..a1b4ccfda6 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 .sn32Dfu: + return SN32DFUDevice(usbDevice: usbDevice) case .none: return usbDevice } @@ -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 diff --git a/readme.md b/readme.md index 44b548de88..1d87be14f5 100644 --- a/readme.md +++ b/readme.md @@ -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: diff --git a/windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs b/windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs index 360d8c530c..087b08b124 100644 --- a/windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs +++ b/windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs @@ -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", diff --git a/windows/QMK Toolbox/MainWindow.cs b/windows/QMK Toolbox/MainWindow.cs index d433130b9b..0522a61779 100644 --- a/windows/QMK Toolbox/MainWindow.cs +++ b/windows/QMK Toolbox/MainWindow.cs @@ -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)"); diff --git a/windows/QMK Toolbox/QMK Toolbox.csproj b/windows/QMK Toolbox/QMK Toolbox.csproj index 00a849bd65..e7040603b1 100644 --- a/windows/QMK Toolbox/QMK Toolbox.csproj +++ b/windows/QMK Toolbox/QMK Toolbox.csproj @@ -131,6 +131,7 @@ + @@ -201,6 +202,8 @@ + + diff --git a/windows/QMK Toolbox/Resources/libhidapi-0.dll b/windows/QMK Toolbox/Resources/libhidapi-0.dll new file mode 100644 index 0000000000..4eded6eeb1 Binary files /dev/null and b/windows/QMK Toolbox/Resources/libhidapi-0.dll differ diff --git a/windows/QMK Toolbox/Resources/sonixflasher.exe b/windows/QMK Toolbox/Resources/sonixflasher.exe new file mode 100755 index 0000000000..2749c60221 Binary files /dev/null and b/windows/QMK Toolbox/Resources/sonixflasher.exe differ diff --git a/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs b/windows/QMK Toolbox/Usb/Bootloader/BootloaderType.cs index 13ade35513..594dbc6090 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, + Sn32Dfu, None } } diff --git a/windows/QMK Toolbox/Usb/Bootloader/Sn32DfuDevice.cs b/windows/QMK Toolbox/Usb/Bootloader/Sn32DfuDevice.cs new file mode 100644 index 0000000000..c53d118b77 --- /dev/null +++ b/windows/QMK Toolbox/Usb/Bootloader/Sn32DfuDevice.cs @@ -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}\""); + } + } +} diff --git a/windows/QMK Toolbox/Usb/UsbListener.cs b/windows/QMK Toolbox/Usb/UsbListener.cs index 29ea045567..9834316d3f 100644 --- a/windows/QMK Toolbox/Usb/UsbListener.cs +++ b/windows/QMK Toolbox/Usb/UsbListener.cs @@ -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; @@ -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 {