See and

Installing USB

OHCI and/or UHCI and/or EHCI (for USB2) have to be included in the kernel. Check e.g. with lspci what your motherboard supports, it does not make sense to select both OHCI and UHCI, however they do not disturb each other.

To check what will be seen on the usb install usbutils for a command line tool or usbview for a gui tool. Make sure version >=2 gets emerged since for new kernels the devices file is no more under /proc/bus/usb/devices but now under /sys/kernel/debug/usb/devices. This file shows what appears on the bus. Alternative command line tools are:


lsusb -t

you must emerge usbutils

e.g. Mount manually usb hard disc

mount -t vfat /dev/sda1 /mnt/usbhd

instead of -t vfat you can use auto.

mount -t auto /dev/sda1 /mnt/usbhd

Unmount it

umount /mnt/usbhd

Disable the low performance USB block driver (BLK_DEV_UB) since it conflicts with USB mass storage support that you have to select to be future oriented (USB_STORAGE). If you have a multi card reader select Probe all LUNs on each SCSI device (SCSI_MULTI_LUN) udev will create the sd* files in /dev if USB_STORAGE is selected. If BLK_DEV_UB is selected /dev/ub* would appear.

udevadm info -a -p $(udevadm info -q path -n /dev/sdc) is a useful command to see what is behind the device file.

According apacer you have to add an option to /etc/modules.conf. The clean way you create a file /etc/modules.d/apacer with the line from the manual

      options scsi_mod max_scsi_luns=8

then run modules-update to put the line in /etc/modules.conf.

For USB2 check out if cables are USB compliant and are not too long e.g. Appearing and disappearing nodes on usbview and EHCI is in the kernel especially USBHD (you might have difficulties to mount them and they disappear and seem to loose data).


When EHCI and OHCI devices are attached, then both EHCI and OHCI need to be installed. This can result that when a EHCI disk is unmounted OHCI remounts it. This can be well observed with programs as usbview but is not what a user wants. To get rid of this remounting a udev rule

        SUBSYSTEM=="usb", <matching argument> OPTIONS=="ignore_device"

USB protocol

USB supports 127 physical devices per host interface (the USB address has 7 bits). PC's can have multiple host interfaces.


The host can reset the bus and all USB hubs will block downstream traffic. This way the USB host sees just the devices immediately attached. All devices have address 0 after the reset. It can therefore configure them and give them one of the 127 available USB addresses. If it is a hub, it can enable downstream of one of the ports and configure there what is found. This way all the devices on the USB bus can be uniquely enumerated. When not configured the devices can draw up to 100mA current, if configured the value is increased up-to 500mA.






















The D+ and D- signals are 3.3V where as the power is 5V.

Data rate

There are also different speeds and versions


USB version

Host interface type


Low speed

USB 1.1



Full speed



High speed

USB 2.0



USB 3.0


Therefore make sure the USB memory devices are attached on the EHCI or USB 2 hosts. The host have two 15kOhm pull down resisters on the data lines to ground. Low speed devices have a 1.5kOhm pull up resistor to 3.3V on the D- line signaling to the host that they are low speed devices. Full speed devices have this resistor on the D+ line.

Data is coded to allow the receivers PLL to synchronize to the data rate. After 6 sequential one bits, a zero bit is stuffed.


Every device has different End Points. Therefore the destination address for a data packet on the USB contains both device address and endpoint number. The endpoint number is 4 bit but 0x80 is added when it has data in direction.

All devices have an endpoint 0 (EP0), where all the hierarchical structured description information can be found and where the device can be configured (default pipe). Other endpoints have a single direction and are used for the application.

Therefore a device can have up to 15 endpoints plus EP0.

Transfer methods

The following transfer methods are supported:

Control Transfer

Used for EP0 configure

Uses a message pipe that contains formatted data and acknowledgment by the receiver

Interrupt Transfer

Host polls here (multiple of 1ms) to get events

Uses stream pipes that have not formatted data

Bulk transfer

Big data exchange without time constraints


Isochronous Transfer

Latency time guaranteed but no error recovery


Data exchange

Since USB is master slave, the host has always to initiate the communication. Devices can just send data when the host has told them to do so.

A Frame locks as follows:

Idle time


PID (Packet Identifier)



End of Package



4 bit plus its 4 bit complementary


5bit or 16bit




Every 1ms a Start of Frame Token is put on the bus, if not the slaves go after 3ms into a suspend mode.

A full speed Start of Frame locks as follows:

Idle time


PID (Packet Identifier)

Frame number


End of Package



4 bit plus its 4 bit complementary

incremented from 0x000 to 0x7FF




SOF (Start of Frame) 0xA5


USB2 uses 125us Micro Frames to increase performance. USB frames are similar to the full speed frames and have more sync and CRC bits.

Device Classes

To avoid that every USB device has its own behavior and own code on the host side. Device Classes are introduced. A good example is, that all USB sticks follow the same Device Class and can therefore be attached and used without the need to install special driver software on the host.


cat /proc/bus/usb/devices or for newer kernels cat /sys/kernel/debug/usb/devices tells you what is attached.

T: Bus=01 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 3 Spd=480 MxCh= 0

D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1

P: Vendor=0dda ProdID=2026 Rev= 1.9c

S: Manufacturer=Generic

S: Product=USB2.0 Card Reader

S: SerialNumber=0000001

C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA

I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

This information is gathered via EP0 of each device, where different Standard Descriptors are read out:

  1. However the first line T: does not come directly from the device it contains how the host has configured the device: USB address, host interface number, ...

  2. Every device has a Device Descriptor, where the information in line D: (and P:) got read, additionally there are links to all other descriptors as String Descriptors

  3. String Descriptors contain what is seen in the S: lines.

  4. Every device has at least one configuration, see C: containing the Configuration Descriptor, where the number of interfaces is defined.

  5. The Interface Descriptor, see I: line, defines how many Endpoints are there

  6. Finally there are the Endpoint Descriptors, see E: lines, that define the endpoint parameters as: direction transfer mode. Note: EP0 is not here since it is always present and fully defined.

This is the multi card reader is a USB2.0 device, having two endpoints #Eps=2 with bulk transfer, one endpoint for each direction. It is device number 3 on the first USB bus in the computer.

The Descriptors are requested using the following C structure.

typedef struct usbRequest{
  uchar       bmRequestType;
  uchar       bRequest;
  usbWord_t   wValue;
  usbWord_t   wIndex;
  usbWord_t   wLength;

The mentioned simple implementations, make use of marking the bmRequestType as vendor specific. After that a frame containing vendor specific data can be sent/received to/from the host.

The numbered directories in /proc/bus/usb represent one host interface but are not human readable.

Linux implementation

There are 3 pieces:

  1. Host interface device driver (UHCI, OHCI, EHCI) is the software the controls the USB host on the motherboard, or plug-in card.

  2. USB core software. Contains everything excluding hardware specific and device specific software.

  3. USB device driver, that can be accessed via /dev as if there would be no USB.

See for more details.

See /usr/src/linux/Documentation/usb/usbmon.txt how to monitor what is going on.

Linurs Servernest startpage