Just thought I'd post some of my notes on getting USB to work 
with 2.2.13.  Maybe this will help someone - or maybe someone
can explain some of the parts I don't understand.

----
Example V2.2.13 USB setup and operation

Anyone who has a recent release of the 2.2.13 kernel (RedHat 6.1 
or Mandrake 6.5, probably some others as well), might notice that
the kernel source has a directory:

/usr/src/linux/drivers/usb 

You might also notice that the /usr/src/linux/Documentation directory 
contains no mention of USB (grep -lir usb *) so your on your own.
The HOW-TO USB V0.8 is just out so I used that for my 
starting point - read this first!  Last I checked it was at:

http://www.dynamine.net/usb/HOWTO/

To get my USB working, I read this and then adjusted a few things to 
make it all work for V2.2.13. Since I'm a relative newbie to this system, 
I don't understand everything that happens, but I was able to make the 
USB stuff work in a couple of hours.

This example is for someone with the following hardware (or similiar):
Media GX 266 MHz
32 MB Ram
2.1 GB Hard disk
Linux Kernel V2.2.13
X-Windows V3.3.5
USB 3 button mouse
USB keyboard
USB trackball
USB hub

I haven't tried this on an Intel based machine yet, but it should be
be about the same process as outlined here.

Note: all of the following is done logged in as root - be warned!

1. Setup the kernel configuration

This is experimental code so several things happened that I was
not expecting (since I've never used the experimental kernel).  First,
copy the configuration file ".config" to config.works or something - 
do not forget this step!

Go to the /usr/src/linux/arch/i386 directory and edit the "config.in" file.
Search for usb and remove the '#' comment character at the beginning of the
line. It should look like this:

source drivers/usb/Config.in

>From the /usr/src/linux directory, using "make menuconfig" I selected the
"Code Maturity Level Options" and then typed Y on the 
"Prompt for development and/or incomplete code/drivers". 
Evidently, this turns on the experimental stuff which is required for the 
USB drivers to work.

However, also note that almost every experimental thing being developed is
turned on as a module or in the kernel.  Not wishing to experiment with 
everything, I went through each option and turned off those marked
Experimental (one heck of a default I think :-(

Now select the desired menuconfig option 
"USB drivers - not for the faint of heart".  

Here are about 7 options that will require that you know something
about your USB hardware.  (Some DOS programs from CATC can detect the type
of controller you have, but I don't think these have been ported to Linux.)

If your motherboard is all Intel all the time, you probably have UHCI. 
Otherwise, Media GX and some other computers use the OHCI device.  Check out
the HOW-TO USB for a better understanding of this identification process.

Since I have a Media GX, I had to enable the following:

        [M] Support for USB (EXPERIMENTAL)
        [*] OHCI (Compact and some others) support ?
        [*] USB mouse support
        [*] USB keyboard support

I didn't try the audio parsing support, since my sound doesn't even work 
on the Media GX yet.  Also, the virtual root hub stuff really wacks out 
a Media GX (possibly others as well - and yes, thats a technical term).

Now escape out and save the configuration file to the default .config 
(you did back this up didn't you ? )

2. Build the kernel

If you want to make sure you turned off everything experimental, use 
"diff .config config.works" and notice that there are a lot of new things
added but commented out - If any new items are not commented  out, you can
go back and try to find them in the "make menuconfig" screens. I didn't
want too many things thrown in the mix at this point, being just a little
faint of heart.

My USB section of the .config file looks like this:

#
# USB drivers - not for the faint of heart
#                                                                               
CONFIG_USB=m
# CONFIG_USB_UHCI is not set
CONFIG_USB_OHCI=y
# CONFIG_USB_OHCI_HCD is not set
CONFIG_USB_MOUSE=y
CONFIG_USB_KBD=y
# CONFIG_USB_AUDIO is not set  

Now you are ready to do the "normal" kernel building stuff:
make clean
make dep
make modules
make modules_install
make bzImage

If any of this is not familiar, you should read up on the kernel
build HOW-TOs or something (also, there may be a better way to do this).

A bazillion messages are now printed to your screen - enjoy your coffee.

3. Setup the kernel for booting

Once this is done (about 1/2 hour of processing??) and everything compiled
correctly, you should notice 2 key files now exist on your system:

/usr/src/linux/arch/i386/boot/bzImage
/lib/modules/2.2.13/usb-ohci-hcd.o

copy the bzImage file to the boot directory:
cp /usr/src/linux/arch/i386/boot/bzImage /boot/testusb

I also copy the system map file, not sure if this is needed or will be
a problem:

cp /boot/System.map System.map.works
cp /usr/src/linux/System.map /boot/testusb.map
ln -s /boot/testusb.map /boot/System.map

Now just update the /etc/lilo.conf file to allow you to boot from this
kernel. I just copied the four lines from another "image=" section and
changed them to look like this:
...
image=/boot/testusb
        label=testusb
        root=/dev/hda5
        read-only                                                               

And, don't forget, do the "/etc/lilo" command to update the boot image. 
Did I mention that you should not forget to run lilo ? Trust me.

4. Reboot and test the usb keyboard

When you reboot, you may want to visit your BIOS to determine that the
USB controller is enabled.  Make sure this is enabled, otherwise,
the hardware specific stuff may not get setup properly.  If you have 
legacy USB support provided by the BIOS, you can use your USB keyboard 
in the BIOS setup screen and at the Lilo prompt.

Now I just rebooted my machine and from the lilo prompt, typed "testusb"
There may be some kernel messages that are useful, I didn't notice any.

If that boots, as root user, change to the "/lib/modules/2.2.13/misc" 
directory and insert the usb module:

insmod usb-ohci-hcd.o

(I just ignored the HOW-TO stuff about usbcore.o - since this file was 
not created, and the driver files - mouse.o, keyboard.o and hub.o will 
not get inserted by insmod - wrong kernel version or some such stuff,
turns out I didn't need them anyhow)

You will see some USB message information printed on the screen, not 
sure what all this means, but thats OK.

Next I plugged in my MicroShaft USB keyboard and *poof* it just started
working.  The backspace key didn't work (it works as a DEL key), but I 
understand this key mapping can be changed, I just haven't tried that yet.
You can even type on both your PS/2 keyboard and your USB keyboard
at the same time - what a deal!

5 Configuring X-Windows with a USB mouse.

Now, for another exercise in hacking, I edited the "/etc/X11/XF86Config" file
and added the following:

Section "Xinput"
 ...
  Subsection   "Mouse"
    DeviceName "USBMouse"
    Protocol   "PS/2"
    Port       "/dev/usbmouse"
  EndSubSection                                                                 
EndSection

(The AlwaysCore statement from the HOW-TO didn't seem to work, but thats OK
too). Also, the HOW-TO suggests making a /dev/usbmouse0, but I noticed that
this didn't work, so I used the /dev/usbmouse link already created. My /dev
directory contains:

lrwxrwxrwx  1 root  root        11 Oct 17 23:23 usbmouse -> hidbp-mse-0 
crw-r--r--  1 root  root   10,  32 Jul 20 15:51 hidbp-mse-0  

Now, use startx to boot X-Windows and from a console window do the
following:

xsetpointer -l

which lists some nice stuff such as:

"USBMouse"      [XPointer]
"keyboard"      [XKeyboard]
"pointer"       [XExtensionDevice]
"SWITCH"        [XExtensionDevice]
"Elo"           [XExtensionDevice]

Also, as per the HOW-TO document - a neat trick to check the hardware,
just to check the keybard and mouse is working, type 

more /proc/interrupts 

to watch the usb interrupt counter - this shows something like:
 ...
  9:     1234        XT-PIC  ohci-usb   

Watch this as you press "up arrow" and return keys. The number (1234)
should be changing by 2 or three counts.  Now (coordinated operation 
here) click the mouse button, press the "up arrow" and then the return 
key - the count should increment by about 30 or 40 counts.

And, to see your mouse working, type

xsetpointer USBMouse

and your pointer should now be controlled by the USB mouse device. Type

xsetpointer pointer

to get back to the default mouse. If you plug in two USB mice, they both
work to control the same cursor - thats handy !?

Other things I noticed: using a Microsoft IntelliMouse (one with a wheel in
the middle of it) didn't work. i.e. in the Xinput section, using:
    Protocol "IntelliMouse"  << doesn't work

6. Automatic USB setup

// Not sure what to do here - you can do the "insmod ..." in one of the power
// up initialization files /etc/rc.d - maybe rc.local or something...
//
// I'm sure there's a way to make X startup the USB mouse also...just don't 
// know how to change that yet.  I'll update this document if someone
// could let me know

7. Summary

Well, thats one example of how I got my USB stuff to work.  I tried it with
a hub and plugging devices in too often causes things to go a little nuts.
If this happens, quickly unplug everything and wait for the hard drive to
cool off. Lots of stuff gets stuffed in the /var/log/messages file.

So, get your configuration set, then leave it alone, thats what I'll do,
at least until I'm brave enough to try the latest USB driver stuff.

Thanks to all the usb developers and Brad Hards for the HOW-TO USB document.
Any mistakes here are purely my own - if you have any questions, I just gave
you about everything I know, so ask somebody who knows whats happening.
Enjoy!

---
Linux - It's now safe to leave your computer on.

Reply via email to