Dienstag, Jänner 03, 2006

My wireless adapter and Linux: An odyssey

Today, an odyssey ended: I finally managed to get my Linksys WUSB 54g v4 running nicely on Ubuntu (Breezy Badger). According to current best practices, I have configured my router to use WPA encryption. As I didn't want to use the more insecure WEP just because it's straighforward to configure on Linux I have chosen the hard way. It took me several days, three Ubuntu installations, and quite a bit of experimenting and reading. However, now it's time to sit back and to document my heroic deeds. ;) Enough said, let's start:


  1. Install a fresh Breezy Badger.

  2. Install the package wireless-tools. You can install them with Synaptic as they are located on the CD.

  3. Download the driver. It's *not* the rt2500 driver as you may find in different tutorials, it's the rt2570 driver. That's a slight but significant difference. The rt2570 driver is fine if you have an USB network adapter, the rt2500 one is obviously suited for PCI based adapters. I got yesterday's CVS snapshot.

  4. Before you even try to compile the module, get gcc-3.4. You will need gcc-3.4 because modules have to be compiled with the same compiler version as your kernel has been. Unfortunately, Breezy Badger's kernel has been compiled with gcc-3.4 but the CD contains only gcc-3.3 and gcc-4.0. However, a simple
    apt-get install gcc-3.4
    will not do as we have no network connection yet. ;) Therefore, get the deb's for gcc-3.4, gcc-3.4-base and cpp-3.4 by using another workstation or boot up your Windows (you haven't kicked it of your hard drive yet, have you?). I have found them via www.rpmseek.com. Next, install them with dpkg according to their dependencies. You may need other dependencies as well. However, I haven't needed them because gcc-4.0 was already installed on my system due to my earlier experiments with the driver.

  5. Now unzip the driver to any directory, cd into this directory. Then cd into Module.
  6. Time for some bugfixing (only if you need WPA). Open the file rtusb_info.c and apply the following fix (in short, remove the constant IW_PRIV_SIZE_FIXED which is located around the string "wpapsk"):

    --- rtusb_info.c.orig 2005-12-14 00:54:26.000000000 +0100
    +++ rtusb_info.c 2005-12-14 00:14:14.000000000 +0100
    @@ -1290,7 +1290,7 @@
    { RTPRIV_IOCTL_WEPSTATUS,
    IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "enc"},
    { RTPRIV_IOCTL_WPAPSK,
    - IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WPAPSK_STRING,
    + IW_PRIV_TYPE_CHAR | MAX_WPAPSK_STRING,
    0, "wpapsk"}, // Variable arg count
    { RTPRIV_IOCTL_PSM,
    IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "psm"}, // Variable arg count

    For more information see the driver project's forum.

  7. Now, you're really ready to compile your module. Run
    sudo make
    followed by
    sudo make install

  8. Your module is now located in /lib/modules/2.6.12/extra. cd to /lib/modules/2.6.12-9-386/kernel/drivers/net/wireless, create a new directory rt2570 and copy the file rt2570.ko from /lib/modules/2.6.12/extra into this directory.

  9. Open /etc/modprobe.conf as root and add this line:
    include /etc/modprobe.d/
    Otherwise you will get warnings at bootup.

  10. Go to /etc/modutils/ and create the file rt2570. Open it with an editor and insert
    alias rausb0 rt2570

  11. Almost done. Now we are ready to configure our network card. Open the file /etc/network/interfaces. The following settings worked for me. If you have other settings than me, get these weird integer values from the source (again, see rtusb_info.c).

    mapping hotplug
    script grep
    map rausb0

    auto rausb0

    #your WLAN card
    iface rausb0 inet static
    address 192.168.1.104
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    #from the source code: means WPAPSK
    pre-up iwpriv rausb0 auth 3
    #from the source code: means CIPHER_TKIP
    pre-up iwpriv rausb0 enc 3
    pre-up iwpriv rausb0 wpapsk your_wpakey_as_you_entered_it_during_router_configuration
    up iwconfig rausb0 essid name_of_your_wlan
    up iwconfig rausb0 rate 54M
    up iwconfig rausb0 key open
    up route add -net default netmask 0.0.0.0 gw 192.168.1.1 dev rausb0
    dns-nameservers 192.168.1.1


  12. Now issue
    sudo ifconfig rausb0 up
    If it doesn't work you may try to restart your system and cross your fingers. ;)

  13. Just in case you need to perform troubleshooting: With iwconfig you can check WLAN specific settings. Especially interesting is the link quality. Obviously, it should be greater than 0.