Madwifi on Ubuntu / Kubuntu

I’m preparing for a presentation on Madwifi that I will be giving at the next LinuxChix meet. Our faithful leader will be using Ubuntu, not SuSE 10.0, so I figured I’d better check that I know how to set it up under the distro of choice.

Couldn’t figure out for the life of me why madwifi compiled fine in SuSE 10.0 but not Kubuntu 5.10 . Gets a bunch of (to me) utterly meaningless errors and fails right away during make. Turns out you can’t just use gcc ; you have to use a specific version of gcc … the same version that Ubuntu and Kubuntu 5.10 default kernel is compiled under – version 3.4 . …And yet, K/Ubuntu’s package manager installs version 4.0 by default. Arghhh!!

All right, here goes my attempt at a simplified set of directions, given that the steps kind of have to be patched together from 3 different locations [1 2 3] graciously provided by the authors, and then some, as it exists now. Thank you ever so much to those who took the time to provide them. I spent a lot of time trying to figure all of this out, and thought it might be helpful to someone here, to have everything in a linear order and all in one place.

This assumes you have a fresh install of Ubuntu or Kubuntu with the default kernel version 2.6.12-9-386 and that you download a madwifi snapshot more recent than January 23, 2006 (r1407).

First, you will need to make it so the package manager can access packages not maintained by K/Ubuntu (in other words, third-party software). This is not enabled by default. As root, use your favorite text editor (vi, gedit, emacs, pico, etc.) to open /etc/apt/sources.list . Here, I used vi:

$ sudo vi /etc/apt/sources.list

and remove the # from in front of these two lines:

deb http://us.archive.ubuntu.com/ubuntu breezy universe
deb-src http://us.archive.ubuntu.com/ubuntu breezy universe

Save and close.

The madwifi driver is included in the package linux-restricted-modules-2.6.12-9-386 and will conflict with the new one you are installing, so the package needs to be uninstalled before you start. Warning: apt-get (and by extension, the Adept gui interface) will, in its infinite wisdom, mark 2 packages for upgrade and 1 for install as soon as you do. (Grrr.) So you have to then uninstall these too, in order to avoid conflicts. You can do all of this from Adept, searching for and marking each package for removal, or from the command line using:

$ sudo apt-get remove --purge linux-restricted-modules-`uname -r`

Now watch for the names of the packages it wants to install/upgrade. They should be removed using the format sudo apt-get remove –purge packagename:

$ sudo apt-get remove --purge linux-restricted-modules-2.6.12-10-386
$ sudo apt-get remove --purge linux-restricted-modules-386
$ sudo apt-get remove --purge linux-image-2.6.12-10-386

You’ll need to install some packages that madwifi will need (note: this is all one line):

$ sudo apt-get install build-essential linux-headers-`uname -r`
gcc-3.4 subversion sharutils

Now you’re ready to download the madwifi driver:

$ cd /usr/src
/usr/src$ sudo svn checkout http://svn.madwifi.org/trunk madwifi-ng

It probably made a new folder called madwifi-ng , in which case you can

/usr/src$ cd madwifi-ng

to move into the new directory (/usr/src/madwifi-ng) .

Now you will need to force madwifi to compile using gcc 3.4 . Use your favorite text editor to open /usr/src/madwifi-ng/hal/public/i386-elf.inc ; here I used vi:

/usr/src/madwifi-ng$ vi hal/public/i386-elf.inc

Find this line:

CC=    ${TOOLPREFIX}gcc

and change it to this:

CC=    ${TOOLPREFIX}gcc-3.4

Save and close.

Now you are ready to install:

$ make uninstall
$ make
$ make install

You may get this warning

WARNING:
It seems that there are modules left from previous MadWifi installations.
You should consider removing them before you continue, or else you might
experience problems during operation. Remove old modules?

[l]ist, [r]emove, [i]gnore or e[x]it (l,r,i,[x]) ?
r

to Remove.

Optional: If you’re using KDE you can launch kwifimanager to help monitor the wireless card’s status. You can go to K Menu -> Internet -> Wireless LAN Manager (KWifiManager), or open a new shell and type

$ kwifimanager

There will probably be a red “X” through the bar graph, indicating that no wireless card has been found.

You are now ready to load the driver module:

$ modprobe ath_pci

If you’re using kwifimanager, the red “X” should disappear.

You should now be able to type

$ iwconfig

and see something like this:

lo        no wireless extensions.

eth0      no wireless extensions.

wifi0     no wireless extensions.

ath0      IEEE 802.11g  ESSID:""

Mode:Managed  Channel:0  Access Point: 00:00:00:00:00:00
Bit Rate:0 kb/s   Tx-Power:13 dBm   Sensitivity=0/3
Retry:off   RTS thr:off   Fragment thr:off
Power Management:off
Link Quality=0/94  Signal level=-95 dBm  Noise level=-95 dBm
Rx invalid nwid:1  Rx invalid crypt:0  Rx invalid frag:0
Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Now start the scanning module, which will allow you to scan for local wireless networks (also known as a site survey):

$ sudo modprobe wlan_scan_sta

Start the the wireless interface:

$ sudo ifconfig ath0 up

If you know there’s at least one wireless network nearby, start a site survey:

If you’re using kwifimanager, you can click “Scan for networks” and should get a list of networks in a popup dialogue.

Otherwise you can use:

$ sudo wlanconfig ath0 list scan

You should get something like this:

SSID               BSSID                     CHAN    RATE   S:N   INT   CAPS
default            00:12:34:56:78:9a       1        11M    22:0   100   E
janeshmane    00:24:68:ac:e1:35       6        54M    51:0   100   EPS ATH
joeshmoe        00:11:33:55:77:99       5        54M      2:0   100   EPs

If you got this far, you know it’s working. If you’re using KDE, you should be able to go into K Menu -> System Settings -> Network Settings, go into Administrator Mode (ALT-M, if you can’t see the Administrator Mode button), and edit the rest of your settings from there… unless you have WPA encryption, in which case you will need wpa_supplicant . And as I’ve mentioned before, WEP is easily crackable so you should be using WPA. But that will have to be another package for another day.

Ω

Leave a comment