webcam uvc

i want to use gadget to change tx2 connect by usb to host,and host can detect a usb camera,how can i do that ?

i have alread insmod uvc.ko and other need ko,but i do not know how to change this mode by cmdline

i am trying to use this /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode.sh

but it does not work,any one can help me ?

if [ ${enable_uvc} -eq 1 ]; then
cfg_str=“${cfg_str}+UVC”
func=functions/uvc.video0
mkdir -p “${func}”
ln -sf “${func}” “${cfg}”
fi

the dmesg give back some errors when start

[ 7.619919] configfs-gadget gadget: uvc_function_bind
[ 7.619924] configfs-gadget gadget: Unable to allocate streaming EP

Hi seasonkky,
We have verified mass storage:
[url]https://devtalk.nvidia.com/default/topic/1014096/jetson-tx2/how-to-set-tx2-otg-usb-as-device-mode-/post/5192587/#5192587[/url]
[url]https://devtalk.nvidia.com/default/topic/1014096/jetson-tx2/how-to-set-tx2-otg-usb-as-device-mode-/post/5205500/#5205500[/url]

Other users may share expereice about your case.

Hi DaneLLL:

thank you for reply.

i have already update my tx2 to R28.2 by jetpack 3.2 and i see the scripts under /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode.sh ,it can set usb mode with otg well

but my problem is how set gadget mode into f_uvc , when i try to enable uvc,i get the error message as below

if [ ${enable_uvc} -eq 1 ]; then
cfg_str=“${cfg_str}+UVC”
func=functions/uvc.usb0
mkdir -p “${func}”
ln -sf “${func}” “${cfg}”
fi

the dmesg give back some errors when start

[ 7.619919] configfs-gadget gadget: uvc_function_bind
[ 7.619924] configfs-gadget gadget: Unable to allocate streaming EP

The default on R28.2 is for mass storage, which is bulk mode and is not streaming or isochronous. I’m not even sure if that port is able to run isochronous, it might be it isn’t supported…but if it is, then you’d have to set it up for that (gadget is just a framework, it isn’t end code).

hi linuxdev:

how can i change the mode to streaming or isochronous,i want my host can check a device named with uvc camera .

but it can’t work at now

only showing Unable to allocate streaming EP

You’d have to learn the gadget framework…you’re building a custom device. There is no easy answer to that. See:
[url]https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt[/url]
[url]http://www.linux-usb.org/gadget/[/url]

The problem is that I’m not certain that the TX2 supports isochronous mode. If this is the case, then it isn’t possible without a custom add-on card. Someone would need to verify if isochronous mode is even possible with the micro-USB connector in device mode.

NOTE: I say isochronous assuming this is full motion UVC video. A camera with snapshots can be bulk mode.

hi linuxdev:

thank you very much

but i also don’t know why i can’t bind tx2 on board camera into uvc mode

i read the Documents about gadget-testing.txt on UVC config

if [ ${enable_uvc} -eq 1 ]; then
cfg_str=“${cfg_str}+UVC”
func=functions/uvc.usb0
mkdir -p “${func}”

mkdir -p functions/uvc.usb0/control/header/h
cd functions/uvc.usb0/control/
ln -s header/h class/s
cd $GADGET_CONFIGFS_ROOT
mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p
cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval
666666
1000000
5000000

EOF

mkdir -p functions/uvc.usb0/streaming/header/h
cd functions/uvc.usb0/streaming/header/h
ln -s ../../uncompressed/u
cd $GADGET_CONFIGFS_ROOT
pwd
cd functions/uvc.usb0/streaming/class/ss
ln -s ../../header/h
cd ../../../../../
ln -sf "${func}" "${cfg}"

fi

I don’t know if the hardware and drivers are actually capable of isochronous device mode on this port. It might be that this is not possible.

anyone can tell to me if the usb2.0 port can support streaming or not?

I am just wondering if the otg-mass-storage will work if just executed the below script, without sophisticated dtb substitution and kernel re compilation:

sudo ./opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode.sh

Thanks.

The stuff in “/opt/nvidia/l4t-usb-device-mode/” (R28.2) is fairly interesting. People interested in OTG should dig around in that, there is a lot of useful stuff there.

In R28.2 it looks like the micro-USB port is already acting as mass storage by default when a type-B connector is used (the “/opt” script is already running once multi-user.target stage is reached during boot). I find that if I connect the micro-B USB from a running Jetson to my host the host sees a new device “/dev/sdf” (no partitions…the “f” because I have sda through sde already filled), and that I can “sudo mount /dev/sdf /mnt”. Two files show up there: “l4t-serial.inf” and “README.txt”. Those two files are not directly on the Jetson’s file system, so those would be from some loopback mounted file on the TX2.

One of the “/opt/nvidia/l4t-usb-device-mode/” files seems to be for setup of start or stop of the mode. The file “/opt/nvidia/l4t-usb-device-mode/filesystem.img” seems to be the loopback file. It looks like there is also simultaneously a USB ethernet device configured (the USB cable can have more than one device, the example has set up both ethernet and bulk storage).

Those files are by default via symbolic links here:

/etc/systemd/system/nv-l4t-usb-device-mode.service
/etc/systemd/system/multi-user.target.wants/nv-l4t-usb-device-mode.service

So far as the original post’s question goes I still do not know if this could be altered to become a webcam because I do not know if the isochronous mode required is possible with that port. Those files though might be a good place to experiment.

“i want to use gadget to change tx2 connect by usb to host,and host can detect a usb camera,how can i do that ?”

I have recently heard [actually seen] the project concerned in delivering usb over ip;
hm

the issue with host pc detecting jetson as a camera is that jetson camera does’nt appear to be usb camera.

if you just want to see the output of the camera at the host and you want to use usb for that:

it seems that usb can be used as ethernet [from the linuxdev post above, I’ve made such conclusion "USB ethernet device configured "]

and if usb works as ethernet then you can get at the host the camera stream via gstreamer network streaming with rtsp, as it seems to me.

However, I would just create a network streaming.

Then may be somehow the stream could be looped to a virtual interface at the host pc and that will make the Jetson camera to act as the host pc camera.

The above is just a rough idea though. I did not implement that.

Hi Andrey1984:

i have used bulk mode to register a v4l2 device,and now i can see the /dev/video1 ,then i use uvc-gadget to start the devices,my host pc can attach a new uvc device,but it have some errors need to be fixed

Hi seasonkky,

Jetson family does not support isochronous transfers only bulk mode. Also, the userspace application is critical to complete the USB enumeration as a UVC device. You can take a look at this link, here are some videos that show how to use a Jetson Xavier as a UVC device and capture video from it. It is the same for the older versions (TX1/TX2).

Best Regards,

However, there is an option to mount network camera that streams e.g. using rtsp “test-launch” and get it mounted as /dev/videoX

hello everyone, I’m new with jetson tx2.
I need to configure the USB OTG port in a UVC because I would like to transfer a video stream to the output, I have a jetson tx2 developer kit with jetpack 4.3 installed. Can anyone help me configure the usb port as a UVC gadget?

You will already find some sample setup in “/opt/nvidia/l4t-usb-device-mode/”, although this is only for mass storage and network device emulation. In general, this is the topic of the Linux “gadget” framework, and so you can search for “linux kernel gadget” and information will be available (best to use information associated with your kernel version).

Do note that one limitation is that this port cannot operate in isochronous mode (“transfer type” might need to be bulk).