USB

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

The USB0 interface is brought out as a type-C connector (X9). The USB1 interface uses a USB HUB to split the bus to 3x locations.

USB Locations

Type

Qty

Header Location

Speed

Bus

USB A Double Stacked

2

X44

2.10

001

Mini PCIe

1

X17

2.10

001

M.2

1

X16

2.10

001

USB C

1

X9

2.10

002

phyCORE-AM67x USB

Note

The phyBOARD-Rigel also has a jumper J22 for controlling the USB C port role. Currently only DFP (host mode) is supported, so the jumper should be set to 1+2 (5V0 to USB-C).

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.

[ 2401.755201] usb 2-1: new high-speed USB device number 4 using xhci-hcd
[ 2401.897146] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 2401.903953] scsi host0: usb-storage 2-1:1.0
[ 2402.928253] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
[ 2402.942630] sd 0:0:0:0: [sda] 120164352 512-byte logical blocks: (61.5 GB/57.3 GiB)
[ 2402.951380] sd 0:0:0:0: [sda] Write Protect is off
[ 2402.956636] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 2402.988855] sd 0:0:0:0: [sda] Attached SCSI removable disk
  • Verify the available USB devices.

sh-phyboard-rigel-am67xx-1:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.35-gAUTOINC-01046-g46d2124bec05 xhci-hcd xHCI Host Controller
Bus 001 Device 002: ID 0451:8142
Bus 002 Device 001: ID 1d6b:0002 Linux 6.12.35-gAUTOINC-01046-g46d2124bec05 xhci-hcd xHCI Host Controller
Bus 002 Device 004: ID 0781:55a9  USB  SanDisk 3.2Gen1
Bus 003 Device 001: ID 1d6b:0003 Linux 6.12.35-gAUTOINC-01046-g46d2124bec05 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-rigel-am67xx-1:~# 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-rigel-am67xx-1:~# cat /sys/bus/usb/devices/2-1/speed
480

Note

USB2.0 has transmission speeds up to 480Mbit/s, also known as “high speed”.

Using a USB Storage Device

Find the Device Name

  • The kernel output shown when the drive was inserted names it (sda in the example above). You can also list the block devices:

    sh-phyboard-rigel-am67xx-1:~# ls /dev/sd*
    /dev/sda  /dev/sda1
    

    Note

    sda is the whole drive and sda1 is the first partition on it. A drive formatted without a partition table only shows sda.

  • Create a mount point for the drive:

    sh-phyboard-rigel-am67xx-1:~# mkdir -p /mnt/usb
    

Continue with the section that matches your drive: Accessing Files on a USB Drive with Data to work with the files already on it, or Formatting a New USB Drive to start with an empty drive.

Accessing Files on a USB Drive with Data

  • Mount the partition that holds the data. Use /dev/sda instead if the drive has no partition table:

    sh-phyboard-rigel-am67xx-1:~# mount /dev/sda1 /mnt/usb
    
  • List the files on the drive:

    sh-phyboard-rigel-am67xx-1:~# ls /mnt/usb
    
  • Copy a file to the drive:

    sh-phyboard-rigel-am67xx-1:~# echo "Hello from the phyBOARD-Rigel AM67x" > hello.txt
    sh-phyboard-rigel-am67xx-1:~# cp hello.txt /mnt/usb/
    
  • Copy a file from the drive back to the board:

    sh-phyboard-rigel-am67xx-1:~# cp /mnt/usb/hello.txt ~/hello-from-usb.txt
    sh-phyboard-rigel-am67xx-1:~# cat ~/hello-from-usb.txt
    Hello from the phyBOARD-Rigel AM67x
    

Formatting a New USB Drive

Warning

Formatting erases all data on the drive. Make sure you selected the right device name, and that the drive is not mounted.

  • Format the whole drive with a FAT file system:

    sh-phyboard-rigel-am67xx-1:~# mkfs.vfat /dev/sda
    
  • Mount the drive:

    sh-phyboard-rigel-am67xx-1:~# mount /dev/sda /mnt/usb
    
  • The drive is now empty and ready to use. To check that data is written to and read back from the drive correctly, continue with Verifying Data Transfer.

Verifying Data Transfer

This test writes a file with random content to the drive and reads it back. Unmounting and mounting the drive in between ensures the file is read from the drive and not from memory.

  • Generate a random 10 MB file and copy it to the drive. Use the device name you mounted above (/dev/sda or /dev/sda1):

    sh-phyboard-rigel-am67xx-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.161874 s, 64.8 MB/s
    sh-phyboard-rigel-am67xx-1:~# cp test.file /mnt/usb/
    sh-phyboard-rigel-am67xx-1:~# umount /mnt/usb
    sh-phyboard-rigel-am67xx-1:~# mount /dev/sda /mnt/usb
    
  • Copy the file back from the drive and compare the checksums:

    sh-phyboard-rigel-am67xx-1:~# cp /mnt/usb/test.file readback-usb.file
    sh-phyboard-rigel-am67xx-1:~# md5sum test.file readback-usb.file
    d3aa3ee1db746d6f7fb66c9b42f4ea6b  test.file
    d3aa3ee1db746d6f7fb66c9b42f4ea6b  readback-usb.file
    

    Both checksums must match.

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. umount writes all pending data to the drive before it returns.

sh-phyboard-rigel-am67xx-1:~# umount /mnt/usb