Hi,
I am trying to create a "virtual webcam" on a Raspberry Pi Zero 2 W with Ubuntu 24.10.
I am working through this tutorial:
https://developer.ridgerun.com/wiki/ind ... r_in_Linux
where they want to create a "virtual webcam" to stream video as if it was coming from a locally attached camera.
I ran through the script (attached below) all the way to the end and everything worked, but the device is not showing up on my mac as a USB device. I have been able to configure this same device as a g_ether gadget by just loading the modules, and it enumerates on the mac, so I know that my hardware/cabling is correct.
The dmesg is showing:
[ 923.318812] configfs-gadget.g1 gadget.0: uvc: uvc_function_bind() [ 923.320674] dwc2 3f980000.usb: bound driver configfs-gadget.g1
However, the mac does not see it show up: % system_profiler SPUSBDataType USB:
USB 3.1 Bus:
Host Controller Driver: AppleT6000USBXHCI
USB 3.1 Bus:
Host Controller Driver: AppleT6000USBXHCI
USB 3.1 Bus:
Host Controller Driver: AppleT6000USBXHCI
I saw the note about needing to do:
echo peripheral > $UDC_ROLE
and I suspect that is where the problem lies in that it is not setting the device in peripheral mode, even though I did specify that in /boot/firmware/config.txt as dr_mode=peripheral.
The script points set UDC Role like: UDC_ROLE=/sys/devices/platform/soc/78d9000.usb/ci_hdrc.0/role
Since my controller is 3f980000.usb, I went in to /sys/devices/platform/soc/3f980000.usb but there is no ci_hdrc.0 folder and I searched for a file named role, but nothing was found:
root@raspberrypi:/sys/devices/platform/soc/3f980000.usb# find . -name role -print root@raspberrypi:/sys/devices/platform/soc/3f980000.usb# find . -name udc -print ./udc
Any guidance on this would be great!
script:
I have tried configuring the device in both g_webcam and in configfs (per the script) and in both cases, the device shows up as being bound to the UDC in dmesg, but the device is not being seen in the host (mac).
I have tried using Raspberry Pi OS Lite 64 (Debian 12 Bookworm) and Ubuntu 24.10 and get the same results. It will enumerate as g_ether, but not g_webcam or through configfs.
I am trying to create a "virtual webcam" on a Raspberry Pi Zero 2 W with Ubuntu 24.10.
I am working through this tutorial:
https://developer.ridgerun.com/wiki/ind ... r_in_Linux
where they want to create a "virtual webcam" to stream video as if it was coming from a locally attached camera.
I ran through the script (attached below) all the way to the end and everything worked, but the device is not showing up on my mac as a USB device. I have been able to configure this same device as a g_ether gadget by just loading the modules, and it enumerates on the mac, so I know that my hardware/cabling is correct.
The dmesg is showing:
[ 923.318812] configfs-gadget.g1 gadget.0: uvc: uvc_function_bind() [ 923.320674] dwc2 3f980000.usb: bound driver configfs-gadget.g1
However, the mac does not see it show up: % system_profiler SPUSBDataType USB:
USB 3.1 Bus:
Host Controller Driver: AppleT6000USBXHCI
USB 3.1 Bus:
Host Controller Driver: AppleT6000USBXHCI
USB 3.1 Bus:
Host Controller Driver: AppleT6000USBXHCI
I saw the note about needing to do:
echo peripheral > $UDC_ROLE
and I suspect that is where the problem lies in that it is not setting the device in peripheral mode, even though I did specify that in /boot/firmware/config.txt as dr_mode=peripheral.
The script points set UDC Role like: UDC_ROLE=/sys/devices/platform/soc/78d9000.usb/ci_hdrc.0/role
Since my controller is 3f980000.usb, I went in to /sys/devices/platform/soc/3f980000.usb but there is no ci_hdrc.0 folder and I searched for a file named role, but nothing was found:
root@raspberrypi:/sys/devices/platform/soc/3f980000.usb# find . -name role -print root@raspberrypi:/sys/devices/platform/soc/3f980000.usb# find . -name udc -print ./udc
Any guidance on this would be great!
script:
Code:
#!/bin/bash# Variables we need to make things easier later on.#set -e# First load the libcomposite modulemodprobe libcompositeUDC=`ls /sys/class/udc`UDC_ROLE=/sys/devices/platform/soc/78d9000.usb/ci_hdrc.0/roleCONFIGFS="/sys/kernel/config"GADGET="$CONFIGFS/usb_gadget"VID="0x0525"PID="0x0102"SERIAL="0123456789"MANUF=$(hostname)PRODUCT="UVC Gadget"mkdir -p $GADGET/g1cd $GADGET/g1echo $VID > idVendorecho $PID > idProductmkdir -p strings/0x409echo $SERIAL > strings/0x409/serialnumberecho $MANUF > strings/0x409/manufacturerecho $PRODUCT > strings/0x409/productmkdir configs/c.1mkdir configs/c.1/strings/0x409CONFIG="configs/c.1"FUNCTION="uvc.0"mkdir functions/$FUNCTIONmkdir -p functions/$FUNCTION/streaming/uncompressed/u/360pcat <<EOF > functions/$FUNCTION/streaming/uncompressed/u/360p/dwFrameInterval66666610000005000000EOFmkdir functions/$FUNCTION/streaming/header/hcd functions/$FUNCTION/streaming/header/hln -s ../../uncompressed/ucd ../../class/fsln -s ../../header/hcd ../../class/hsln -s ../../header/hcd ../../class/ssln -s ../../header/hcd ../../../controlmkdir -p header/hln -s header/h class/fsln -s header/h class/sscd ../../../echo 2048 > functions/$FUNCTION/streaming_maxpacketln -s functions/$FUNCTION configs/c.1echo $UDC > UDCecho "Done. Listing /dev/video*"ls /dev/video*
I have tried using Raspberry Pi OS Lite 64 (Debian 12 Bookworm) and Ubuntu 24.10 and get the same results. It will enumerate as g_ether, but not g_webcam or through configfs.
Statistics: Posted by meydey — Thu Dec 05, 2024 9:59 pm