Skip to content

camera-firmware: fix firmware upload on macOS#518

Open
gabrielrlima wants to merge 1 commit into
thp:masterfrom
gabrielrlima:macos-camera-firmware-fixes
Open

camera-firmware: fix firmware upload on macOS#518
gabrielrlima wants to merge 1 commit into
thp:masterfrom
gabrielrlima:macos-camera-firmware-fixes

Conversation

@gabrielrlima

Copy link
Copy Markdown

psmove camera-firmware was 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 to libusb_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 subsequent libusb_set_configuration() failed with LIBUSB_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 a set_configuration failure there, since AppleUSBHostCompositeDevice already selects configuration 1.

Testing

Apple Silicon (M4, macOS 26), Sony PS5 HD Camera (CFI-ZEY1) behind a USB 3 hub:

  • Before: segfault on psmove camera-firmware; with only the NULL check fixed, upload aborted with res = -4 at libusb_set_configuration.
  • After both fixes: firmware upload completes ("Firmware uploaded") and the camera re-enumerates as a standard UVC device (05a9:058c, "USB Camera-OV580"), working in Photo Booth, QuickTime and Teams at 1920x1080@30.
  • Linux/Windows code paths are unchanged (the guards only affect macOS behavior).

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant