androidandroid-emulatorusbqemurealsense

USB passthrough to connect a RealSense camera in Android Emulator


I want to connect an Intel Realsense camera (D455) to my android virtual device, running on the android emulator, so I can debug my android APP using the Realsense camera.

On this page, it seems that the latest android studio emulator supports USB passthrough, so I tried the following command:

./emulator -avd Nexus_6P_API_29 -qemu -usb -device usb-host,vendorid=0x8086,productid=0x0b5c

where -avd Nexus_6P_API_29 specifies the name of the android virtual device, and vendorid and productid are obtained by lsusb.

The emulator gives the following error message (showing it 3 times):

qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "Intel(R) RealSense(TM) Depth Ca" ( speed) to bus "usb-bus.0", port "1" (full speed)

It seems the emulator does find the device, but there's a "speed mismatching" problem. I found a good explanation of the problem on this page, saying usb-bus corresponds to USB 1.0. As the Realsense camera supports usb-3.2, I think I should use usb-3.0, so I tried the following:

./emulator -avd Nexus_6P_API_29 -qemu -usb -device nec-usb-xhci,id=xhci -device usb-host,vendorid=0x8086,productid=0x0b5c

specifying nec-usb-xhci for usb-3.0.

However I'm getting the error message as:

qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "Intel(R) RealSense(TM) Depth Ca" ( speed) to bus "xhci.0", port "1" (full+high+super speed)

I noted that, the speed of the camera is displayed as ( speed). (I.e. the actual speed, while normally should be one of (full speed)/(high speed)/(super speed), is blank.) I guess the speed mismatch problem has something to do with this blank speed. Has anyone had similar experiences ? Thanks in advance !


Solution

  • Only EHCI is already built in the kernel on AVDs.

    I've wrote on XDA a little guide with some deeper informations about it.

    You can read more there.

    If your device can handle EHCI, you could try it with:

        -qemu -usb -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=0x8086,productid=0x0b5c
    

    Otherwise, recompile your kernel with XHCI enabled. Perhaps some other steps are necessary as well. Like adding permissions to android.hardware.usb.host

    Update: 22.03.2021 I figured it is (was) a speed reporting issue from emulator qemu. Now with the Emulator Version 30.5.3 this issue is fixed and it works with all my UVC Standard cameras, on EHCI und XHCI. Also the built in Face Time Camera works as USB attached Device. But, only two Apps from the PlayStore were able to show me the footage. USB Camera - Connect EasyCap or USB WebCam very smooth and nice footage. UVC Camera / Usb Camera with driver from userspace with hugh jitter.