12.8 USB Devices


The Universal Serial Bus (USB) was designed by a consortium of hardware and software vendors Compaq, Intel, Microsoft and NEC beginning in 1994. It was conceived to provide a standardized way of connecting a wide range of peripheral devices to a computer (read "personal computer") and to correct some of the limitations of traditional serial and parallel lines.

USB has the following advantages:

  • Up to 127 devices can be connected.

  • Devices can be added and removed while the system is running.

  • Connectors have been standardized across all device types.

  • It is much faster. The theoretical bandwidth of a USB bus is 12 Mbs/sec; however, actual throughput is more like 8-8.5 Mbs/sec, and devices seldom achieve more than about 2 Mbs/sec.

USB cables contain only four wires: power, ground, send, and receive. Communication is handled in a hierarchical manner, under the control of a master; attached devices all function as slaves, thereby eliminating issues such as avoiding collisions. USB cable connectors are illustrated on the far left in Figure 12-2, and Figure 12-5 illustrates their corresponding pinouts.

Figure 12-5. USB connectors
figs/esa3.1205.gif

B-type connectors are used for the USB port on the device, and A-type connectors are used for the port on the hub or computer system.

FreeBSD, HP-UX, Linux, Solaris, and Tru64 all support USB devices to some extent, although the support under HP-UX and Tru64 is limited to the USB keyboards and mice that come with the system (and are accordingly preconfigured by the operating system).

We will consider configuring three sample USB devices a mouse, a Zip drive, and a printer on the other three systems in the remainder of this section.

Table 12-6 summarizes the device files used for some USB devices on these systems.

Table 12-6. Example USB device special files

Device

FreeBSD

Linux

Solaris

mouse

/dev/ums0

/dev/input/mouse0, /dev/input/mice

/dev/usbms

Zip drive

/dev/da0s4

/dev/sda4

/dev/dsk/c1t0d0s0:c

printer

/dev/ulpt0

/dev/usblp0

/dev/usbprn0

12.8.1 FreeBSD USB Support

FreeBSD provides good support for USB devices, although some of it is in the experimental stage. See the FreeBSD USB project's home page, http://www.etal.net/~n_hibma/usb/, for details on the current status.

Before you can use USB devices, you must configure support in the kernel. The following kernel configuration file lines relate to USB support:

device          uhci         General USB support modules. device          usb device          ugen device          ohic         Alternate USB chipset support. device          uhid device          ukbd         Keyboard. device          ulpt         Printer. device          umass        Mass storage: Zip drive. device          umodem       Modem. device          ums          Mouse. device          uscanner     Scanner.

You should always include the first four items. Include uhid also if you are using a mouse or keyboard. Include as many of the other items as makes sense for your configuration (or include all of them to allow for flexibility in the future).

You can determine if your kernel includes USB support that is compatible with the USB controller on the system by examining the output of dmesg:

# dmesg | grep usb usb0: OHCI version 1.0, legacy support usb0: <OHCI (generic) USB controller> on ohci0 usb0: USB revision 1.0

This kernel is configured for USB support, and it successfully detected the controller.

You can load the USB kernel module manually via the kldload usb command. Alternatively, you can set the appropriate modules to load automatically in the /boot/loader.conf file. Here we load general USB support and the modules for the mouse, keyboard, printer and Zip drive:

usb_load="YES" ums_load="YES" ukdb_load="YES" umass_load="YES" ulpt_load="YES"

See Chapter 16 for information about building FreeBSD kernels and modules.

You can list the current USB devices with the usbdevs command:

# usbdevs addr 1: OHCI root hub, (unknown)   addr 2: Genius USB Wheel Mouse, KYE   addr 3: TUSB2046 hub, Texas Instruments     addr 4: Espon Stylus Photo 1280     addr 5: USB Zip 250, Iomega

This system has a USB mouse in one of the system's USB ports and a USB hub in the other. The secondary hub has a printer and a Zip 250 drive attached to it.

Some USB devices are configured automatically when they are detected, via the usbd daemon; the actions performed are specified in its configuration file, /etc/usbd.conf . This is the case for the printer, the Zip drive, and the USB mouse used in the system console's text mode.

Using the mouse under X as well requires an additional step, however. You must edit the XF86Config file to make X aware of the USB mouse (this file is usually in /etc). Under XFree86 Version 3.3, you modify the Pointer section as follows:

Section "Pointer"   Device  "/dev/sysmouse"   Protocol "MouseSystems" EndSection

A USBprinter is also easy to configure. You can set it up like any other printer within the LPD facility, using the special file /dev/ulpt0 to refer to the printer.

A Zip drive is accessed via the USB mass storage driver. Via sleight of hand, it manages to trick the standard SCSI driver into servicing a USB disk. Accordingly, the kernel must also provide SCSI support in order to use such USB devices, and SCSI disk special files will be used to refer to them.

For example, the following command can be used to mount the disk in a Zip drive at /zip:

# mount -t msdos /dev/da0s4 /zip

The DOS partition on a Zip disk appears as the fourth slice to FreeBSD.

Alternatively, you can create a UFS filesystem on a Zip disk using the usual commands (see Section 10.3):

# disklabel -w -r da0 zip250 # newfs /dev/da0c # mount -t ufs /dev/da0c /somewhere

12.8.2 Linux USB Support

Linux also provides good support forUSB devices. Once again, support for them must be enabled in the kernel. Figure 12-6 illustrates make xconfig's USB menu.

Figure 12-6. Linux USB-related kernel parameters
figs/esa3.1206.gif

We show only part of this very long parameter list (the gap indicates omitted selections). The items are divided into sections of related settings, beginning with general USB support and then support for hubs and devices classes, followed later by choices corresponding to specific USB devices. The ones required for our three devices are highlighted. I recommend selecting module-based support whenever possible.

You will also want to install the usbutils package and possibly the usbview package, as well (the latter provides a graphical USB device display command of the same name). We'll use tools from the former in this section.

You can view the currently attached USB devices with lsusb:

# lsusb | grep Bus Bus 001 Device 001: ID 0000:0000 Bus 001 Device 002: ID 0458:0003 KYE Systems Corp.(Mouse Systems) Bus 001 Device 003: ID 0451:2046 Texas Instruments TUSB2046 Hub Bus 001 Device 004: ID 059b:0030 Iomega Corp. Zip 250

USB device attributes are also available within the /proc filesystem, in files named like /proc/bus/usb/bus#/dev#. For example, the usbmodules command can be used to list the device-specific modules used by a USB device:

# usbmodules --device /proc/bus/usb/001/002 usbmouse hid

As with FreeBSD, using a USB mouse in the system console does not require configuration. If you want to use one under X, however, you must edit the XF86Config file, usually found in /etc/X11 (we are assuming Version 4 here). In order to use a USB mouse instead of the usual mouse type, add an InputDevice section like this one:

Section "InputDevice"     Identifier "USB Mouse"     Driver "mouse"     Option "Protocol" "IMPS/2"     Option "Device" "/dev/input/mice" EndSection

The special file mentioned in this example, mice, refers to any and all USB mice present on the system. If you want to specify just the first USB mouse, substitute /dev/input/mouse0.

In addition, you must designate the mouse to the X server via an InputDevice directive in the ServerLayout section. For example, these entries allow you to use both a normal and a USB mouse:

Section "ServerLayout"     Identifier   "Layout[all]"     InputDevice  "Mouse[1]" "CorePointer"     InputDevice  "USB Mouse" "SendCoreEvents"     ... EndSection

If you want to use only a USB mouse, remove the entry for the usual mouse, and set the second parameter of the USB mouse's entry to CorePointer.

Configuring a USB printer is no different than configuring any other printer. Using the administrative tools to do so is often a quick method. For example, Figure 12-7 illustrates the SuSE Linux YAST2 printer management facility's built-in USB printer support. In it, we see the available USB device choices.

Figure 12-7. Adding a USB printer with YAST2
figs/esa3.1207.gif

Alternatively, you can set up a printer manually, using the same device file, /dev/usb/lp0. On SuSE 7 systems, the corresponding device is /dev/usblp0.

As under FreeBSD, accessing a USB Zip drive uses an interface to the SCSI subsystem (which must also be enabled in the kernel). For example, the following command could be used to mount a Zip disk at /zip:

# mount -t vfat /dev/sda4 /zip

The Zip disk's DOS partition is interpreted as partition 4 on the disk. You can also build other filesystem types on Zip disks, if you like.

For more information about the Linux USB project, see http://www.linux-usb.org.

12.8.3 Solaris USB Support

Solaris also provides support for USB devices. In fact, some Sun systems, like my Sun Blade, come with USB keyboards and mice standard, and no additional configuration is required to use them.

You can also use the system's USB ports for other sorts of devices. I tried using the same devices on my Sun as for the other two operating systems. The Zip drive worked fine. I used the following command to mount it:

# mount -F pcfs /dev/dsk/c1t0d0s0:c /zip

Like the other systems, the Solaris USB mass storage driver interfaces to the SCSI drive, and so the Zip drive's special filename is of the usual SCSI form. The DOS partition corresponds to the c slice.

Solaris offers support only for a very few USB printers, accessed via the /dev/usbprn* device files or via the usual /dev/printers/* files.

Keeping Up to Date

Serial lines and terminal handling is an area in which tremendous changes have taken place in recent years. Thus, it illustrates one of the occupational hazards of any technically-oriented profession: having one's expertise become outdated and stale. Here are some simple things you can do to avoid having this happen to you:

  • Attend system administration-related technical conferences, such asLISA (see http://www.usenix.org/events/), or those put on by hardware vendors. I try to attend at least one a year.

  • Regularly monitor administrative and security-related websites, mailing lists or newgroups. Late breaking news often first appears in these forums. This is especially important for administrators of open source operating systems.

  • Subscribe to and read periodicals (at least a few of the articles or columns) devoted to the types of systems that you administer. I subscribe to SysAdmin magazine (see http://www.samag.com) as well as some operating system-specific publications.

  • Reread all of the manual pages on the system every six months. I have a friend who does this religiously, and it's his recommendation. I must admit that I don't really have time to do this, but I do try to read all of the administrative (1m) manual pages about once a year. (Even this is a lot to do when you administer 10 different kinds of systems.)



Essential System Administration
Essential System Administration, Third Edition
ISBN: 0596003439
EAN: 2147483647
Year: 2002
Pages: 162

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net