Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Introduction

  • The USB controller can be configured as host, device, or on-the-go (OTG).

  • The core is compliant to USB 2.0 specification and supports high, full, and low-speed modes in all configurations.

  • In host mode, the USB controller is compliant with the Intel XHCI specification. In device mode, it supports up to 12 end points.

  • The universal low peripheral interface (ULPI) is used to connect the controller to an external PHY operating up to 480 Mb/s.

  • Versal supports only USB 2.0 protocol.

  • Provided below test cases are proven on vck190-es1 board with 2021.1 release.

...

ZynqMP Vs Versal USB controller support

Peripheral

Zynq UltraScale+ MPSOC

Versal ACAP

USB 3.0 (host, device, dual-role device)

2 controllers

N/A

Usb 2.0 (host, device, on-the-go)

2 controllers

1 controller

Hardware Setup

Boards:  VCK190-ES1 Board

...

Code Block
breakoutModefull-width
[28962.568558] usb 1-3.3: new high-speed USB device number 27 using xhci_hcd
[28962.585670] usb 1-3.3: New USB device found, idVendor=0101, idProduct=1d6b
[28962.585691] usb 1-3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[28962.585706] usb 1-3.3: Product: XilinxTest - HID Audio
[28962.585720] usb 1-3.3: Manufacturer: Xilinx
[28962.585734] usb 1-3.3: SerialNumber: Xilinx_1234567890
[28962.653843] usbcore: registered new interface driver snd-usb-audio

UVC Gadget

Kernel configurations

...

Code Block
CONFIG_USB_DWC3 = y
CONFIG_USB_DWC3=y
CONFIG_USB_DWC3_DUAL_ROLE=y
CONFIG_USB_DWC3_HAPS=y
CONFIG_USB_DWC3_OF_SIMPLE=y
CONFIG_USB_DWC3_XILINX=y
CONFIG_USB_GADGET_XILINX=y
CONFIG_USB_GADGETFS=m
CONFIG_USB_FUNCTIONFS=m
CONFIG_USB_G_WEBCAM=m
CONFIG_USB_ROLE_SWITCH=y

CONFIG_V4L_TEST_DRIVERS=y
# CONFIG_VIDEO_VIMC is not set
CONFIG_VIDEO_VIVID=m
CONFIG_VIDEO_VIVID_CEC=y
CONFIG_VIDEO_VIVID_MAX_DEVS=64
CONFIG_VIDEO_VIM2M=m

# USB HID support
CONFIG_USB_HID=y
# CONFIG_HID_PID is not set
# CONFIG_USB_HIDDEV is not set
CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y

# Miscellaneous USB options
CONFIG_USB_DEFAULT_PERSIST=y
CONFIG_USB_OTG=y
CONFIG_USB_OTG_FSM=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_XHCI_PLATFORM=y
CONFIG_USB_STORAGE=y

# USB Physical Layer drivers

CONFIG_USB_PHY=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DEBUG_FS=y
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2

CONFIG_USB_LIBCOMPOSITE=y
CONFIG_USB_U_ETHER=y
CONFIG_USB_F_RNDIS=y
CONFIG_USB_F_MASS_STORAGE=y
CONFIG_USB_F_FS=y
CONFIG_USB_F_UVC=y
CONFIG_USB_F_HID=y
CONFIG_USB_CONFIGFS=y
CONFIG_USB_CONFIGFS_RNDIS=y
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
CONFIG_USB_CONFIGFS_F_FS=y
CONFIG_USB_CONFIGFS_F_HID=y
CONFIG_USB_CONFIGFS_F_UVC=y
CONFIG_USB_CONFIGFS_F_UAC1=y
CONFIG_USB_PHY=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DEBUG_FS=y
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
CONFIG_U_SERIAL_CONSOLE=y

For reference Attaching complete kernel config file: 

View file
namekernel_config.txt

Device Tree 

Edit the following file and make the following changes.

<path to petalinux project >/project-spec/meta-user/recipe-bsp/device-tree/system-user.dtsi

...

Steps to add uvc-gadget test application to petalinux project

  1. Create an empty app and populate with uvc-gadget test application

petalinux-create -t apps -n uvc-gadget --enable

2. Clone the source repo in the app file folder

git clone https://github.com/wlhe/uvc-gadget.git project-spec/meta-user/recipes-apps/uvc-gadget/files/

3. Edit the recipe to add the appropriate files to the build

"project-spec/meta-user/recipes-apps/uvc-gadget/uvc-gadget.bb"

SUMMARY = "Simple uvc-gadget application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://uvc-gadget.c
file://uvc.h
file://Makefile
"
#INHIBIT_PACKAGE_STRIP = 1

S = "${WORKDIR}"

do_compile() {
oe_runmake
}

do_install() {
install -d ${D}${bindir}
install -m 0755 uvc-gadget ${D}${bindir}
}

4. Edit the Makefile so that it works with Petalinux

“project-spec/meta-user/recipes-apps/uvc-gadget/files/Makefile”

APP = uvc-gadget

APP_OBJS = uvc-gadget.o

all: $(APP)

$(APP): $(APP_OBJS)
$(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

clean:
-rm -f $(APP) *.elf *.gdb *.o

Steps to test UVC Gadget

When the Linux kernel boots up, give the below commands:

Code Block
modprobe usb_f_fs
modprobe g-webcam streaming_maxburst=15
modprobe vivid
uvc-gadget -u /dev/video0 -v /dev/video1 -t 15 -r 0 -n 2 &

Steps on Windows/Ubuntu Host:
Open zoom app -> settings -> video -> Select Camera as "UVC Camera"or use VLC Player 

Logs

Code Block
root@xilinx-vck190-es1-2021_2:~# cd /lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/
gadget/ misc/
root@xilinx-vck190-es1-2021_2:~# cd /lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget# ls
function  legacy
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget# cd legacy/
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy# ls
g_ether.ko         g_ffs.ko           g_mass_storage.ko  g_printer.ko       g_webcam.ko        gadgetfs.ko
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy# modprobe g_ffs.ko
[   82.509688] file system registered
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy# modprobe g_webcam
[   93.901622] g_webcam gadget: uvc: uvc_function_bind()
[   93.906865] g_webcam gadget: Webcam Video Gadget
[   93.911498] g_webcam gadget: g_webcam ready
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy# modprobe vivid
[  100.229052] vivid-000: using single planar format API
[  100.236189] vivid-000: CEC adapter cec0 registered for HDMI input 0
[  100.242557] vivid-000: V4L2 capture device registered as video1
[  100.248688] vivid-000: CEC adapter cec1 registered for HDMI output 0
[  100.255132] vivid-000: V4L2 output device registered as video2
[  100.261091] vivid-000: V4L2 capture device registered as vbi0, supports raw and sliced VBI
[  100.269483] vivid-000: V4L2 output device registered as vbi1, supports raw and sliced VBI
[  100.277799] vivid-000: V4L2 capture device registered as swradio0
[  100.284025] vivid-000: V4L2 receiver device registered as radio0
[  100.290150] vivid-000: V4L2 transmitter device registered as radio1
[  100.296550] vivid-000: V4L2 metadata capture device registered as video3
[  100.303389] vivid-000: V4L2 metadata output device registered as video4
[  100.310127] vivid-000: V4L2 touch capture device registered as v4l-touch0
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy#
root@xilinx-vck190-es1-2021_2:/lib/modules/5.10.0-xilinx-v2021.2/kernel/drivers/usb/gadget/legacy# cd
root@xilinx-vck190-es1-2021_2:~#
root@xilinx-vck190-es1-2021_2:~#
root@xilinx-vck190-es1-2021_2:~# uvc-gadget -u /dev/video0 -v /dev/video1 -t 15 -r 0 -n 2 &
[1] 1082
Requested Burst value = 15
Number of buffers requested = 2
V4L2 device is vivid on bus platform:vivid-000
V4L2: Getting current format: YUYV 640x360
V4L2: Setting format to: YUYV 640x360
V4L2: Getting current format: YUYV 640x360
v4l2 open succeeded, file descriptor = 3
uvc device is dwc3-gadget on bus gadget
uvc open succeeded, file descriptor = 4
V4L2: Buffer 0 mapped at address 0xffffb899d000.
V4L2: Buffer 1 mapped at address 0xffffb892c000.
V4L2: 2 buffers allocated.
root@xilinx-vck190-es1-2021_2:~# [  156.641979] g_webcam gadget: uvc: uvc_function_set_alt(0, 0)
[  156.647630] g_webcam gadget: uvc: reset UVC Control
[  156.652506] g_webcam gadget: uvc: uvc_function_set_alt(1, 0)
[  156.658205] g_webcam gadget: uvc: uvc_function_set_alt(1, 0)
[  156.677171] g_webcam gadget: uvc: uvc_function_set_alt(1, 0)
control request (req 86 cs 04)
control request (req 81 cs 02)
control request (req 86 cs 09)
control request (req 81 cs 02)
control request (req 86 cs 02)
control request (req 82 cs 02)
control request (req 83 cs 02)
control request (req 84 cs 02)
control request (req 87 cs 02)
streaming request (req 81 cs 01)
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 83 cs 01)
streaming request (req 82 cs 01)
streaming request (req 81 cs 01)
streaming request (req 01 cs 01)
......
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 83 cs 01)
streaming request (req 82 cs 01)
root@xilinx-vck190-es1-2021_2:~#

Output:

We should see the uvc gadget interface on host side.

Open zoom app -> settings -> video -> Select Camera as "UVC Camera" then it will stream the video

References

Zynq Ultrascale MPSOC Linux USB device driver

...