USB on Linux

By James Holden

What is USB?

  • Intended to provide an easy way to connect a variety of devices to a PC.
  • Specification started in 1994 by Compaq, Intel, NEC and Microsoft.
  • First version completed in January 1996.
  • Version 1.1 launched September 1998.
  • Version 2.0 launched April 2002.

Connecting USB Devices

  • Up to 127 devices, including hubs.
  • Strict master to slave structure, one controller.
  • Mix of low (1.5Mbit/sec) and high(12Mbit/sec) devices.
  • Bus powered devices must be connected to self powered hub.
  • Devices include HID’s, scanners, audio, modem, parallel, serial, mass storage etc…

Linux USB Support

  • Original stack by IÃaky PÃrez GonzÃlez (1996)
  • Linus’ kernel driver from in 2.2.18.
  • Mass storage not supported in 2.2 series.
  • Active development in 2.5 series, with backporting to 2.4 series.
  • Generic support plus specific drivers for unusual peripherals like radio adaptors.

Device Support

  • Scanners – SANE
  • TV cards / Video Capture – Ktuner +
    Video4Linux
  • Input devices – full support
  • Digital camera – mostly mass-storage
  • Serial/Parallel devices – mostly work
  • http://www.qbik.ch/usb/devices/

Kernel Modules

  • usbcore.o Core USB support.
  • usb-uhci.o or usb-ohci.o Controller driver.
  • printer.o, audio.o, scanner.o, visor.o etc… – Generic class drivers or specific drivers.
  • usb-storage.o Storage class driver, provides USB to SCSI layer.
  • Dependancies may load other modules, eg: scsi_mod.o, sd_mod.o, fat.o, vfat.o.

Boot Messages

  • On bootup, the USB controller and root hub should be detected:
  • usb.c: registered new driver usbdevfs
    usb.c: registered new driver hub
    usb-uhci.c: $Revision: 1.275 $ time 07:43:07 Apr 18 2002
    usb-uhci.c: High bandwidth mode enabled
    PCI: Found IRQ 5 for device 00:1f.4
    PCI: Setting latency timer of device 00:1f.4 to 64
    usb-uhci.c: USB UHCI at I/O 0x2440, IRQ 5
    usb-uhci.c: Detected 2 ports
    usb.c: new USB bus registered, assigned bus number 1
    hub.c: USB hub found
    hub.c: 2 ports detected
    usb-uhci.c: v1.275:USB Universal Host Controller Interface driver

Device Connect Sequence

  1. Device is connected (physically).
  2. USB drivers notice, and call /sbin/hotplug with device ID details.
  3. /sbin/hotplug passes the details on to
    /etc/hotplug/usb.agent, which checks
    /lib/modules/…/modules.usbmap
  4. /etc/hotplug/usb.agent loads the appropriate driver.

Device Connection

  • Check /var/log/messages (linked file for illustration purposes only) for encouraging messages

Didn’t Work?

After Connecting

  • Run other commands placing a script in
    /etc/hotplug/usb.handmap
  • Sync PDAs, download camera pictures etc…
  • Some devices require firmware to be loaded.
    Place a script in /etc/hotplug/usb
  • The scripts should have the same name as the driver.

Resources

My contract is ending soon!

  • Need a job!
  • All offers considered
  • Linux, NetBSD, IRIX, Solaris, Netware and that other OS
  • Contract or permanent
  • ‘Glowing references available’ – says my current boss!

Comments are closed.