Recognizing USB Devices

Introduced in the late 1990s, USB took a while to take hold, but it's now become an extremely popular device interface. Some computers, particularly Macintoshes, have discarded RS-232 serial and parallel interfaces entirely in favor of USB ports, which are faster than RS-232 serial ports and more flexible than parallel ports. USB's flexibility, though, comes at a cost: Linux requires dozens of distinct drivers to support the many available USB devices. Therefore, configuring USB support can be tricky. Unfortunately, Linux doesn't support all USB devices, although Linux does support many of the most popular USB devices.

USB Driver Requirements

In order to use a USB device, your computer requires at least two types of drivers. In some cases, you may need additional drivers, as well:

USB Host Controller Drivers The host controller driver (HCD) is the driver for USB itself, as implemented by a chipset on your motherboard or a USB expansion card. As of the 2.5.54 kernel, Linux supports three HCDs: Enhanced Host Controller Interface (EHCI), Open Host Controller Interface (OHCI), and Universal Host Controller Interface (UHCI). EHCI handles the USB 2.0 protocol (which is capable of speeds of up to 60MB/S, as opposed to 1,5MB/s for USB 1 .x). UHCI is the USB 1 .x controller used by Intel and VIA motherboard chipsets. OHCI is the USB 1 .x controller used by most add-on cards and motherboards that use chipsets from manufacturers other than Intel or VIA. If your system has USB 2.0 support, you need both the EHCI driver and either the UHCI or OHCI driver.

USB Device Drivers Each USB device is uniquely addressable and supports its own commands. For instance, Linux must be able to treat a USB Zip disk as a block device (to transfer 512-byte blocks in one operation), whereas a USB keyboard must be configured as a character device (to transfer data in single-byte chunks). Furthermore, Zip disks require sector addressing, disk-lock commands, and other features that are not needed by keyboards. Thus, each USB device requires its own drivers. Some of these drivers, such as those for keyboards, mice, and printers, work for an entire class of device. Others, such as mass storage drivers for disk and disk-like devices, are often written for specific brands and models of devices, although generic drivers sometimes work with devices that aren't explicitly supported.

Non-USB Support Drivers Some USB drivers tie into older non-USB portions of the kernel's device driver hierarchy. Most notably, USB mass storage drivers make the USB devices look like SCSI devices to Linux programs. There are also USB-to-RS-232-serial and USB-to-parallel adapters, which link into RS-232 serial and parallel systems in the kernel, respectively; and USB speakers that look like sound cards to software. In all of these cases, you need to activate at least basic support for the mimicked device type. For instance, to use a USB Zip drive, you need both basic SCSI and SCSI disk support. The USB mass storage driver then works much like a driver for a specific SCSI host adapter.

Non-Kernel Drivers Some devices—most notably scanners, cameras, printers, and mice—require non-kernel drivers in support software. Scanners need drivers in the Scanner Access Now Easy (SANE) package, as described in the upcoming section, "Getting a Scanner to Work" Cameras are supported by camera packages, as described in Chapter 8, "Miscellaneous User Tools." Printers usually need drivers in Ghostscript, as described in Chapter 13, "Managing Printers." Mice require drivers in X or in text-based mouse packages. USB mice use the PS/2 mouse protocol or variants of it, as described in the upcoming section, "Using a Mouse to the Fullest."

In addition to these drivers, the Linux USB kernel options include some features that tweak performance or modify the way Linux interfaces with USB devices. For instance, the USB Device Filesystem option creates a /proc/bus/usb/devices virtual file that contains information on USB devices.

Note The USB Device Filesystem option doesn't create any files or subdirectories in the /dev directory. If you activate the/dev Filesystem Support option in the

Filesystems kernel configuration area and activate this filesystem at boot, though, Linux will automatically create device file entries for your USB devices, which can greatly simplify locating them.

Most Linux distributions ship with support for most USB devices available as modules. If you recompile your kernel, though, you'll need to be sure to compile support by selecting the options you need in the USB Support section of the kernel configuration, as shown in Figure 3.2 for a 2.5.54 kernel. Chapter 15, "Creating a Custom Kernel," describes kernel compilation in more detail.

Figure 3.2: The Linux kernel provides a large number of USB driver options.

Tip New USB drivers are constantly being written and added to the kernel. Thus, if a USB device doesn't work with Linux as installed, do a web search or simply try the latest kernel. Your device might be supported in a more recent kernel. You should also check http://www.linux-usb.org, which hosts information on the latest Linux USB developments.

Figure 3.2: The Linux kernel provides a large number of USB driver options.

Tip New USB drivers are constantly being written and added to the kernel. Thus, if a USB device doesn't work with Linux as installed, do a web search or simply try the latest kernel. Your device might be supported in a more recent kernel. You should also check http://www.linux-usb.org, which hosts information on the latest Linux USB developments.

Using a USB Device

Because USB devices are so varied, it's impossible to present simple and complete instructions on their use. The general outline for using USB devices is as follows:

1. Plug the USB device into the computer.

2. If applicable, turn on the device.

3. Load the Linux kernel modules for the driver, as described in Chapter 1, "Optimizing System Architecture Usage." In most cases, the drivers will load automatically when you plug in the device or power it on.

4. Use the device just as you would any other device of its class. For instance, create an appropriate entry for a USB mouse in /etc/X11/XF86Config; or mount a USB Zip disk with mount.

If you opted to create a /dev filesystem, most USB devices will be accessible through files in the/dev/usb subdirectory. For instance, a Kodak DC-240 digital camera appears as /dev/usb/dc2xx0 and a USB scanner is /dev/usb/scannerO. Some devices—mainly those that mimic older hardware types, such as USB mass storage devices—appear under other names. For instance, a USB Zip disk is likely to be accessible as/dev/sda, with partitions numbered /dev/sda1 and up, assuming the system has no true SCSI disks or other USB mass storage devices. Mandrake and Slackware use a /dev filesystem by default, but other common distributions don't.

If you don't use the /dev filesystem, your distribution will have shipped with a large number of device files, most probably including a /dev/usb subdirectory for common USB devices. Unfortunately, naming and placement of device files in /dev isn't entirely consistent across distributions—particularly for USB devices, although most bear common names, such as /dev/usb/scannerO for a scanner. You may need to locate your driver's documentation for instructions on creating device-specific device files, particularly for less common hardware.

The Ultimate Computer Repair Guide

The Ultimate Computer Repair Guide

Read how to maintain and repair any desktop and laptop computer. This Ebook has articles with photos and videos that show detailed step by step pc repair and maintenance procedures. There are many links to online videos that explain how you can build, maintain, speed up, clean, and repair your computer yourself. Put the money that you were going to pay the PC Tech in your own pocket.

Get My Free Ebook


Post a comment