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.
Class drivers connect through libusbdi.so run on the hosts, and handle devices (e.g., devb-umass).
Function drivers connect through libusbdci.so and run on the device (e.g., 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 an x86_64 platform and access a mass storage device.
- Start the USB stack with the Extensible Host Controller Interface (xHCI) driver:
# io-usb-otg -d xhci
- Start the USB mass storage interface driver:
Now any connected mass storage device and its partitions can be seen under /dev. For example:devb-umass cam pnp &
# ls /dev/hd* /dev/hd0 /dev/hd0t6
- To access the files on the mass storage device, mount it 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.
- 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
- Start the USB stack with usbumass device controller driver:
# io-usb-otg -d dcd-usbumass-mx8-ci ioport=0x5B0D0000,irq=299
- Start the Mass Storage function driver:
# devu-umass_client-block -l lun=0,devno=1,iface=0,fname=/dev/hd0
- Enable USB soft link with ulink_ctrl, which controls DCD links:
# ulink_ctrl -l 1
On the host system the iMX8 should be detected as a mass storage device. For example: /dev/hd0
USB Utility
The USB utility can be used to access device details and configurations.
For example:
# usb -vvv