UVC gadget device Jetson Nano

Hello,

I try to mount the jetson nano like an uvc gadget device to a a laptop but it doesn’t worked.

cd /sys/kernel/config/usb_gadget
sudo mkdir g1

mkdir: cannot create directory ‘g1’: Cannot allocate memory

dmesg:

[ 1316.660535] sysfs: cannot create duplicate filename ‘/devices/virtual/android_usb/android0’
[ 1316.669043] ------------[ cut here ]------------
[ 1316.673683] WARNING: CPU: 2 PID: 7446 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/fs/sysfs/dir.c:31 sysfs_warn_dup+0x68/0x88
[ 1316.685671] Modules linked in: fuse zram overlay spidev nvgpu bluedroid_pm ip_tables x_tables [last unloaded: v4l2loopback]

[ 1316.685786] CPU: 2 PID: 7446 Comm: mkdir Tainted: G W O 4.9.140-tegra #1
[ 1316.685797] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[ 1316.685809] task: ffffffc0ccd8e200 task.stack: ffffffc0f7c64000
[ 1316.685828] PC is at sysfs_warn_dup+0x68/0x88
[ 1316.685845] LR is at sysfs_warn_dup+0x68/0x88
[ 1316.685859] pc : [] lr : [] pstate: 40400145
[ 1316.685868] sp : ffffffc0f7c67a80
[ 1316.685878] x29: ffffffc0f7c67a80 x28: 00000000ffffffff
[ 1316.685907] x27: ffffffc0c8760700 x26: 0000000000000000
[ 1316.685932] x25: 0000000000000000 x24: 0000000000000000
[ 1316.685956] x23: 0000000000000000 x22: ffffffc0f4399700
[ 1316.685979] x21: ffffffc0f4eb23c0 x20: ffffff800948e710
[ 1316.686001] x19: ffffffc0f2c60000 x18: 0000000000000010
[ 1316.686024] x17: 0000000000000000 x16: 0000000000000000
[ 1316.686046] x15: ffffffffffffffff x14: 6c6175747269762f
[ 1316.686068] x13: 736563697665642f x12: 2720656d616e656c
[ 1316.686090] x11: 6966206574616369 x10: 0000000000000372
[ 1316.686113] x9 : 65726320746f6e6e x8 : ffffff80083d47b0
[ 1316.686135] x7 : ffffff8009e94358 x6 : ffffffc0fefe7bf0
[ 1316.686157] x5 : ffffffc0fefe7bf0 x4 : 0000000000000000
[ 1316.686179] x3 : ffffffc0fefed7f8 x2 : ffffffc0fefe7bf0
[ 1316.686201] x1 : ffffffc0ccd8e200 x0 : 000000000000004f

[ 1316.686232] —[ end trace 7578c5a09c1fa400 ]—
[ 1316.690868] Call trace:
[ 1316.690890] [] sysfs_warn_dup+0x68/0x88
[ 1316.690910] [] sysfs_create_dir_ns+0x9c/0xb0
[ 1316.690937] [] kobject_add_internal+0x98/0x348
[ 1316.690954] [] kobject_add+0x88/0xf0
[ 1316.690979] [] device_add+0xe8/0x5d8
[ 1316.690998] [] device_create_groups_vargs+0x124/0x130
[ 1316.691015] [] device_create+0x8c/0xa0
[ 1316.691038] [] gadgets_make+0x260/0x338
[ 1316.691056] [] configfs_mkdir+0x138/0x4b8
[ 1316.691079] [] vfs_mkdir2+0x13c/0x1e8
[ 1316.691093] [] SyS_mkdirat+0x88/0xf8
[ 1316.691113] [] el0_svc_naked+0x34/0x38
[ 1316.691274] kobject_add_internal failed for android0 with -EEXIST, don’t try to register things with the same name in the same directory

Could you help me ?

Thanks.

In device mode a video stream uses “isochronous” transfer mode (a continuous real time stream with reserved bandwidth). Jetsons are unable to become an isochronous mode device (you can plug an isochronous device into the Jetson and use that, but you cannot emulate an isochronous device on any of the current Jetsons). This is a hardware limitation.

Ok but according to this website the jetson nano and xavier seems to be compatible with uvc gadget:

https://developer.ridgerun.com/wiki/index.php?title=USB_Video_Class_Gadget_Library_-_libguvc

And ok isochronous not compatible. So according to you there are using bulk mode ?

There is a video about the functionality.

Those Jetsons can use USB UVC devices. Unless isochronous mode is not used, then the Jetsons cannot emulate those devices with gadget. Some video devices may use an alternate mode as a workaround, e.g., bulk, but there is no ability for the hardware itself to work as (“pretend to be”) an isochronous mode device of any kind. I am not sure what the URL is actually suggesting, but it would depend on the device being emulated as not using isochronous mode. This is a hardware limitation, and so different modes are the only possible workaround.

Hi,

The UVC specification is not limited to Isochronous mode only, it actually suggests the UVC mode can be used in either Isochronous and Bulk mode. From the UVC specification UVC v1.1:

“Each VideoStreaming interface can have one isochronous or bulk data endpoint for video”

Despite Isochronous is preferred for a wide range of reasons including the reserved bandwidth, there are cases where bulk transfer is the way to go (like in the case of Jetson family due to the lack of Isochronous transfer support).

In all the videos shown at:

https://developer.ridgerun.com/wiki/index.php?title=USB_Video_Class_Gadget_Library_-_libguvc

We enabled bulk support for the Jetson family in order to get the UVC functionality working.

Best Regards,

I guess a good question then would be whether this particular gadget is programmed to emulate bulk or isochronous mode…the former can work, the latter cannot.

Hi linuxdev,

Indeed, the mainstream UVC gadget driver is designed to work with isochronous transfers, however it is possible to use it in bulk mode with some modifications.

Best Regards,

Lacking those modifications could possibly lead to the given error, at least on Tegra hardware, but I’ve never modified isochronous gadgets for bulk mode. I couldn’t guarantee this is the problem, but odds are this would have to be addressed anyway.