camera-firmware: fix firmware upload on macOS#518
Open
gabrielrlima wants to merge 1 commit into
Open
Conversation
Two fixes for the Darwin libusb backend, which made 'psmove camera-firmware' unusable on macOS: - libusb_get_parent() can return NULL on macOS. The unchecked result was passed to libusb_get_device_descriptor(), crashing with a segfault before the firmware upload could even start. - libusb_reset_device() on macOS triggers a re-enumeration that drops the device off the bus and invalidates the handle, so the following libusb_set_configuration() failed with LIBUSB_ERROR_NO_DEVICE (-4) and aborted the upload. Skip the reset on macOS (the device is freshly enumerated in boot mode anyway) and tolerate a set_configuration failure there, since AppleUSBHostCompositeDevice already selects configuration 1. Tested on Apple Silicon (M4, macOS 26) with a PS5 camera (CFI-ZEY1) behind a USB 3 hub: firmware upload completes and the camera re-enumerates as a standard UVC device (05a9:058c, "USB Camera-OV580") usable in Photo Booth, QuickTime, Teams, etc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
psmove camera-firmwarewas unusable on macOS due to two issues with the Darwin libusb backend:1. Segfault from NULL parent device
libusb_get_parent()can return NULL on macOS. The result was passed unchecked tolibusb_get_device_descriptor(), crashing the tool before the firmware upload could even start.2. Upload aborted after device reset
libusb_reset_device()on the Darwin backend triggers a re-enumeration that drops the device off the bus and invalidates the handle, so the subsequentlibusb_set_configuration()failed withLIBUSB_ERROR_NO_DEVICE(-4) and aborted the upload. This change skips the reset on macOS (the device is freshly enumerated in boot mode anyway) and tolerates aset_configurationfailure there, sinceAppleUSBHostCompositeDevicealready selects configuration 1.Testing
Apple Silicon (M4, macOS 26), Sony PS5 HD Camera (CFI-ZEY1) behind a USB 3 hub:
psmove camera-firmware; with only the NULL check fixed, upload aborted withres = -4atlibusb_set_configuration.05a9:058c, "USB Camera-OV580"), working in Photo Booth, QuickTime and Teams at 1920x1080@30.🤖 Generated with Claude Code