Skip to main content

USB Host

The carrier boards have one or two USB type A sockets which can be used on all CPUs. These tests require a USB Memory Stick.

U-Boot

The U-Boot has USB support for reading/writing USB memories. Connect a USB memory stick to one of the ports and then issue the following commands.

Initialize the interface

usb start
starting USB...
USB0: Port not available.
USB1: USB EHCI 1.00
scanning bus 1 for devices... 4 USB Device(s) found
scanning usb for storage devices... 2 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

List storage devices

usb storage
 Device 0: Vendor: USB Rev: 1100 Prod: Flash Disk
Type: Hard Disk
Capacity: 1912.0 MB = 1.8 GB (3915776 x 512)
Device 1: Vendor: Kingston Rev: 1.00 Prod: DataTraveler G2
Type: Removable Hard Disk
Capacity: 15259.7 MB = 14.9 GB (31252024 x 512)

List content on the memory stick (attached to device 0)

fatls usb 0
24055271   core-image-base-imx6sxea-com.rootfs.tar.bz2
79691776 core-image-base-imx6sxea-com.rootfs.ext3
316520 u-boot-imx6sxea-com.img
6084744 zimage-imx6sxea-com
42732 imx6sxea-com-kit.dtb

5 file(s), 0 dir(s)

Linux

Linux has support for a wide range of USB devices including mouse, keyboard, memory sticks, hubs etc.

It is possible to see which USB devices are currently connected.

lsusb
Bus 001 Device 004: ID 0951:1624 Kingston Technology DataTraveler G2
Bus 001 Device 003: ID 8087:07dc Intel Corp.
Bus 001 Device 002: ID 0424:2513 Standard Microsystems Corp. 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

When a new USB device is connected some status messages will be printed in the console. The following comes when inserting a USB memory stick.

usb 1-1.3: new high-speed USB device number 5 using ci_hdrc
usb-storage 1-1.3:1.0: USB Mass Storage device detected
scsi1 : usb-storage 1-1.3:1.0
scsi 1:0:0:0: Direct-Access Kingston DataTraveler G2 1.00 PQ: 0 ANSI: 2
sd 1:0:0:0: [sda] 31252024 512-byte logical blocks: (16.0 GB/14.9 GiB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Incomplete mode parameter data
sd 1:0:0:0: [sda] Assuming drive cache: write through
sd 1:0:0:0: [sda] Incomplete mode parameter data
sd 1:0:0:0: [sda] Assuming drive cache: write through
sda: sda1
sd 1:0:0:0: [sda] Incomplete mode parameter data
sd 1:0:0:0: [sda] Assuming drive cache: write through
sd 1:0:0:0: [sda] Attached SCSI removable disk

The interesting part above is the sda: sda1 which indicates which device (sda1) that the USB memory stick is assigned to. The Linux section in the SATA chapter describes an alternative way to find the device name.

To be able to access the memory stick it must first be mounted.

mkdir /mnt/usb
mount /dev/sda1 /mnt/usb

The memory stick is now available in the /mnt/usb directory on the file system.

ls /mnt/usb/
core-image-base-imx6sxea-com.rootfs.ext3
core-image-base-imx6sxea-com.rootfs.tar.bz2
imx6sxea-com-kit.dtb
u-boot-imx6sxea-com.img
zImage-imx6sxea-com

Before physically removing the memory stick from the carrier board, it should be unmounted to make sure that all pending write operations are committed to prevent data loss.

 umount /mnt/usb

There are many different USB devices and the level of support varies with the kind of device. Keyboards will work without any extra work – just plug in and start typing. A mouse will work but without a graphical desktop it will be difficult to use it.