Page 339 - Hacking Roomba
P. 339
320 Part III — More Complex Interfacing
Debugging USB Devices
If you ever have problems with USB devices on Linux (any Linux, not just OpenWrt), you
have options to diagnose them. The first is to look at all the dmesg output you can, as shown in
Listing 14-2. The next is to see which kernel modules are currently loaded:
root@OpenWrt:~# lsmod
Module Size Used by Tainted: P
ftdi_sio 21848 0 (unused)
usb-ohci 19204 0 (unused)
pl2303 12552 0
usbserial 23868 0 [ftdi_sio pl2303]
switch-core 4896 0
wlcompat 14896 0 (unused)
usbcore 74792 1 [ftdi_sio usb-ohci pl2303
usbserial]
wl 423640 0 (unused)
diag 3320 0 (unused)
If you see something missing (or something that shouldn’t be there), use insmod and rmmod to
fix things up. To see which kernel modules are available, look in the /lib/modules/2.4.30/
directory. Each file is a different kernel module.
The /proc virtual file system contains huge amounts of interesting data about the running
kernel. Use cat /proc/cpuinfo to get details on the processor or cat /proc/pci to see
what exists on the internal PCI bus. Similarly for USB, you can see what’s connected on the
USB bus by doing as in Listing 14-3. If you understand USB, it gives you a lot of good infor-
mation. It’s a bit verbose, however, and if all you really want to know is if something is plugged
in, install lsusb and run it.
The dmesg program spews many apparent errors. Usually you can ignore these. OpenWrt is still
a work in progress, and some parts of the system are a little too chatty for users who aren’t
developers. As you become more familiar with OpenWrt, you’ll get to learn which messages are
true errors and which are not. As OpenWrt approaches a 1.0 release, the volume of dmesg out-
put has been going down.
Listing 14-3: Inspecting USB Devices via /proc and lsusb
root@OpenWrt:~# cat /proc/bus/usb/devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh=
2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 0.00
S: Product=USB OHCI Root Hub
S: SerialNumber=b8004000
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00
Driver=hub