USB

USB Stack

USB (Universal Serial Bus) is a protocol and hardware specification for interconnecting various USB devices to a host controller.

The BSP provided by QNX for each reference board contains a USB stack (io-usb-otg) that implements USB protocol and HCI (Host Controller Interface) drivers. The USB stack manages the USB bus and USB protocols through hardware controller drivers. The stack can run in either USB host mode or USB device mode or both simultaneously. If the provided HCI drivers do not support custom hardware then the support will have to be added.

Class drivers connect through libusbdi.so and run on the hosts and handle devices. For example: usbnet, devb-umass

Function drivers connect through libusbdci.so and run on the device. For example: usbdnet, devu-umass_client-block

Host Mode

Host Controller Drivers (HCD) are required to run the USB stack in a host mode.

The following examples show the components and dependencies required to run the stack in host mode on x86_64 platform and access a mass storage device.

  1. Start USB stack with Extensible Host Controller Interface (xHCI) driver
    # io-usb-otg -d xhci
  2. Start USB mass storage interface driver
    devb-umass cam pnp &
    Now any connected mass storage device and it's partitions can be seen under /dev. Example:
    # ls /dev/hd*
    /dev/hd0           /dev/hd0t6
    
  3. To access the files on the mass storage device, it can be mounted as follows:
    # mount -t dos /dev/hd0t6 /fs

Device Mode

Device Controller Drivers (DCD) are required to run the USB stack in a device mode. There are several device mode drivers such as dcd-usbumass, dcd-usbncm etc.

The following example for iMX8 target shows the dependencies and components required to run a mass storage device mode.

  1. The very first step is to create a RAM disk which acts as a storage medium, create a partition and format it with a FAT filesystem
    # devb-ram ram capacity=16384,nodinit,cache=512k disk name=hd@0
    # waitfor /dev/hd0
    # fdisk /dev/hd0 add -t 6
    # mount -e /dev/hd0
    # waitfor /dev/hd0t6
    # mkdosfs /dev/hd0t6
    
  2. Start USB stack with usbumass device controller driver
    # io-usb-otg -d dcd-usbumass-mx8-ci ioport=0x5B0D0000,irq=299
  3. Start Mass Storage function driver
    # devu-umass_client-block -l lun=0,devno=1,iface=0,fname=/dev/hd0
  4. Enable USB soft link with ulink_ctrl which controls DCD link
    # ulink_ctrl -l 1

On the host system the iMX8 should be detected as a mass storage device Ex: /dev/hd0

USB Launcher

USB launcher utility monitors USB bus and provides automation steps.

More details can be found at usblauncher_otg

USB Utility

USB utility can be used to access device details and configurations.

Example:

# usb -vvv