USB

This guide will show you how to use the USB Host capabilities featured on the phyCORE-AM64x development kit carrier board.

The USB0 interface uses a USB HUB to split the bus to 4x locations.

  • 2x USB 3.0 ports on the stacked type-A connector

  • 1x USB 2.0 interface at the miniPCIe connector

  • 1x USB 2.0 interface at the X27 expansion connector.

phyCORE-AM64x USB Connections on the Front phyCORE-AM64x miniPCIe Connector Location

Warning

The USB super speed signals are muxed between the miniPCIe interface and the USB HUB. Enabling miniPCIe (done via device tree overlay) will disable USB3.0 speeds at the stacked type-A USB connector but USB2.0 speeds will still be available.

Requirements

  • USB Storage Device

Step-by-Step Instructions

Verifying USB Interface

  • With the phyCORE-AM64x development kit booted into Linux, we can check the USB status in the bootlog:

Target (Linux)
dmesg | grep usb
Expected Output
root@phyboard-electra-am64xx-1:~# dmesg | grep usb
[    8.602929] usbcore: registered new interface driver usbfs
[    8.654230] usbcore: registered new interface driver hub
[    8.671868] usbcore: registered new device driver usb
[    9.362307] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
[    9.383565] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    9.400655] usb usb1: Product: xHCI Host Controller
[    9.419649] usb usb1: Manufacturer: Linux 5.10.65 xhci-hcd
[    9.425307] usb usb1: SerialNumber: xhci-hcd.2.auto
[        9.469163] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    9.479296] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.10
[    9.499177] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    9.507331] usb usb2: Product: xHCI Host Controller
[    9.512716] usb usb2: Manufacturer: Linux 5.10.65 xhci-hcd
[    9.518668] usb usb2: SerialNumber: xhci-hcd.2.auto
[    9.699493] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[    9.859959] usb 1-1: New USB device found, idVendor=0451, idProduct=8242, bcdDevice= 1.00
[    9.868261] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=1
[    9.875569] usb 1-1: SerialNumber: B2010871CA15
[    9.991547] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci-hcd
[   10.023761] usb 2-1: New USB device found, idVendor=0451, idProduct=8240, bcdDevice= 1.10
[   10.032168] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0

USB Host Connection (FAT32)

  • Insert a USB storage device into the USB-A connector. You should see something like the following on the serial console:

Expected Output
[102566.987448] usb 1-1.1: new high-speed USB device number 3 using xhci-hcd
[102567.093222] usb 1-1.1: New USB device found, idVendor=ffff, idProduct=5678, bcdDevice= 2.00
[102567.101685] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[102567.109332] usb 1-1.1: Product: Disk 2.0
[102567.113454] usb 1-1.1: Manufacturer: USB
[102567.118256] usb 1-1.1: SerialNumber: WYKTDZM005000872
[102567.153171] usb-storage 1-1.1:1.0: USB Mass Storage device detected
[102567.160458] scsi host0: usb-storage 1-1.1:1.0
[102567.169789] usbcore: registered new interface driver usb-storage
[102568.200251] scsi 0:0:0:0: Direct-Access     VendorCo ProductCode      2.00 PQ: 0 ANSI: 4
[102568.213147] sd 0:0:0:0: [sda] 31129600 512-byte logical blocks: (15.9 GB/14.8 GiB)
[102568.221799] sd 0:0:0:0: [sda] Write Protect is off
[102568.228929] sd 0:0:0:0: [sda] No Caching mode page found
[102568.240788] sd 0:0:0:0: [sda] Assuming drive cache: write through
[102568.261362]  sda: sda1
[102568.266041] sd 0:0:0:0: [sda] Attached SCSI removable disk
  • USB storage devices should mount automatically, the ‘mount’ utility can help show where:

Target (Linux)
mount | grep sda
Expected Output
root@phyboard-electra-am64xx-1:~# mount | grep sda
/dev/sda1 on /run/media/sda1 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

Note

In the above example output we can see that the device sda (located at /dev/sda) has a single partition /dev/sda1 mounted on /run/media/sda1.

  • We can verify the USB drive was mounted properly by viewing the contents of the mount point:

Target (Linux)
ls /run/media/sda1

Write to the USB Host Device

  • Generate a random 10 MB file to test transferring data from the storage device.

Target (Linux)
dd if=/dev/urandom of=test.file count=10 bs=1M
Expected Output
root@phyboard-electra-am64xx-1:~# dd if=/dev/urandom of=test.file count=10 bs=1M
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.170118 s, 61.6 MB/s
  • Copy the file to your storage device.

Target (Linux)
cp test.file /run/media/sda1 && sync

Read from the USB Host Device

  • Copy the test file we previously created during the write process back to the host:

Target (Linux)
cp /run/media/sda1/test.file test-readback.file && sync
  • We can double check that the file was successfully copied to and from the USB device by checking the md5sum of the file:

Target (Linux)
md5sum test.file test-readback.file
Expected Output
root@phyboard-electra-am64xx-1:~# md5sum test.file test-readback.file
f4115fd9e1ea5b166ec2691512f3288c  test.file
f4115fd9e1ea5b166ec2691512f3288c  test-readback.file

Unmounting the Drive

Warning

Make sure the drive is unmounted prior to physically disconnecting the device. Failure to do so may result in loss of data and corruption of files

Target (Linux)
umount /run/media/sda1