...
Important AR links
USB gadget as an RNDIS Ethernet data transfer got failed due to endpoint not recognized as prime (windows host machine specific) -AR-76735
Host Mode
Kernel Configuration
Ensure the below config parameters are selectedCode Block | ||
---|---|---|
| ||
Device Drivers USB support <*> Support for Host-side USB <*> EHCI HCD (USB 2.0) support <*> USB Mass Storage support <*> ChipIdea Highspeed Dual Role Controller <*> ChipIdea host controller USB Physical Layer drivers ---> <*> Generic ULPI Transceiver Driver |
Devicetree
Code Block | ||
---|---|---|
| ||
usb_0: usb@e0002000 { compatible = "xlnx,zynq-usb-2.20.a", "chipidea,usb2"; clocks = <&clkc 28>; dr_mode = "host"; interrupt-parent = <&intc>; interrupts = <0 21 4>; reg = <0xe0002000 0x1000>; usb-phy = <&usb_phy0>; }; usb_phy0: phy0 { compatible = "ulpi-phy"; #phy-cells = <0>; reg = <0xe0002000 0x1000>; view-port = <0x170>; drv-vbus; } |
Performance
Host Mode | 25.00 MB/sec | Tool: hdparm |
Test Procedure
Tested with mas-storage device.Connect the mass storage device and perform the file read/write operations.
Peripheral Mode
Kernel Configuration
Ensure the below config parameters are selectedMass Storage
Code Block | ||
---|---|---|
| ||
Device Drivers USB support <*> ChipIdea Highspeed Dual Role Controller <*> ChipIdea device controller <*> USB Gadget Support <M> USB Gadget Drivers <M> USB functions configurable through configfs [*] Mass storage |
Code Block | ||
---|---|---|
| ||
<M> USB Gadget Support <M> USB Gadget Drivers <M> USB functions configurable through configfs [*] RNDIS |
Devicetree
Code Block | ||
---|---|---|
| ||
usb_0: usb@e0002000 { compatible = "xlnx,zynq-usb-2.20.a", "chipidea,usb2"; clocks = <&clkc 28>; dr_mode = "peripheral"; interrupt-parent = <&intc>; interrupts = <0 21 4>; reg = <0xe0002000 0x1000>; usb-phy = <&usb_phy0>; }; usb_phy0: phy0 { compatible = "ulpi-phy"; #phy-cells = <0>; reg = <0xe0002000 0x1000>; view-port = <0x170>; drv-vbus; } |
Performance
Peripheral mode | 32.00 MB/sec | Tool: hdparm |
Test Procedure
Tested with Mass storage and Ethernet gadget.Mass Storage
Please refer above kernel configuration for enabling required modules for mass storage gadget.
After building the source code, copy the required modules found in the above-given paths into sd card
Steps for mounting the sdcard for accessing the compiled modules
zynq> mount /dev/mmcblk0p1 /mnt
Install the following modules
zynq> insmod /mnt/configfs.ko
zynq> insmod /mnt/libcomposite.ko
zynq> insmod /mnt/usb_f_mass_storage.ko
zynq> dd if=/dev/zero of=/tmp/mydev count=10 bs=1M
zynq> mount -t configfs none /sys/kernel/config
zynq> cd /sys/kernel/config/usb_gadget
zynq> mkdir g1
zynq> cd g1
zynq> echo "64" > bMaxPacketSize0
zynq> echo "0x200" > bcdUSB
zynq> echo "0x100" > bcdDevice
zynq> echo "0x03FD" > idVendor
zynq> echo "0x0500" > idProduct
zynq> mkdir functions/mass_storage.ms0
Number of LUNs=8
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
zynq> mkdir configs/c1.1
zynq> echo /tmp/mydev > functions/mass_storage.ms0/lun.0/file
zynq> echo 1 > functions/mass_storage.ms0/lun.0/removable
zynq> ln -s functions/mass_storage.ms0 configs/c1.1/
zynq> echo "ci_hdrc.0" > UDC
configfs-gadget gadget: high-speed config #1: c1
Perform the file read/write operation from the host machine
Ethernet
Please refer above kernel configuration for enabling required modules for the ethernet gadget.
After building the source code, copy the required modules found in the above-given paths into sd card
Steps for mounting the sdcard for accessing the compiled modules
zynq> mount /dev/mmcblk0p1 /mnt
Install the following modules
zynq> insmod /mnt/configfs.ko
zynq> insmod /mnt/libcomposite.ko
zynq> insmod /mnt/u_ether.ko
zynq> insmod /mnt/usb_f_rndis.ko
zynq> mount -t configfs none /sys/kernel/config
zynq> cd /sys/kernel/config/usb_gadget
zynq> mkdir g1
zynq> cd g1
zynq> echo "64" > bMaxPacketSize0
zynq> echo "0x200" > bcdUSB
zynq> echo "0x100" > bcdDevice
zynq> echo "0x03FD" > idVendor
zynq> echo "0x0500" > idProduct
zynq> mkdir functions/rndis.rn0
zynq> mkdir configs/c1.1
zynq> ln -s functions/rndis.rn0 configs/c1.1/
zynq> echo "ci_hdrc.0" > UDC
zynq> ifconfig usb0 10.10.70.1
zynq> ifconfig usb0 up
Run the standard network tests like ping, iperf,netperf...
OTG Mode
Kernel Configuration
Ensure the below config parameters are selectedCode Block | ||
---|---|---|
| ||
Device Drivers USB support <*> Support for Host-side USB <*> OTG support <*> EHCI HCD (USB 2.0) support <*> USB Mass Storage support <*> ChipIdea Highspeed Dual Role Controller <*> ChipIdea host controller <*> ChipIdea device controller USB Physical Layer drivers ---> <*> NOP USB Transceiver Driver <*> USB Gadget Support <M> USB Gadget Drivers <M> USB functions configurable through configfs [*] Mass storage |
fs/configfs/configfs.ko
drivers/usb/gadget/libcomposite.ko
drivers/usb/gadget/function/usb_f_mass_storage.ko
drivers/usb/gadget/function/usb_f_rndis.ko
Devicetree
Code Block | ||
---|---|---|
| ||
usb_0: usb@e0002000 { compatible = "xlnx,zynq-usb-2.20.a", "chipidea,usb2"; clocks = <&clkc 28>; dr_mode = "otg"; interrupt-parent = <&intc>; interrupts = <0 21 4>; reg = <0xe0002000 0x1000>; usb-phy = <&usb_phy0>; }; usb_phy0: phy0 { compatible = "ulpi-phy"; #phy-cells = <0>; reg = <0xe0002000 0x1000>; view-port = <0x170>; drv-vbus; } |
Test Procedure
Using the correct cables is the key to OTG operation. Testing was done using two cables joined together to create an OTG cable. An OTG cable has a micro A connector on one end and a micro B connector on the other end. The micro A connector is the host side of the cable and the micro B connector is the device side by default.
Testing for OTG was done with 2 ZC706 boards connected together. An adapter with a Micro-A plug on one end and a Standard-A receptacle on the other end was used for testing. The adapter is connected to the board that defaults to being a host. A cable with a Micro-B plug on one end and a Standard-A plug on the end is connected to the board that defaults to being a device. The cable is then connected to the adapter with the Standard-A receptacle and Standard-A plug.
Code Block | ||
---|---|---|
| ||
After booting linux, insert the gadget drivers on both the boards. This step is necessary as OTG device should work as both host and device. 1. Do the above steps used for testing mass storage gadget 2. Connect Micro-A cable to USB interface of the board#1. This board will act as USB A-device. 3. Connect Micro-B cable to USB interface of board#2. This board will act as a USB B-device. Now, both board#1 and board#2 are connected. 4. Make sure there is no hub in between. This makes the back-to-back connection between the two boards. 5. Check the Host enumerates the device as Mass Storage device 6. Now disconnect cable and connect in reverse order check board#2 now acts as Host and enumerates board#1 as Mass storage device |
Mainline Status
The current driver available in the Xilinx Linux git is in sync with the open-source kernel driver except for the following:
- USB 2.0 PHY support.
- UPLI Reset and register access using viewpoint.
- OTG feature.
Change Log
2024.1
- 6.6 Kernel upgrade
- e684b35 usb: phy: phy-ulpi: support legacy drv-vbus DT binding
- ae55943 usb: phy: phy-ulpi: Do not use devm_platform_ioremap_resource
...