raleighlittles / PS5-Camera-Firmware-Loader

A cross-platform utility for loading custom firmware onto the PlayStation 5 camera, written in Rust
https://crates.io/crates/ps5_camera_firmware_loader
41 stars 8 forks source link

[Bug]: NoDevice error despite firmware uploading successfully #10

Open parkerlreed opened 1 month ago

parkerlreed commented 1 month ago

Provide a brief description of the issue

Errors out with NoDevice despite the firmware upload and UVC initialization working as expected.

Operating System version

Linux (Default)

Which camera model was this for?

PlayStation 5

Relevant log output

[parker@rogally debug]$ ./ps5_camera_firmware_loader 21.01-03.20.00.04-00.00.00.bin 
thread 'main' panicked at src/main.rs:119:10:
called `Result::unwrap()` on an `Err` value: NoDevice
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[  327.750651] usb 6-1.3.3: new SuperSpeed USB device number 8 using xhci_hcd
[  327.767485] usb 6-1.3.3: New USB device found, idVendor=05a9, idProduct=0580, bcdDevice= 1.00
[  327.767490] usb 6-1.3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  327.767492] usb 6-1.3.3: Product: USB Boot 
[  327.767493] usb 6-1.3.3: Manufacturer: OmniVision Technologies, Inc.
[  334.017407] usb 6-1.3.3: USB disconnect, device number 8
[  334.596850] usb 6-1.3.3: new SuperSpeed USB device number 9 using xhci_hcd
[  334.619970] usb 6-1.3.3: New USB device found, idVendor=05a9, idProduct=058c, bcdDevice= 1.00
[  334.619980] usb 6-1.3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  334.619984] usb 6-1.3.3: Product: USB Camera-OV580
[  334.619986] usb 6-1.3.3: Manufacturer: Omnivision Technologies, Inc.
[  334.628714] usb 6-1.3.3: Found UVC 1.00 device USB Camera-OV580 (05a9:058c)
parkerlreed commented 1 month ago

That is the output for dmesg. Boot device, run the program, mode switch, good to go. It's working great just erroneously throwing the error.

There's nothing before it besides just regular dmesg

[ 2041.066035] usb 6-1.3.3: new SuperSpeed USB device number 11 using xhci_hcd
[ 2041.083772] usb 6-1.3.3: New USB device found, idVendor=05a9, idProduct=0580, bcdDevice= 1.00
[ 2041.083777] usb 6-1.3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2041.083779] usb 6-1.3.3: Product: USB Boot 
[ 2041.083781] usb 6-1.3.3: Manufacturer: OmniVision Technologies, Inc.
[parker@rogally debug]$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 045e:028e Microsoft Corp. Xbox360 Controller
Bus 001 Device 003: ID 0b05:1abe ASUSTek Computer, Inc. N-KEY Device
Bus 001 Device 004: ID 0489:e0f5 Foxconn / Hon Hai Wireless_Device
Bus 001 Device 005: ID 1c7a:0588 LighTuning Technology Inc. ETU905A86-E
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 0bda:5487 Realtek Semiconductor Corp. Dell dock
Bus 005 Device 003: ID 0bda:5413 Realtek Semiconductor Corp. Dell dock
Bus 005 Device 004: ID 413c:b06e Dell Computer Corp. Dell dock
Bus 005 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 005 Device 006: ID 05ac:024f Apple, Inc. Aluminium Keyboard (ANSI)
Bus 005 Device 007: ID 413c:b06f Dell Computer Corp. Dell dock
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 006 Device 002: ID 0bda:0487 Realtek Semiconductor Corp. Dell dock
Bus 006 Device 003: ID 0bda:0413 Realtek Semiconductor Corp. Dell dock
Bus 006 Device 004: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 006 Device 011: ID 05a9:0580 OmniVision Technologies, Inc. USB Boot 
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Run the rust binary

$ RUST_BACKTRACE=1 ./ps5_camera_firmware_loader 21.01-03.20.00.04-00.00.00.bin 
thread 'main' panicked at src/main.rs:119:10:
called `Result::unwrap()` on an `Err` value: NoDevice
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: core::result::Result<T,E>::unwrap
             at /usr/src/debug/rust/rustc-1.78.0-src/library/core/src/result.rs:1077:23
   4: ps5_camera_firmware_loader::main
             at /home/parker/.local/build/PS5-Camera-Firmware-Loader/rust/src/main.rs:110:5
   5: core::ops::function::FnOnce::call_once
             at /usr/src/debug/rust/rustc-1.78.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[ 2155.677464] usb 6-1.3.3: USB disconnect, device number 11
[ 2156.249555] usb 6-1.3.3: new SuperSpeed USB device number 12 using xhci_hcd
[ 2156.277481] usb 6-1.3.3: New USB device found, idVendor=05a9, idProduct=058c, bcdDevice= 1.00
[ 2156.277490] usb 6-1.3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2156.277494] usb 6-1.3.3: Product: USB Camera-OV580
[ 2156.277496] usb 6-1.3.3: Manufacturer: Omnivision Technologies, Inc.
[ 2156.286347] usb 6-1.3.3: Found UVC 1.00 device USB Camera-OV580 (05a9:058c)
[parker@rogally debug]$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 045e:028e Microsoft Corp. Xbox360 Controller
Bus 001 Device 003: ID 0b05:1abe ASUSTek Computer, Inc. N-KEY Device
Bus 001 Device 004: ID 0489:e0f5 Foxconn / Hon Hai Wireless_Device
Bus 001 Device 005: ID 1c7a:0588 LighTuning Technology Inc. ETU905A86-E
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 0bda:5487 Realtek Semiconductor Corp. Dell dock
Bus 005 Device 003: ID 0bda:5413 Realtek Semiconductor Corp. Dell dock
Bus 005 Device 004: ID 413c:b06e Dell Computer Corp. Dell dock
Bus 005 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 005 Device 006: ID 05ac:024f Apple, Inc. Aluminium Keyboard (ANSI)
Bus 005 Device 007: ID 413c:b06f Dell Computer Corp. Dell dock
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 006 Device 002: ID 0bda:0487 Realtek Semiconductor Corp. Dell dock
Bus 006 Device 003: ID 0bda:0413 Realtek Semiconductor Corp. Dell dock
Bus 006 Device 004: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 006 Device 012: ID 05a9:058c OmniVision Technologies, Inc. USB Camera-OV580
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
parkerlreed commented 1 month ago

It seems like this is a common thing? cpp version does it as well. This website notes the same thing https://barelywalking.com/?p=707

[parker@rogally cpp]$ ./ps5_camera_firmware_loader ../rust/target/debug/firmware.bin 
ERROR: libusb reported error during control transfer, error# = -4
Finished uploading firmware!
parkerlreed commented 1 month ago

-4 is no device so this correlates with the rust error as well

LIBUSB_ERROR_NO_DEVICE -4

No such device (it may have been disconnected) 

Seems like the firmware uploader isn't releasing the device before it drops out and switches to UVC. Basically having it ripped out from underneath it.

Maybe just a race condition?

raleighlittles commented 1 month ago

@parkerlreed Thanks for the detailed bug report. This is an odd issue, it does seem like a race condition of some sort, or maybe something where there needs to be a delay before writing the final "footer" packet for the device to do something. Just curious, if you comment out line 119 - what happens?

a) Does it still "work" (recognize UVC device correctly) ? b) If it doesn't, do you get the error on line 89 instead?

Also what device is this? Desktop or Laptop? Are you connecting the camera to the USB port on the device itself or via some dock/hub?

parkerlreed commented 1 month ago

This is on an ROG Ally/Steam Deck so having to go through a dock no matter what.

Removing

.unwrap();

So it looks like this

    // Again, taken from OrbisEyeCam
    let footer_packet: [u8; 1] = [0x5B];

    libusb_dev_handle
        .write_control(
            USB_OUTGOING_PACKET_BM_REQUEST_TYPE,
            0x0,
            0x2200,
            0x8018,
            &footer_packet,
            std::time::Duration::ZERO,
        );
}

That seems to clear up the error and it initializes properly.

[parker@rogally debug]$ ./ps5_camera_firmware_loader 21.01-03.20.00.04-00.00.00.bin 
[parker@rogally debug]$ 
[44171.567168] usb 6-1.1: new SuperSpeed USB device number 6 using xhci_hcd
[44171.585018] usb 6-1.1: New USB device found, idVendor=05a9, idProduct=0580, bcdDevice= 1.00
[44171.585025] usb 6-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[44171.585026] usb 6-1.1: Product: USB Boot 
[44171.585028] usb 6-1.1: Manufacturer: OmniVision Technologies, Inc.
[44237.228026] usb 6-1.1: USB disconnect, device number 6
[44237.748461] usb 6-1.1: new SuperSpeed USB device number 7 using xhci_hcd
[44237.773548] usb 6-1.1: New USB device found, idVendor=05a9, idProduct=058c, bcdDevice= 1.00
[44237.773560] usb 6-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[44237.773563] usb 6-1.1: Product: USB Camera-OV580
[44237.773565] usb 6-1.1: Manufacturer: Omnivision Technologies, Inc.
[44237.781689] usb 6-1.1: Found UVC 1.00 device USB Camera-OV580 (05a9:058c)