diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e724ef2f0a..ff3f969118 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: - name: Check binary permissions working-directory: ./macos/QMK Toolbox/Resources env: - QMK_BINARIES: avrdude bootloadHID dfu-programmer dfu-util mdloader teensy_loader_cli + QMK_BINARIES: avrdude bootloadHID dfu-programmer dfu-util mdloader teensy_loader_cli wb32-dfu-updater_cli run: | status=0 for b in $QMK_BINARIES; do diff --git a/macos/QMK Toolbox.xcodeproj/project.pbxproj b/macos/QMK Toolbox.xcodeproj/project.pbxproj index 0b2d85ad21..ca1cc6ad87 100644 --- a/macos/QMK Toolbox.xcodeproj/project.pbxproj +++ b/macos/QMK Toolbox.xcodeproj/project.pbxproj @@ -53,6 +53,8 @@ 3AE6DA032726CB7A00CECA21 /* USBAspDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE6DA022726CB7A00CECA21 /* USBAspDevice.m */; }; 3AE6DA062726CBB200CECA21 /* USBTinyISPDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE6DA052726CBB200CECA21 /* USBTinyISPDevice.m */; }; 3AFD4BD1281AB86800ADCB65 /* libhidapi.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3AFD4BCF281AB83C00ADCB65 /* libhidapi.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 9B7999EF280AA1D0007469DA /* WB32DFUDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7999EE280AA1D0007469DA /* WB32DFUDevice.m */; }; + 9BE10718275F4CFE00C708D5 /* wb32-dfu-updater_cli in Resources */ = {isa = PBXBuildFile; fileRef = 9BE10717275F4CFE00C708D5 /* wb32-dfu-updater_cli */; }; C93A0FF42292232E0006C88F /* reset.eep in Resources */ = {isa = PBXBuildFile; fileRef = C93A0FF32292232D0006C88F /* reset.eep */; }; C9A09B5722EE6826008C3CF3 /* mdloader in Resources */ = {isa = PBXBuildFile; fileRef = C9A09B5622EE6826008C3CF3 /* mdloader */; }; /* End PBXBuildFile section */ @@ -149,6 +151,9 @@ 3AE6DA042726CBB200CECA21 /* USBTinyISPDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = USBTinyISPDevice.h; sourceTree = ""; }; 3AE6DA052726CBB200CECA21 /* USBTinyISPDevice.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = USBTinyISPDevice.m; sourceTree = ""; }; 3AFD4BCF281AB83C00ADCB65 /* libhidapi.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libhidapi.0.dylib; sourceTree = ""; }; + 9B7999ED280AA1C8007469DA /* WB32DFUDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WB32DFUDevice.h; sourceTree = ""; }; + 9B7999EE280AA1D0007469DA /* WB32DFUDevice.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WB32DFUDevice.m; sourceTree = ""; }; + 9BE10717275F4CFE00C708D5 /* wb32-dfu-updater_cli */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = "wb32-dfu-updater_cli"; sourceTree = ""; }; C93A0FF32292232D0006C88F /* reset.eep */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = reset.eep; path = ../../../common/reset.eep; sourceTree = ""; }; C9A09B5622EE6826008C3CF3 /* mdloader */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = mdloader; sourceTree = ""; }; /* End PBXFileReference section */ @@ -241,6 +246,7 @@ 3A7492CB27DF96BF0073A5A0 /* hid_bootloader_cli */, C9A09B5622EE6826008C3CF3 /* mdloader */, 0929640E1F5E4068004F2D3F /* teensy_loader_cli */, + 9BE10717275F4CFE00C708D5 /* wb32-dfu-updater_cli */, 3A7770D822BD3B8200398C40 /* libftdi.1.dylib */, 3AFD4BCF281AB83C00ADCB65 /* libhidapi.0.dylib */, 09D79CBB1FB8A6490086ABF6 /* libusb-0.1.4.dylib */, @@ -308,6 +314,8 @@ 3AE6DA022726CB7A00CECA21 /* USBAspDevice.m */, 3AE6DA042726CBB200CECA21 /* USBTinyISPDevice.h */, 3AE6DA052726CBB200CECA21 /* USBTinyISPDevice.m */, + 9B7999ED280AA1C8007469DA /* WB32DFUDevice.h */, + 9B7999EE280AA1D0007469DA /* WB32DFUDevice.m */, ); path = Bootloader; sourceTree = ""; @@ -387,6 +395,7 @@ 3A7492CC27DF96BF0073A5A0 /* hid_bootloader_cli in Resources */, C9A09B5722EE6826008C3CF3 /* mdloader in Resources */, 0929640F1F5E4068004F2D3F /* teensy_loader_cli in Resources */, + 9BE10718275F4CFE00C708D5 /* wb32-dfu-updater_cli in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -423,6 +432,7 @@ 3AE6DA002726CB2600CECA21 /* STM32DuinoDevice.m in Sources */, 3AE6DA032726CB7A00CECA21 /* USBAspDevice.m in Sources */, 3AE6DA062726CBB200CECA21 /* USBTinyISPDevice.m in Sources */, + 9B7999EF280AA1D0007469DA /* WB32DFUDevice.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macos/QMK Toolbox/AppDelegate.m b/macos/QMK Toolbox/AppDelegate.m index f054b398d3..b1ae15b241 100644 --- a/macos/QMK Toolbox/AppDelegate.m +++ b/macos/QMK Toolbox/AppDelegate.m @@ -60,6 +60,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [self.logTextView logInfo:@" - Caterina (Arduino, Pro Micro) via avrdude (http://nongnu.org/avrdude/)"]; [self.logTextView logInfo:@" - HalfKay (Teensy, Ergodox EZ) via Teensy Loader (https://pjrc.com/teensy/loader_cli.html)"]; [self.logTextView logInfo:@" - LUFA/QMK HID via hid_bootloader_cli (https://github.com/abcminiuser/lufa)"]; + [self.logTextView logInfo:@" - WB32 DFU via wb32-dfu-updater_cli (https://github.com/WestberryTech/wb32-dfu-updater)"]; [self.logTextView logInfo:@" - LUFA Mass Storage"]; [self.logTextView logInfo:@"Supported ISP flashers:"]; [self.logTextView logInfo:@" - AVRISP (Arduino ISP)"]; diff --git a/macos/QMK Toolbox/Resources/wb32-dfu-updater_cli b/macos/QMK Toolbox/Resources/wb32-dfu-updater_cli new file mode 100755 index 0000000000..5338c87bc6 Binary files /dev/null and b/macos/QMK Toolbox/Resources/wb32-dfu-updater_cli differ diff --git a/macos/QMK Toolbox/USB/Bootloader/BootloaderType.h b/macos/QMK Toolbox/USB/Bootloader/BootloaderType.h index 6ec33b4846..09dc0efced 100644 --- a/macos/QMK Toolbox/USB/Bootloader/BootloaderType.h +++ b/macos/QMK Toolbox/USB/Bootloader/BootloaderType.h @@ -15,5 +15,6 @@ typedef enum BootloaderType : NSUInteger { BootloaderTypeSTM32Duino, BootloaderTypeUSBAsp, BootloaderTypeUSBTinyISP, + BootloaderTypeWB32DFU, BootloaderTypeNone } BootloaderType; diff --git a/macos/QMK Toolbox/USB/Bootloader/WB32DFUDevice.h b/macos/QMK Toolbox/USB/Bootloader/WB32DFUDevice.h new file mode 100644 index 0000000000..15f3521e25 --- /dev/null +++ b/macos/QMK Toolbox/USB/Bootloader/WB32DFUDevice.h @@ -0,0 +1,4 @@ +#import "BootloaderDevice.h" + +@interface WB32DFUDevice : BootloaderDevice +@end diff --git a/macos/QMK Toolbox/USB/Bootloader/WB32DFUDevice.m b/macos/QMK Toolbox/USB/Bootloader/WB32DFUDevice.m new file mode 100644 index 0000000000..cb566373c7 --- /dev/null +++ b/macos/QMK Toolbox/USB/Bootloader/WB32DFUDevice.m @@ -0,0 +1,28 @@ +#import "WB32DFUDevice.h" + +@implementation WB32DFUDevice + +- (id)initWithUSBDevice:(USBDevice *)usbDevice { + if (self = [super initWithUSBDevice:usbDevice]) { + self.name = @"WB32 DFU"; + self.type = BootloaderTypeWB32DFU; + self.resettable = YES; + } + return self; +} + +-(void)flashWithMCU:(NSString *)mcu file:(NSString *)file { + if([[[file pathExtension] lowercaseString] isEqualToString:@"bin"]) { + [self runProcess:@"wb32-dfu-updater_cli" withArgs:@[@"--toolbox-mode", @"--dfuse-address", @"0x08000000", @"--download", file]]; + } else if([[[file pathExtension] lowercaseString] isEqualToString:@"hex"]) { + [self runProcess:@"wb32-dfu-updater_cli" withArgs:@[@"--toolbox-mode", @"--download", file]]; + } else { + [self printMessage:@"Only firmware files in .bin or .hex format can be flashed with wb32-dfu-updater_cli!" withType:MessageType_Error]; + } +} + +-(void)resetWithMCU:(NSString *)mcu { + [self runProcess:@"wb32-dfu-updater_cli" withArgs:@[@"--reset"]]; +} + +@end diff --git a/macos/QMK Toolbox/USB/USBListener.m b/macos/QMK Toolbox/USB/USBListener.m index a8262828fc..a41e7262ac 100644 --- a/macos/QMK Toolbox/USB/USBListener.m +++ b/macos/QMK Toolbox/USB/USBListener.m @@ -17,6 +17,7 @@ #import "STM32DuinoDevice.h" #import "USBAspDevice.h" #import "USBTinyISPDevice.h" +#import "WB32DFUDevice.h" @implementation USBListener { mach_port_t masterPort; @@ -158,6 +159,8 @@ - (void)stop { return [[USBAspDevice alloc] initWithUSBDevice:usbDevice]; case BootloaderTypeUSBTinyISP: return [[USBTinyISPDevice alloc] initWithUSBDevice:usbDevice]; + case BootloaderTypeWB32DFU: + return [[WB32DFUDevice alloc] initWithUSBDevice:usbDevice]; case BootloaderTypeNone: default: return usbDevice; @@ -262,6 +265,11 @@ - (BootloaderType)deviceTypeForVendorID:(ushort)vendorID productID:(ushort)produ return BootloaderTypeAPM32DFU; } break; + case 0x342D: // WestBerryTech + if (productID == 0xDFA0) { + return BootloaderTypeWB32DFU; + } + break; } return BootloaderTypeNone;