UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor nicothenico
Visitor
15,283 Views
Registered: ‎02-12-2015

ZC702 as UVC Device (USB Webcam)

Jump to solution

Hi,

 

Good day! I'm very new to ZYNQ and Linux development in general. But could someone provide some insight on how to go about implementing the ZYNQ board to act as a UVC device, i.e. USB webcam?

 

Basically what I want to do is connect my ZYNQ board to a host PC via USB connection and run an app, like Skype or VLC, and stream live video from the ZYNQ board. The PC will have the ZYNQ board be enumerated as a UVC device.

 

From what I have read here, I have to setup the board in Peripheral mode and install UVC modules. I've been searching for resources about UVC modules but came up empty.

 

Would really appreciate any help.

 

Thanks,

Nico

0 Kudos
1 Solution

Accepted Solutions
Visitor nicothenico
Visitor
24,393 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

I've just successfully streamed video on a Windows 7 and Ubuntu host PC using the Zynq board configured as a UVC device. I had to patch the UVC functions for the g_webcam module in the Xilinx Linux kernel. Thanks.

0 Kudos
14 Replies
Visitor nicothenico
Visitor
15,263 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

I found a module named "USB Webcam Gadget" under menuconfig "USB Gadget Support". Anyone know I can set this up?

Source code: https://github.com/Xilinx/linux-xlnx/blob/master/drivers/usb/gadget/legacy/webcam.c

0 Kudos
Visitor nicothenico
Visitor
15,213 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

So I was able to build and load the g_webcam.ko module on the ZYNQ board successfully. 

 

ZYNQ:

[ 38.647018] g_webcam gadget: uvc_function_bind
[ 38.647018] ------------[ cut here ]------------
[ 38.647019] WARNING: CPU: 1 PID: 866 at drivers/media/v4l2-core/videobuf2-core.c:2124 vb2_queue_init+0xc0/0x124()
[ 38.647021] Modules linked in: g_webcam(+) videobuf2_vmalloc usb_f_ss_lb libcomposite ipv6
[ 38.647022] CPU: 1 PID: 866 Comm: insmod Not tainted 3.13.0-xilinx #14
[ 38.647023] [<c0015598>] (unwind_backtrace+0x0/0x11c) from [<c00118d0>] (show_stack+0x10/0x14)
[ 38.647025] [<c00118d0>] (show_stack+0x10/0x14) from [<c048c09c>] (dump_stack+0x8c/0xd0)
[ 38.647026] [<c048c09c>] (dump_stack+0x8c/0xd0) from [<c0022550>] (warn_slowpath_common+0x60/0x84)
[ 38.647027] [<c0022550>] (warn_slowpath_common+0x60/0x84) from [<c0022604>] (warn_slowpath_null+0x18/0x20)
[ 38.647029] [<c0022604>] (warn_slowpath_null+0x18/0x20) from [<c037b100>] (vb2_queue_init+0xc0/0x124)
[ 38.647030] [<c037b100>] (vb2_queue_init+0xc0/0x124) from [<bf099694>] (uvc_function_bind+0x32c/0x4bc [g_webcam])
[ 38.647032] [<bf099694>] (uvc_function_bind+0x32c/0x4bc [g_webcam]) from [<bf0789dc>] (usb_add_function+0x98/0x17c [libcomposite])
[ 38.647034] [<bf0789dc>] (usb_add_function+0x98/0x17c [libcomposite]) from [<bf0999b4>] (uvc_bind_config+0x190/0x220 [g_webcam])
[ 38.647036] [<bf0999b4>] (uvc_bind_config+0x190/0x220 [g_webcam]) from [<bf099a6c>] (webcam_config_bind+0x28/0x34 [g_webcam])
[ 38.647038] [<bf099a6c>] (webcam_config_bind+0x28/0x34 [g_webcam]) from [<bf0794c8>] (usb_add_config+0x68/0x270 [libcomposite])
[ 38.647040] [<bf0794c8>] (usb_add_config+0x68/0x270 [libcomposite]) from [<bf09932c>] (webcam_bind+0x44/0x80 [g_webcam])
[ 38.647041] [<bf09932c>] (webcam_bind+0x44/0x80 [g_webcam]) from [<bf07aaac>] (composite_bind+0x80/0x190 [libcomposite])
[ 38.647043] [<bf07aaac>] (composite_bind+0x80/0x190 [libcomposite]) from [<c03426f4>] (udc_bind_to_driver+0x54/0x100)
[ 38.647045] [<c03426f4>] (udc_bind_to_driver+0x54/0x100) from [<c0342a40>] (usb_gadget_probe_driver+0x94/0xc0)
[ 38.647046] [<c0342a40>] (usb_gadget_probe_driver+0x94/0xc0) from [<c0008800>] (do_one_initcall+0xb8/0x160)
[ 38.647048] [<c0008800>] (do_one_initcall+0xb8/0x160) from [<c00827a4>] (load_module+0x1744/0x1d48)
[ 38.647049] [<c00827a4>] (load_module+0x1744/0x1d48) from [<c0082ea4>] (SyS_init_module+0xfc/0x10c)
[ 38.647051] [<c0082ea4>] (SyS_init_module+0xfc/0x10c) from [<c000e5a0>] (ret_fast_syscall+0x0/0x48)
[ 38.647052] ---[ end trace f7d639807cd7bf98 ]---
[ 38.647054] g_webcam gadget: Webcam Video Gadget
[ 38.647054] g_webcam gadget: g_webcam ready
[ 38.647055] zynq-udc: bind to driver g_webcam
root@zynq:/mnt/card# [ 38.647080] g_webcam gadget: high-speed config #1: Video
[ 38.647081] g_webcam gadget: uvc_function_set_alt(0, 0)
[ 38.647082] g_webcam gadget: uvc_function_set_alt(1, 0)
[ 38.647083] g_webcam gadget: uvc_function_set_alt(1, 0)
[ 38.647086] g_webcam gadget: uvc_function_set_alt(1, 0)

 

The host PC detected the board as a UVC device. However, there seems to be some driver issues.

 

Host PC:

usb 1-1: new high speed USB device using ehci_hcd and address 9
usb 1-1: configuration #1 chosen from 1 choice
uvcvideo: Found UVC 1.00 device Webcam gadget (1d6b:0102)
uvcvideo: Failed to query (135) UVC control 1 (unit 0) : -110 (exp. 26).
psmouse.c: Wheel Mouse at isa0060/serio1/input0 lost synchronization, throwing 1 bytes away.
uvcvideo: Failed to query (129) UVC control 1 (unit 0) : -110 (exp. 26).
uvcvideo: Failed to initialize the device (-5).
usb 1-1: New USB device found, idVendor=1d6b, idProduct=0102
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: Webcam gadget
usb 1-1: Manufacturer: Linux Foundation
psmouse.c: resync failed, issuing reconnect request

 

The cheese program is also unable to detect a camera source. Anyone kind enough to help?

 

I'm using the xilinx-v2014.1 tagged source by the way. 

 

Thanks.

0 Kudos
Visitor nicothenico
Visitor
15,086 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

I've already tried the old g_webcam module and the new configfs approach (I had to apply uvcvideo and configfs uvc patches). I tried various kernels starting from v14.7 to the master. I tried different version of the uvc-gadget app. But, I still can't get any stream.

 

Has anyone ever done this on the ZC702 board?

0 Kudos
Visitor nicothenico
Visitor
24,394 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

I've just successfully streamed video on a Windows 7 and Ubuntu host PC using the Zynq board configured as a UVC device. I had to patch the UVC functions for the g_webcam module in the Xilinx Linux kernel. Thanks.

0 Kudos
Newbie raghukiran
Newbie
14,202 Views
Registered: ‎06-28-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

Hi All,

 

Could you please share the patch which is working. I'm able to compile the webcam.c but getting kernel panic when i enable webcam function. It is much appriciated if you can share the patch.

 

 

BR,

Raghu Kiran A

0 Kudos
Visitor nicothenico
Visitor
8,349 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

It's been a while but for everyone's reference:

 

Basically I had to patch the xilinx-v2014.4 kernel. Applied the patches from http://www.spinics.net/lists/linux-usb/msg93556.html to the f_uvc.c, uvc.h and uvc_v4l2.c files in drivers\usb\gadget\function. These patches implement streaming format negotiation in the driver instead of in the uvc-gadget application. Then used the uvc-gadget app with patches from http://www.spinics.net/lists/linux-usb/msg99220.html.

0 Kudos
Observer mattsini1
Observer
8,187 Views
Registered: ‎03-02-2017

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

Hi, can you explain how can do that?

I've build the kernel from git repo but some modules like g_webcam aren't loaded.

How i can load this module and set the board as UVC device as you did?

 

Would really appreciate any help.

 

Thanks a lot,

Mattia.

0 Kudos
Visitor nicothenico
Visitor
8,163 Views
Registered: ‎02-12-2015

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

You need to setup the xilinx-v2014.4 kernel so modules, like g_webcam, are included in the build process (menuconfig). If you haven't yet, you should read up on the System Software Development section from http://www.wiki.xilinx.com/Getting+Started. Unfortunately, I haven't done any development related to Zynq in years so I don't know what has changed since then.

0 Kudos
Observer mattsini1
Observer
7,899 Views
Registered: ‎03-02-2017

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

Hi @nicothenico, I setted the dr_mode="peripheral" in the dts and then i maked the devicetree.

After that i compiled the kernel and load the module but it is unable to bind the driver with the gadget.

I don't receive all of this as you:

[ 38.647055] zynq-udc: bind to driver g_webcam
root@zynq:/mnt/card# [ 38.647080] g_webcam gadget: high-speed config #1: Video
[ 38.647081] g_webcam gadget: uvc_function_set_alt(0, 0)
[ 38.647082] g_webcam gadget: uvc_function_set_alt(1, 0)
[ 38.647083] g_webcam gadget: uvc_function_set_alt(1, 0)
[ 38.647086] g_webcam gadget: uvc_function_set_alt(1, 0)

 

Do you think i missed something?

This is what i have:

 

zynq> cd home                                                                   
zynq> ls                                                                        
default               g_webcam.ko           usb_f_fs.ko                         
g_ffs.ko              gadgetfs.ko           usb_f_uvc.ko                        
g_mass_storage.ko     libcomposite.ko       videobuf2-vmalloc.ko                
zynq> insmod libcomposite.ko                                                    
zynq> insmod videobuf2-vmalloc.ko                                               
zynq> insmod usb_f_fs.ko                                                        
zynq> insmod usb_f_uvc.ko                                                       
zynq> insmod g_webcam.ko                                                        
g_webcam gadget: uvc_function_bind                                              
g_webcam gadget: Webcam Video Gadget                                            
g_webcam gadget: g_webcam ready        
                                         
zynq> 

 

After all, it seems that the gadget is created but it still not bind to driver and obiviously when i try to connect the boart to the host, nothing happen and the board is not detected.

Thanks.

-Mattia

0 Kudos
3,316 Views
Registered: ‎09-25-2014

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution
Hi nicothenico,
I want to do video from webcamera interfacing with Zynq board. Can you tell what is the process i have follow. I am very new in this platform.
0 Kudos
Visitor jihen.thabet
Visitor
2,972 Views
Registered: ‎09-26-2017

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

Hi ,

I want that my ZYNQ board act as a UVC device under windows .

 

could you help me?

 

Thanks

0 Kudos
Visitor charlie0611
Visitor
2,418 Views
Registered: ‎08-02-2018

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

Hi Nico,

 

I'm trying to get this to work on the ZCU106 on the 2018.1 build for the VCU Targeted Reference Design (TRD).

 

This uses the 2018.1 kernel, and I had to hand apply the kernel patches referenced here:

 http://www.spinics.net/lists/linux-usb/msg93556.html

 

 

The uvc-gadget app patches that you referenced list only the number of changes in each file, not a .patch file or the actual diffs.

 http://www.spinics.net/lists/linux-usb/msg99220.html

 

Do you have the .patch files, or the actual file changes. I am not able to build the stock uvc-gadget.c  from the git://git.ideasonboard.org/uvc-gadget.git repo.

 

Am I missing something? Can you point me to the actual .patch file or the diffs so that I can hand patch

 

Thanks,

Charlie Hamilton

0 Kudos
Visitor iamjy1005
Visitor
1,133 Views
Registered: ‎04-05-2019

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

I have the same issue. How could you solve it?

Thanks.

0 Kudos
Visitor iamjy1005
Visitor
1,132 Views
Registered: ‎04-05-2019

Re: ZC702 as UVC Device (USB Webcam)

Jump to solution

I have the same issue. How could you solve it?

Thanks.

 

==============================================

I setted the dr_mode="peripheral" in the dts and then i maked the devicetree.

After that i compiled the kernel and load the module but it is unable to bind the driver with the gadget.

I don't receive all of this as you:

[ 38.647055] zynq-udc: bind to driver g_webcam
root@zynq:/mnt/card# [ 38.647080] g_webcam gadget: high-speed config #1: Video
[ 38.647081] g_webcam gadget: uvc_function_set_alt(0, 0)
[ 38.647082] g_webcam gadget: uvc_function_set_alt(1, 0)
[ 38.647083] g_webcam gadget: uvc_function_set_alt(1, 0)
[ 38.647086] g_webcam gadget: uvc_function_set_alt(1, 0)

 

Do you think i missed something?

This is what i have:

 

zynq> cd home
zynq> ls
default g_webcam.ko usb_f_fs.ko
g_ffs.ko gadgetfs.ko usb_f_uvc.ko
g_mass_storage.ko libcomposite.ko videobuf2-vmalloc.ko
zynq> insmod libcomposite.ko
zynq> insmod videobuf2-vmalloc.ko
zynq> insmod usb_f_fs.ko
zynq> insmod usb_f_uvc.ko
zynq> insmod g_webcam.ko
g_webcam gadget: uvc_function_bind
g_webcam gadget: Webcam Video Gadget
g_webcam gadget: g_webcam ready
zynq>

 

After all, it seems that the gadget is created but it still not bind to driver and obiviously when i try to connect the boart to the host, nothing happen and the board is not detected.

Thanks.

0 Kudos