{{{#!html
Universal Serial Bus (USB) is an industry standard developed in the mid-90's that defines cables, connectors and communication protocols used in a bus between computers and peripherals.
References:
The following types of USB host controllers exist:
The following is a set of supported speeds per USB specification:
There are four types of transfers in USB:
USB has a list of recognized and approved USB device classes in order to simplify driver development. The most common device classes are:
Often vendors choose HID device class to allow control via userspace applications without needing a OS specific driver (as all modern OS's have an HID driver).
The HIDAPI (open-source and cross-platform Linux/Windows/MacOS) provides simple USB HID enumeration, read and write functions.
The HID device class uses HID reports to describe details about the data input and output a device supports. The sub class can be 'Generic HID' and the report type can be 'Vendor Defined' which makes it generic. The maximum report size is 64B.
Vendors sometimes choose to implement a Vendor specific device which has an undefined class.
The libusb (open-source and cross-platform Linux/Windows/MacOS) can be used for generic USB communication. Vendor specific commands can be implemented.
In an effort to define these options available to developers, Gateworks has created the following table with the fields as follows:
In all cases the miniPCIe slots get their VBUS directly from the board power rail, which has no power control.
Gateworks USB device Table:
Family | SBC | USB Port | Ref | Reset | Bus-Device[.Port] | Bus Steering |
---|---|---|---|---|---|---|
Ventana | GW51xx | Front Panel OTG | J20 | Soft/VBUS | 1-1 | |
miniPCIe USB EHCI | J6 | Soft | 2-1 | |||
GW52xx | Front Panel OTG | J15 | Soft/VBUS | 1-1 | gpio2 low (default) | |
Bot Right miniPCIe EHCI | J7 | Soft | 2-1 | |||
Bot Left miniPCIe OTG | J8 | Soft | 2-1 | gpio2 high | ||
GW53xx | Front Panel OTG | J20 | Soft/VBUS | 1-1 | ||
Front Panel EHCI | J18 | Soft/VBUS | 2-1.1 | |||
Bot Left miniPCIe EHCI | J9 | Soft | 2-1.2 | |||
Bot Center miniPCIe EHCI | J8 | Soft | 2-1.3 | |||
Bot Right miniPCIe EHCI | J6 | Soft | 2-1.4 | |||
GW54xx | Front Panel OTG | J23 | Soft/VBUS | 1-1 | ||
Bot Right miniPCIe EHCI | J6 | Soft | 2-1.1 | |||
Top Right miniPCIe EHCI | J9 | Soft | 2-1.2 | |||
Top Left miniPCIe EHCI | J7 | Soft | 2-1.3 | |||
Front Panel EHCI | J21 | Soft/VBUS | 2-1.4 | |||
GW551x | Adapter Board OTG | J3 (J9 on Adapter) | Soft | 1-1 | ||
Bot miniPCIe EHCI | J2 | Soft | 2-1 | |||
GW552x | Bot Left miniPCIe EHCI | J6 | Soft | 1-1.1 | ||
Bot Right miniPCIe EHCI | J5 | Soft | 1-1.2 | |||
Front Panel EHCI | J10 (Top) | Soft/VBUS | 1-1.3 | |||
Front Panel EHCI | J10 (Bot) | Soft/VBUS | 1-1.4 | |||
GW553x | Front Panel OTG | J8 | Soft/VBUS | 1-1 | ||
miniPCIe EHCI | J5 | Soft | 2-1 | |||
Laguna | GW2380 | MiniPCIe EHCI | J5 | Soft | 1-1 | |
GW2382 | Front Panel EHCI | J4 | Soft/VBUS (gpio9) | 1-1 | gpio10 high (default) | |
MiniPCIe EHCI | J5 | Soft | 1-1 | gpio10 low | ||
GW2383 | Front Panel OTG | J4 | Soft/VBUS | 1-1 | ||
MiniPCIe EHCI | J6 | Soft | 1-2 | |||
GW2387 | Front Panel OTG | J12 (Top) | Soft/VBUS (gpio6) | 1-1 | ||
Front Panel EHCI | J12 (Bot) | Soft/VBUS (gpio6) | 2-1 | gpio5 low (default) | ||
MiniPCI EHCI | J5 (Bot) | Soft | 2-1 | gpio5 high | ||
GW2388 | Front Panel OTG | J19 (Top) | Soft/VBUS (gpio6) | 1-1 | (loading option)(1) | |
Front Panel EHCI | J19 (Bot) | Soft/VBUS (gpio6) | 2-1 | (loading option)(1) | ||
MiniPCI EHCI (1) | J4 (Bot) | Soft | 2-1 | (resistor loading option)(1) | ||
GW2391 | Front Panel OTG | J14 (Top) | Soft/VBUS (gpio6) | 1-1 | gpio5 low (default) | |
Front Panel EHCI | J14 (Bot) | Soft/VBUS (gpio6) | 2-1 | gpio7 low (default) | ||
MiniPCIe OTG | J4 (Bot) | Soft | 1-1 | gpio5 high | ||
MiniPCIe EHCI | J3 (Top) | Soft | 2-1 | gpio7 high | ||
Cambria | GW2350 | Front Panel EHCI | J9 (Top) | Soft/VBUS | 1-1 | |
Front Panel EHCI | J9 (Bot) | Soft/VBUS | 2-1 | |||
MiniPCI EHCI (1) | J4 | Soft | 2-1 | (resistor loading option)(1) | ||
GW2358 | Front Panel EHCI | J16 (Top) | Soft/VBUS | 1-1 | ||
Front Panel EHCI | J16 (Bot) | Soft/VBUS | 2-1 | |||
MiniPCI EHCI (1) | J8 | Soft | 2-1 | (resistor loading option)(1) | ||
Avila | GW2348-SP107 | Front Panel EHCI | J18 (Top) | Soft/VBUS | 1-1 | |
Front Panel EHCI | J18 (Bot) | Soft/VBUS | 2-1 | |||
MiniPCI EHCI (1) | J4 | Soft | 2-1 | (resistor loading option)(1) |
Some boards allow USB to be steered via a software controlled gpio. Refer to the 'bus steering' column for details which show which gpio to use, what the default is set to (via bootloader), and where it can be steered to. Typically a bus may be steerable between a front-panel connector and a miniPCIe socket in which case the front-panel is always the default configured by the bootloader. You can change the steering at run-time if you whish which would be like physically removing a USB device from the bus and adding another (re-enumerates).
Examples:
# export and configure the GPIO as an output high echo 2 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio2/direction echo 1 > /sys/class/gpio/gpio2/value # 0=front-panel 1=miniPCIe-j8
echo 1 > /sys/class/gpio/gpio5/value # 0=front-panel 1=miniPCIe
The best way to reset a USB device is to 'hot plug' the device by physically removing and reinserting it. However this is not typically possible and there are other options.
Note that BUS Steering can sometimes be a useful alternative to resetting a device as it forces a re-enumeration of the device.
The next best thing to physically removing and re-inserting a USB device is to toggle power to that device. While this is not possible on the USB bus routed to miniPCIe sockets (which run off an always 3.3V power rail) this is possible on:
Ports provided by a USB OTG controller ('OTG' in USB Port name) which support host mode can have their VBUS reset by unbinding and rebinding the host controller via sysfs:
echo 2184000.usb > /sys/bus/platform/drivers/imx_usb/unbind sleep 1 echo 2184000.usb > /sys/bus/platform/drivers/imx_usb/bind
echo dwc2.0 > /sys/bus/platform/drivers/dwc2/unbind sleep 1 echo dwc2.0 > /sys/bus/platform/drivers/dwc2/bind
Ports provided by a USB Hub's (will have a '.<port>' in their bus-device.port entry in the table above) with over-current/fault detection such as those found on a GW530x/GW540x can have their VBUS reset by unbinding their upstream bus-dev from the USB bus:
echo 2-1 > /sys/bus/usb/drivers/usb/unbind sleep 1 echo 2-1 > /sys/bus/usb/drivers/usb/bind
Ports with GPIO controlled VBUS such as the Laguna boards can be reset by turning them on/off via gpio control:
echo 0 > /sys/class/gpio/gpio9/value # de-assert GW2382 VUSB_EN sleep 1 echo 1 > /sys/class/gpio/gpio9/value # assert GW2382 VUSB_EN
echo 0 > /sys/class/gpio/gpio9/value # de-assert GW2387/GW2388/GW2391 VUSB_EN sleep 1 echo 1 > /sys/class/gpio/gpio9/value # assert GW2387/GW2388/GW2391 VUSB_EN
Refer to the USB device table above for the bus-dev and/or VBUS capabilities per board.
In some scenarios (ie Mini-PCIe modem) having command line options to reset these devices via sysfs is preferable and can be found via modern kernel drivers. Refer to the USB Device Table above for the bus-device.port reference for your board/port.
Note that commands targeting a hub cause a soft reset for all child devices which include the front panel and any pcie ports with "usb" on the silk screen. VBUS is only brought down on the front panel port(s) connected to the internal hub.
Examples:
echo 1-1 > /sys/bus/usb/drivers/usb/unbind sleep 1 echo 1-1 > /sys/bus/usb/drivers/usb/bind
echo 2-1 > /sys/bus/usb/drivers/usb/unbind sleep 1 echo 2-1 > /sys/bus/usb/drivers/usb/bind
echo 2-1.1 > /sys/bus/usb/drivers/usb/unbind sleep 1 echo 2-1.1 > /sys/bus/usb/drivers/usb/bind
There are also ioctls that can accomplish the same results programmaticlly and in some cases give even finer control than the above table. An example of a simple program that uses some of these ioctls is the usbreset command (present in OpenWrt):
Further information regarding these ioctls can be found throughout the Linux source documentation.
}}}