The guide below shows you how to build USB drivers & boot the board and then run some example configurations (Host, Device, OTG mode of PS USB controller ) on Versal platform.
The steps below use PetaLinux and assume you have some knowledge of using PetaLinux.
Table of Contents
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.
...
Code Block | ||
---|---|---|
| ||
root@xilinx-vck190-es1-2021_1:~# mount -t configfs none /sys/kernel/config /mount: mounting none on /sys/kernel/config failed: Device or resource busy kernel/croot@xilinx-vck190-es1-2021_1:~# root@xilinx-vck190-es1-2021_1:~# cd /sys/kernel/config/usb_gadget/ root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget# mkdir g && cd g root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 0x1d6b > idVendor root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 0x0104 > idProduct # Multifunction Composite Gadget root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 0x0100 > bcdDevice # v1.0.0 root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 0x0200 > bcdUSB # USB 2.0 root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# mkdir -p strings/0x409 root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo "xxxxxxxxxxxx" > strings/0x409/serialnumber root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo "xilinx" > strings/0x409/manufacturer root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo "versal" > strings/0x409/product root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# mkdir -p functions/acm.usb0 # serial -proot@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# mkdir -p functions/ecm.usb0 # network p mkdir: can't create directory 'functions/ecm.usb0': No such file or directory functionsroot@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# mkdir -p functions/rndis.usb0 # network [ 103.054675] using random self ethernet address [ 103.059147] using random host ethernet address root@xilinx-vck190-es1-20202021_21:/sys/kernel/config/usb_gadget/g# mkdir -p functions/mass_storage.ms0 # mass storage d[ 141.238768] Mass Storage Function, version: 2009/09/11 [ 141.243939] LUN: removable file: (no medium) ev/zero of=/root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# dd if=/dev/zero of=/tmp/mydev count=256 bs=1M tmp/mydev > functions/mass_storage.ms0/lun.0/file echo 1 > functions/mass_storage.ms0/lun.0/removable mkdir -p configs/c.1 echo 250 > configs/c.1/MaxPower echo 0xE0 > configs/c.1/bmAttributes ln -s functions/rndis.256+0 records in 256+0 records out usb0 coroot@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo /tmp/mydev > functions/mass_storage.ms0/lun.0/file root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 1 > functions/mass_storage.ms0/lun.0/removable root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# mkdir -p configs/c.1 figs/c.root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 250 > configs/c.1/MaxPower root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# echo 0xE0 > configs/c.1/bmAttributes root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ln -s functions/rndis.usb0 configs/c.1/ root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ln -s functions/mass_storage.ms0/ configs/c.1/ root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ln -s functions/acm.usb0 configs/c.1/ s/class/root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ls /sys/class/udc/ > UDC [ 155.915282] usb0: HOST MAC 76:5d:c3:e3:7a:e1 [ 155.919616] usb0: MAC f2:26:48:7a:ab:ed root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# [ 156.331433] configfs-gadget gadget: high-speed config #1: c root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ifconfig -a can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:16 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:6 eth0 Link encap:Ethernet HWaddr CE:49:EC:C8:49:B3 inet addr:10.10.71.2 Bcast:10.10.71.255 Mask:255.255.255.0 inet6 addr: fe80::cc49:ecff:fec8:49b3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:49 errors:0 dropped:0 overruns:0 frame:0 TX packets:57 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:6105 (5.9 KiB) TX bytes:9135 (8.9 KiB) Interrupt:16 eth1 Link encap:Ethernet HWaddr C6:86:53:97:D6:F2 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) sit0 Link encap:IPv6-in-IPv4 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) usb0 Link encap:Ethernet HWaddr F2:26:48:7A:AB:ED BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ifconfig usb0 10.10.70.1 up root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# ping 10.10.71.101 PING 10.10.71.101 (10.10.71.101): 56 data bytes 64 bytes from 10.10.71.101: seq=0 ttl=64 time=0.389 ms 64 bytes from 10.10.71.101: seq=1 ttl=64 time=0.305 ms 64 bytes from 10.10.71.101: seq=2 ttl=64 time=0.343 ms 64 bytes from 10.10.71.101: seq=3 ttl=64 time=0.290 ms 64 bytes from 10.10.71.101: seq=4 ttl=64 time=0.351 ms ^C --- 10.10.71.101 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 0.290/0.335/0.389 ms root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# root@xilinx-vck190-es1-2021_1:/sys/kernel/config/usb_gadget/g# |
...