USB

The Universal Serial Bus (USB) can be utilized for many functions on the phyBOARD-Electra AM64x, including external media. The phyBOARD-Electra AM64x provides multiple USB connectors, as detailed in USB0 Split by USB Hub. This guide will show you how to use the USB Host capabilities featured on the phyBOARD-Electra AM64x. To learn more information about the phyCORE-AM64x USB interface, please see section 7.6 in the Hardware Manual.

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

USB0 Split by USB Hub

Type

Qty

Header Location

Speed

Bus

USB A Double Stacked

2

X13

3.1

002

Mini PCIe

1

X31

2.0

001

Pin Header

1

X27 (Pin 21, 22, 37, 39)

2.0

001

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 will disable USB3.0 speeds at the stacked type-A USB connector but USB2.0 speeds will still be available.

Requirements

  • USB Storage Device

Verifying USB Interface

  • Boot into Linux and Insert a USB Storage Device into one of the USB ports.

  • Upon insertion, kernel output should appear.

[   30.428000] usb 1-1.1: new high-speed USB device number 4 using xhci-hcd
[   30.532866] usb 1-1.1: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00
[   30.541258] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   30.548583] usb 1-1.1: Product:  SanDisk 3.2Gen1
[   30.553247] usb 1-1.1: Manufacturer:  USB
[   30.557275] usb 1-1.1: SerialNumber: 0401a83fbd697e437712b826697973aaaf57d1c75e9691ad879dfe7934b8a81bea020000000000000000000037ac13c5ff935d18915581076e2cc649
[   30.573038] usb-storage 1-1.1:1.0: USB Mass Storage device detected
[   30.580206] scsi host0: usb-storage 1-1.1:1.0
[   31.609115] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
[   31.622632] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
[   31.636317] sd 0:0:0:0: [sda] Write Protect is off
[   31.641991] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   31.664047] sd 0:0:0:0: [sda] Attached SCSI removable disk
  • Verify the available USB devices.

sh-phyboard-electra-am64xx-2:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux 6.1.33-bsp-yocto-ampliphy-am64x-pd23.2.0 xhci-hcd xHCI Host Controller
Bus 001 Device 004: ID 0781:5591  USB  SanDisk 3.2Gen1
Bus 001 Device 002: ID 0451:8242
Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am64x-pd23.2.0 xhci-hcd xHCI Host Controller
  • To list more information about the USB device and buses on the development kit use the following command.

    This command will output a good chunk of information. This guide will only show a snippet of the expected output for the USB drive that was just connected.

    sh-phyboard-electra-am64xx-2:~# lsusb -v
    
  • The speed of the USB device can be determined with either the lsusb -v from above or by reading the device’s “speed”

sh-phyboard-electra-am64xx-2:~# cat /sys/bus/usb/devices/usb2/speed
5000

Note

USB3.0 has transmission speeds up to 5000 Mbit/s, also known as “super speed”. USB2.0 has transmission speeds up to 480Mbit/s, also known as “full speed”.

Mounting USB Stroage Devices

  • Verify that a device directory was established for the USB drive.

    1. Run the following command to confirm the USB device name.

    sh-phyboard-electra-am64xx-2:~# ls /dev/sd*
    /dev/sda
    
    1. Remove the USB drive and re-insert it.

    2. The output log that appears when connecting the USB device will indicate the devices name.

    [   30.428000] usb 1-1.1: new high-speed USB device number 4 using xhci-hcd
    [   30.532866] usb 1-1.1: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00
    [   30.541258] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [   30.548583] usb 1-1.1: Product:  SanDisk 3.2Gen1
    [   30.553247] usb 1-1.1: Manufacturer:  USB
    [   30.557275] usb 1-1.1: SerialNumber: 0401a83fbd697e437712b826697973aaaf57d1c75e9691ad879dfe7934b8a81bea020000000000000000000037ac13c5ff935d18915581076e2cc649
    [   30.573038] usb-storage 1-1.1:1.0: USB Mass Storage device detected
    [   30.580206] scsi host0: usb-storage 1-1.1:1.0
    [   31.609115] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
    [   31.622632] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
    [   31.636317] sd 0:0:0:0: [sda] Write Protect is off
    [   31.641991] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
    [   31.664047] sd 0:0:0:0: [sda] Attached SCSI removable disk
    

    Note

    In this example the device name for the USB drive is “sda”.

  • Make a directory for mounting the USB device.

    sh-phyboard-electra-am64xx-2:~# mkdir -p /mnt/usb
    
  • Format file type.

    sh-phyboard-electra-am64xx-2:~# mkfs.vfat /dev/sda
    
  • Mount the USB device to the directory.

    sh-phyboard-electra-am64xx-2:~# mount /dev/sda /mnt/usb/
    
  • See what media is on the USB drive.

    sh-phyboard-electra-am64xx-2:~# ls /mnt/usb/
    

Write to the USB Host Device

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

    sh-phyboard-electra-am64xx-2:~# 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.161874 s, 64.8 MB/s
    
  • Copy the file to your storage device.

    sh-phyboard-electra-am64xx-2:~# cp test.file /mnt/usb/ && sync
    

Read from the USB Host Device

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

    sh-phyboard-electra-am64xx-2:~# cp /mnt/usb/test.file readback-usb.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:

    sh-phyboard-electra-am64xx-2:~# md5sum test.file readback-usb.file
    d3aa3ee1db746d6f7fb66c9b42f4ea6b  test.file
    d3aa3ee1db746d6f7fb66c9b42f4ea6b  readback-usb.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

sh-phyboard-electra-am64xx-2:~# umount /mnt/usb/