In this simple tutorial, we shall be creating a linux image using the Petalinux 2016.1 BSP, and making slight modification to the DT, and Kernel. We can then boot from the SD card and test and verify the read/write to USB
http://xirweb/~stephenm/Projects/usb_sd_card.zip
First, build the Linux Image:
petalinux-create -t project -s Xilinx-ZC706-v2016.1-final.bsp cd Xilinx-ZC706-v2016.1 open Xilinx-ZC706-2016.1/subsystems/linux/configs/device-tree/system-top.dts o change: &usb0 { dr_mode = "host"; usb-phy = <&usb_phy0>; }; To: &usb0 { status = "okay"; dr_mode = "peripheral"; usb-phy = <&usb_phy0>; }; petalinux-config -c kernel o Configure for OTG Mode: . 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 ---> o <*> NOP USB Transceiver Driver <*> USB Gadget Support o
Next, Place the following files on the SD Card:
o Xilinx-ZC706-2016.1/images/linux/BOOT.BIN o Xilinx-ZC706-2016.1/images/linux/image.ub o Xilinx-ZC706-2016.1/build/linux/kernel/xlnx-4.4/fs/configfs/configfs.ko o Xilinx-ZC706-2016.1/build/linux/kernel/xlnx-4.4/drivers/usb/gadget/libcomposite.ko o Xilinx-ZC706-2016.1/build/linux/kernel/xlnx-4.4/drivers/usb/gadget/function/ usb_f_mass_storage.ko
Set the boot mode to boot from the SD Card (SW11 1:5 00110)
Insert the USB UART cable and set the buad rate to 115200.
Power on the board, and boot linux and login (root & root)
Plug in the usb cable to your HOST
On the linux console, use the commands below:
o mount /dev/mmcblk0p1 /mnt o insmod /mnt/configfs.ko o insmod /mnt/libcomposite.ko o insmod /mnt/usb_f_mass_storage.ko o dd if=/dev/zero of=/tmp/mydev count=10 bs=1M o mount -t configfs none /sys/kernel/config o cd /sys/kernel/config/usb_gadget o mkdir g1 o cd g1 o echo "64" > bMaxPacketSize0 o echo "0x200" > bcdUSB o echo "0x100" > bcdDevice echo "0x03FD" > idVendor echo "0x0500" > idProduct o mkdir functions/mass_storage.ms0 o mkdir configs/c1.1 o echo /tmp/mydev > functions/mass_storage.ms0/lun.0/file o echo 1 > functions/mass_storage.ms0/lun.0/removable o ln -s functions/mass_storage.ms0 configs/c1.1/ o echo "ci_hdrc.0" > UDC
You will see the pop up box:
You will now be able to read/write from HOST.