feat(transport): implement macOS USB discovery using IOKit#39
feat(transport): implement macOS USB discovery using IOKit#39skot wants to merge 1 commit into256foundation:mainfrom
Conversation
- Add core-foundation, io-kit-sys, mach2 dependencies for macOS - Implement MacOsIoKitDiscovery with device enumeration via IORegistry - Support hotplug notifications using CFRunLoop and IOKit callbacks - Map USB devices to /dev/cu.* serial ports by location ID - Update README to reflect macOS is now supported
|
tested with a bitaxe-raw bitaxeGamma from MacOS and seems to be working. |
|
Tested on macOS with a BitAxe Gamma 602 connected via USB-C. The device was detected correctly and communication through Mujina worked as expected. |
|
Tested on: Mac mini (Apple M-series, macOS 26.2) with a Bitaxe Gamma (BM1370, AxeOS v2.13.0) connected via USB. Build: Clean. No new errors or warnings introduced by this PR. Hardware verification: The Bitaxe enumerates in IORegistry under IOUSBHostDevice (VID 0x303A / Espressif) with an associated IOSerialBSDClient at /dev/cu.usbmodem*. This is exactly the class and serial port path the PR targets. Issues found:
After flashing bitaxe-raw (esp-hal-update branch) onto the Bitaxe, re-ran the same discovery tests. The firmware presents a different USB descriptor than AxeOS: |
| core-foundation = "0.10" | ||
| io-kit-sys = "0.4" | ||
| mach2 = "0.4" |
There was a problem hiding this comment.
these versions are not the latest, any specific reason to prefer those?
Implement get_serial_ports on macOS using IOKit to locate /dev/cu.* devices by walking the IORegistry parent chain and matching on location ID. Includes a retry loop for the same device-node-not-yet-created race that exists on Linux, though the permissions race does not apply since macOS creates nodes with final permissions. Adds core-foundation and io-kit-sys as macOS-only dependencies. Thanks to Skot for PR #39, which inspired this implementation. This takes a different direction by using nusb for shared enumeration and hotplug across platforms, reducing the amount of unsafe code we maintain to just the serial port lookup. Co-authored-by: Skot <skot@bitnet.cx>
|
Merged this feature to main with a slightly different approach in d174cde. I've tested this with Bitaxe 601 connected to an M3 Mac running macOS 26.3 via the hub on a Studio Display. Other test reports are welcome, thanks! |
Summary
Validation