USB

The Universal Serial Bus (USB) can be utilized for many functions on the development kit, including external media. The phyCORE-AM57x development kit provides one USB 2.0 Dual-Role Devices (DRD) subsystems via a USB mini connector (X9), a USB3.0 (X30) and a USB2.0 (X19). This guide will walk you through the basic use of the USB interface. To learn more information about the phyCORE-AM57x USB interface, please see section 8.1 in the Hardware Manual.

USB Locations

Type

Header Location

Speed

Bus

USB A

X30

3.0

001

USB Mini

X9

2.0

002/004

USB A

X19

2.0

003

USB Locations

Note

The USB2.0 port at X19 and the USB Mini connector at X9 share signals and are therefore not functional at the same time. See the following bullets for configuring your hardware to enable your desired USB port. It is critical that jumpers are removed/installed only when the AM57x is completely powered off with the power supply removed.

  • In order to enable the USB2.0 port at X19, close the jumpers JP3, JP6, and JP10.

  • In order to enable the Mini-B USB connector at X9, open the jumpers JP3, JP6, and JP10.

phyCORE-AM57x Development Kit USB Jumper Locations

Requirements

Verifying USB Interface

  • With the phyCORE-AM57x development kit booted into Linux, verify that there are 4 USB devices.

    Target (Linux)
    lsusb
    
    Expected Output
    root@phycore-am57xx-1:~# lsusb
    Bus 004 Device 001: ID 1d6b:0003
    Bus 003 Device 001: ID 1d6b:0002
    Bus 002 Device 001: ID 1d6b:0003
    Bus 001 Device 001: ID 1d6b:0002
    
  • Insert a USB device into X9.

    Expected Output
    root@phycore-am57xx-1:~# [   32.154693] usb 3-1: new high-speed USB device number 2 using xhci-hcd
    [   32.336120] usb 3-1: New USB device found, idVendor=090c, idProduct=1000, bcdDevice=11.00
    [   32.344360] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [   32.352355] usb 3-1: Product: USB Flash Disk
    [   32.356689] usb 3-1: Manufacturer: General
    [   32.360839] usb 3-1: SerialNumber: 04NO3BEZ826XRN7H
    [   32.384979] usb-storage 3-1:1.0: USB Mass Storage device detected
    [   32.392700] scsi host1: usb-storage 3-1:1.0
    [   32.398284] usbcore: registered new interface driver usb-storage
    [   32.407379] usbcore: registered new interface driver uas
    [   33.696716] scsi 1:0:0:0: Direct-Access     General  USB Flash Disk   1100 PQ: 0 ANSI: 4
    [   33.706268] sd 1:0:0:0: [sda] 31506432 512-byte logical blocks: (16.1 GB/15.0 GiB)
    [   33.717529] sd 1:0:0:0: [sda] Write Protect is off
    [   33.726043] sd 1:0:0:0: [sda] No Caching mode page found
    [   33.731384] sd 1:0:0:0: [sda] Assuming drive cache: write through
    [   33.808105]  sda: sda1
    [   33.812774] sd 1:0:0:0: [sda] Attached SCSI removable disk
    [   34.192993] cryptd: max_cpu_qlen set to 1000
    
  • Verify that the USB was properly recongnized by development kit.

    Target (Linux)
    lsusb
    
    Expected Output
    root@phycore-am57xx-1:~# lsusb
    Bus 004 Device 001: ID 1d6b:0003
    Bus 003 Device 002: ID 090c:1000 General USB Flash Disk
    Bus 003 Device 001: ID 1d6b:0002
    Bus 002 Device 001: ID 1d6b:0003
    Bus 001 Device 001: ID 1d6b:0002
    
  • 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.

    Target (Linux)
     lsusb -v -s 003:002
    

    Note

    “003” refers to bus 003 and “002” refers to the device number, both of these can be found in the lsusb command.

Expected Output for Example USB Drive
Bus 003 Device 002: ID 090c:1000 General USB Flash Disk
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x090c
  idProduct          0x1000
  bcdDevice           11.00
  iManufacturer           1 General
  iProduct                2 USB Flash Disk
  iSerial                 3 04NO3BEZ826XRN7H
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
  ...
  • The speed of the USB device can be determined with either the lsusb -v from above or by reading the device’s “speed”

    Target (Linux)
    cat /sys/bus/usb/devices/3-1/speed
    
    cat /sys/bus/usb/devices/usb3/speed
    

    Note

    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.

      Target (Linux)
      ls /dev/sd*
      
      Expected Output
      root@phycore-am57xx-1:~# ls /dev/sd*
      /dev/sda   /dev/sda1
      
    2. Remove the USB drive and re-insert it.

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

      Expected Output
      root@phycore-am57xx-1:~# [   32.154693] usb 3-1: new high-speed USB device number 2 using xhci-hcd
      [   32.336120] usb 3-1: New USB device found, idVendor=090c, idProduct=1000, bcdDevice=11.00
      [   32.344360] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
      [   32.352355] usb 3-1: Product: USB Flash Disk
      [   32.356689] usb 3-1: Manufacturer: General
      [   32.360839] usb 3-1: SerialNumber: 04NO3BEZ826XRN7H
      [   32.384979] usb-storage 3-1:1.0: USB Mass Storage device detected
      [   32.392700] scsi host1: usb-storage 3-1:1.0
      [   32.398284] usbcore: registered new interface driver usb-storage
      [   32.407379] usbcore: registered new interface driver uas
      [   33.696716] scsi 1:0:0:0: Direct-Access     General  USB Flash Disk   1100 PQ: 0 ANSI: 4
      [   33.706268] sd 1:0:0:0: [sda] 31506432 512-byte logical blocks: (16.1 GB/15.0 GiB)
      [   33.717529] sd 1:0:0:0: [sda] Write Protect is off
      [   33.726043] sd 1:0:0:0: [sda] No Caching mode page found
      [   33.731384] sd 1:0:0:0: [sda] Assuming drive cache: write through
      [   33.808105]  sda: sda1
      [   33.812774] sd 1:0:0:0: [sda] Attached SCSI removable disk
      [   34.192993] cryptd: max_cpu_qlen set to 1000
      
  • Make a directory for mounting the USB device.

    Target (Linux)
     mkdir ~/usb_sda
    
  • Format file type.

    Target (Linux)
     mkfs.vfat /dev/sda
    
  • Mount the USB device to the directory.

    Target (Linux)
    mount /dev/sda ~/usb_sda/
    
  • See what media is on the USB drive.

    Target (Linux)
     ls ~/usb_sda/
    

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
    
  • Copy the file to your storage device.

    Target (Linux)
    cp test.file ~/usb_sda/ && sync
    
  • Verify that the file wasn’t corrupted with md5sum. Both the hashes should match.

    Target (Linux)
    md5sum test.file ~/usb_sda/test.file
    
    Expected Output
    root@phycore-am57xx-1:~# md5sum test.file ~/usb_sda/test.file
    ad3de54f2681aa83e87d80a9acaa4d16  test.file
    ad3de54f2681aa83e87d80a9acaa4d16  /root/usb_sda/test.file
    

Read from the USB Host Device

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

    Target (Linux)
    cp ~/usb_sda/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:

    Target (Linux)
    md5sum test.file readback-usb.file
    
    Expected Output
    root@phycore-am57xx-1:~# md5sum test.file readback-usb.file
    ad3de54f2681aa83e87d80a9acaa4d16  test.file
    ad3de54f2681aa83e87d80a9acaa4d16  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

Target (Linux)
umount ~/usb_sda/
umount /dev/sda