# New madwifi driver breaks my wlan

## ralle

Hello!

After updating to the latest ~x86 madwifi drivers in portage, my wlan card (atheros ar5212) does not work any more.

iwconfig does not show an ath0 device any more, but a wifi0 device. The wifi0 device does not seem to have any wireless extensions. I already tried recompiling wireless-tools and wpa_supplicant after compiling the new driver, but no luck.

Then I tried to go back to 0.1_pre20050420, but now wpa_supplicant always times out. iwconfig shows the correct information, though.

----------

## Raffi

Similar problems here until I deleted ath_rate_sample.ko left behind by the newer module.

----------

## langthang

the new madwifi-driver is madwifi-ng. to get it work, read http://madwifi.org/wiki/UserDocs/Distro/Gentoo

----------

## Chris W

I think you could achieve the same result within the existing Gentoo network system by using the preup() and postdown() functions explained in

/etc/conf.d/net.example.  I've not tried this in anger yet (not near my Madwifi AP) but I was thinking along these lines....

```

$ cat /etc/conf.d.net 

....8<......snip

preup() {

   if [ "${IFACE}" = "ath0" ] 

   then

       /usr/local/bin/wlanconfig ath0 create wlandev wifi0 wlanmode sta

        return $?

   fi

}

postdown() {

   if [ "${IFACE}" = "ath0" ] 

   then

       /usr/local/bin/wlanconfig ath0 destroy

      return $?

   fi

}

```

If I get the chance I'll test it over the weekend and update the wiki (or someone else might beat me to it).

----------

## ralle

Thanks for your help guys. Unfortunately, I don't have a command wlanconfig.

Can you tell me which package includes the command?

----------

## smathy

 *Raffi wrote:*   

> Similar problems here until I deleted ath_rate_sample.ko left behind by the newer module.

 Thank you, this was precisely my problem (also AR5212 not working after last madwifi update), I manually removed this file from /lib/modules/2.6.13-gentoo-r5/net/ - then merged madwifi-driver again, rebooted and voila!  So thanks again.

----------

## ralle

OK, this did not work for me. I seem to need the program wlanconfig, but I don't know where to find it. It is neither included in madwifi-tools-0.1_pre20051031 nor in wireless-tools-27-r1.

Can anybody confirm that I need wlanconfig in order to make my Atheros AR5212 work? At least langthang's and Chris W's hints need wlanconfig installed. If I need wlanconfig, can anybody find out which package contains it? A simple 

```
whereis wlanconfig
```

 followed by 

```
equery b /path/to/wlanconfig
```

 should do the trick.

----------

## Raffi

Have you looked at linux-wlan-ng yet? I don't have it installed, but that's where I would expect to find it.

----------

## ralle

The description of linux-wlan-ng says: "Programs/files needed for Prism2/2.5/3 based wireless LAN products". That's not what I have. I emerged it anyway, and it contains a program called "wlancfg". But like expected, it is a completely different program.

----------

## Raffi

OK. It was just a guess. I'm not at my laptop, or I would try to hunt around.

----------

## ralle

Thank you. I already looked at /usr/portage/net-wireless, but nothing seemed appropriate.

----------

## WackyDoo

 *ralle wrote:*   

> Thanks for your help guys. Unfortunately, I don't have a command wlanconfig.
> 
> Can you tell me which package includes the command?

 

It seems to be part of madwifi-ng 

madwifi-ng seems to install things in '/usr/local' by default.  Have you checked in /usr/local/bin. Try 

```

BINDIR=/usr/bin MANDIR=/usr/man make install

```

I am not at home to check I my machine.  I started messing with the latest version earlier in the week but haven't go back to it.

----------

## UberLord

wlanconfig is provided by the latest madwifi-tools package

----------

## ralle

OK, wlanconfig was in the latest madwifi-tools package, but the ebuild did not install it. I changed the ebuild so that wlanconfig gets installed, created ath0, but wpa_supplicant keeps timing out.

This is the output:

```

bender ~ # wpa_supplicant -dd -iath0 -Dmadwifi -c/etc/wpa_supplicant.conf

Initializing interface 'ath0' conf '/etc/wpa_supplicant.conf' driver 'madwifi'

Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant.conf'

ctrl_interface='/var/run/wpa_supplicant'

ctrl_interface_group=0

fast_reauth=1

Line: 4 - start of a new network block

ssid - hexdump_ascii(len=7):

     74 65 78 74 69 73 6d                              textism         

proto: 0x1

key_mgmt: 0x2

PSK (ASCII passphrase) - hexdump_ascii(len=23): [REMOVED]

PSK (from passphrase) - hexdump(len=32): [REMOVED]

Priority group 0

   id=0 ssid='textism'

Initializing interface (2) 'ath0'

EAPOL: SUPP_PAE entering state DISCONNECTED

EAPOL: KEY_RX entering state NO_KEY_RECEIVE

EAPOL: SUPP_BE entering state INITIALIZE

EAP: EAP entering state DISABLED

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

Own MAC address: 00:11:95:91:62:5f

wpa_driver_madwifi_del_key: keyidx=0

wpa_driver_madwifi_del_key: keyidx=1

wpa_driver_madwifi_del_key: keyidx=2

wpa_driver_madwifi_del_key: keyidx=3

wpa_driver_madwifi_set_countermeasures: enabled=0

wpa_driver_madwifi_set_drop_unencrypted: enabled=1

Setting scan request: 0 sec 100000 usec

Wireless event: cmd=0x8b06 len=8

RTM_NEWLINK, IFLA_IFNAME: Interface 'wifi0' added

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

RTM_NEWLINK, IFLA_IFNAME: Interface 'ath0' added

Starting AP scan (broadcast SSID)

Wireless event: cmd=0x8b1a len=12

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=0 idleWhile=0

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=0 idleWhile=0

EAPOL: Port Timers tick - authWhile=0 heldWhile=0 startWhen=0 idleWhile=0  

...

```

I also tried to emerge a newer version of wpa_supplicant than 0.3.9, but I get a compile error:

```

i686-pc-linux-gnu-gcc -Os -march=athlon-xp -fomit-frame-pointer -pipe -I. -I../utils -I../hostapd -I/usr/include/madwifi -DCONFIG_DRIVER_HOSTAP -DCONFIG_DRIVER_WEXT -DCONFIG_DRIVER_PRISM54 -DCONFIG_DRIVER_MADWIFI -DCONFIG_DRIVER_ATMEL -DCONFIG_DRIVER_NDISWRAPPER -DCONFIG_DRIVER_IPW -DCONFIG_DRIVER_WIRED -DEAP_TLS -DEAP_PEAP -DEAP_TTLS -DEAP_MD5 -DEAP_MSCHAPv2 -DEAP_GTC -DEAP_OTP -DEAP_LEAP -DEAP_PSK -DEAP_TLV -DIEEE8021X_EAPOL -DEAP_TLS_FUNCS -DPKCS12_FUNCS -DCONFIG_SMARTCARD -DCONFIG_WIRELESS_EXTENSION -DCONFIG_CTRL_IFACE -DCONFIG_READLINE -DCONFIG_NO_STDOUT_DEBUG   -c -o driver_madwifi.o driver_madwifi.c

driver_madwifi.c: In function `set80211priv':

driver_madwifi.c:91: Fehler: Â»IEEE80211_IOCTL_CHANLISTÂ« nicht deklariert (erste Benutzung in dieser Funktion)

driver_madwifi.c:91: Fehler: (Jeder nicht deklarierte Bezeichner wird nur einmal aufgefÃ¼hrt

driver_madwifi.c:91: Fehler: fÃ¼r jede Funktion in der er auftritt.)

make: *** [driver_madwifi.o] Fehler 1 

```

----------

## jamapii

modify the madwifi-tools ebuild, function src_install(), to install wlanconfig (add it to the list of binaries). It will be installed as /usr/bin/wlanconfig

----------

## ralle

That's what I already did, I have wlanconfig installed now. But this does not solve my problem with wpa_supplicant, which is always timing out. Plus, newer versions of wpa_supplicant don't compile on my system.

----------

## jamapii

 *Raffi wrote:*   

> Similar problems here until I deleted ath_rate_sample.ko left behind by the newer module.

 Mod parent up, Important!  :Smile: 

If it doesn't work after downgrading to a previous version, this might be the problem. To find all the kernel modules that need deletion, emerge the new version, do "grep /lib/modules /var/db/pkg/*/madwifi-driver*/CONTENTS" and remove the files you find, then emerge the old version.

It's even possible that the old version contains a file that prevents the new version from working... what about ath_rate_amrr ?

I didn't try it, I just looked at the files.

----------

## ralle

Thank you so much jamapii!

I went back to the latest ~x86 version in portage, like I have done before. The leftovers of the newer driver must have disturbed the older one. But now it works fine again, and I'm very pleased.

I hope the newer madwifi-ng driver gets proper support in Gentoo. At least it is a pain in the ass to set up with this wlanconfig tool. I think you should plug a card in and be able to start the interface.[/glep]

----------

## hlevyn

 *jamapii wrote:*   

> modify the madwifi-tools ebuild, function src_install(), to install wlanconfig (add it to the list of binaries). It will be installed as /usr/bin/wlanconfig

 

How do I modify src_install() to install wlanconfig?

Thanks  :Smile: 

----------

## jamapii

 *hlevyn wrote:*   

> 
> 
> How do I modify src_install() to install wlanconfig?
> 
> Thanks 

 

for a quick fix, login as root, cd /usr/portage/*/madwifi-driver

open the latest .ebuild in an editor, scroll down to he function src_install()

there is a line that starts with dobin (I guess) and contains a lot of names that will end up as binaries, add wlanconfig to this line

For a "real" fix that isn't killed by the next sync, make a portage overlay: 

mkdir -p /usr/local/portage/net-wireless

cp -p -R /usr/portage/net-wireless/madwifi-driver /usr/local/portage/net-wireless

add a line "PORTDIR_OVERLAY=/usr/local/portage" to /etc/make.conf

do the changes in /usr/local/portage

----------

## hlevyn

I'm still having trouble finding the list of binaries. Here's the content of src_install from /usr/portage/net-wireless/madwifi-driver/madwifi-driver-0.1_pre20051111.ebuild

```
src_install() {

    linux-mod_src_install 

    dodoc README COPYRIGHT docs/users-guide.pdf docs/WEP-HOWTO.txt

    # install headers for use by

    # net-wireless/wpa_supplicant and net-wireless/hostapd

    insinto /usr/include/madwifi/include/

    doins include/*.h

    insinto /usr/include/madwifi/net80211

    doins net80211/*.h

}
```

The only real list I see in the ebuild is in pkg_setup() for MODULE_NAMES...

Also, is it just me or is anyone else having trouble accessing madwifi.org?

----------

## Insanity5902

yeah, madwifi.org seems to be down right now.

----------

## hlevyn

Happily madwifi.org came back the other day just long enough for me to grab the sources and update madwifi-driver and madwifi-tools. wlanconfig is now included with madwifi-tools, so I'm able to connect once again (and to an 802.11g network this time too!)  :Smile: 

----------

## Insanity5902

is this uses the newest (latest) drivers.

If so, what did you do to get it to work?  I tried for about 10 minutes and then went back b/c I had to be in the internet right then.

----------

## hlevyn

It's having a bit of a tantrum atm, but not sure if that's due to the driver or to the AP (my inclination is the AP). I'm still using iwconfig rather than wpa_supplicant and it just worked. Once it's back up I'll post some excerts from my /etc/conf.d/net file if you'd like.

----------

## Tiro

anyone that can work his madwifi card and could post a config file??

this card drives me crazy....

----------

## hlevyn

Here's the relevant part from /etc/conf.d/net:

```
modules=( "iwconfig" )

iface_ath0="dhcp"

dhcpcd_ath0="-N"

key_essidGoesHere="000000000000000000000000000 key [1] enc restricted"

preferred_aps=( "essidGoesHere" )

associate_order="forcepreferredonly"

preup() {

  if [ "${IFACE}" = "ath0" ]; then

    /sbin/wlanconfig ath0 create wlandev wifi0 wlanmode sta

    return $?

  fi

}

postdown() {

  if [ "${IFACE}" = "ath0" ]; then

    /sbin/wlanconfig ath0 destroy

    return $?

  fi

}
```

Hope that helps.

----------

## Tiro

am sorry...forget to specify that I haven't any AP. Only ad-hoc cards....

anyway it doesn't work with that config opportunely. It's hard to get working this drivers. Try to downgrade.

Thanks!  :Smile: 

----------

## hlevyn

Ah. I haven't tried with ad-hoc so not sure. Sorry.

----------

## daff

The old driver (20050420 and a AR5212 in my Thinkpad T41p) doesn't work for me anymore either. Trying the new driver didn't work either, wlanconfig segfaults. I think I'll file a bug report about the this. For the sake of completeness I'll post the relevant information here as well. Hopefully this is a problem with the madwifi-driver and not something else on my system. Bug is here.

/etc/portage/package.keywords:

```

...

=net-wireless/madwifi-driver-0.1_pre20051111 ~x86

=net-wireless/madwifi-tools-0.1_pre20051111 ~x86

...

```

/etc/portage/package.unmask:

```

=net-wireless/madwifi-driver-0.1_pre20051111

=net-wireless/madwifi-tools-0.1_pre20051111

```

Then I emerge the new driver:

```

emerge -v =net-wireless/madwifi-driver-0.1_pre20051111 =net-wireless/madwifi-tools-0.1_pre20051111

```

I add the following to /etc/conf.d/net

```

preup() {

        if [ "${IFACE}" = "ath0" ]; then

                /sbin/wlanconfig ath0 create wlandev wifi0 wlanmode sta

                return $?

        fi

}

postdown() {

        if [ "${IFACE}" = "ath0" ]; then

                /sbin/wlanconfig ath0 destroy

                return $?

        fi

}

config_eth0=( "dhcp" )

modules_eth0=( "ifconfig" )

modules_ath0=( "wpa_supplicant" )

wpa_supplicant_ath0="-Dmadwifi"

preferred_aps=( "one_working_ssid" ) 

associate_order="forcepreferredonly"

mode_ath0="managed"

```

Once I load the modules via

```

modprobe ath_pci

```

hotplug/net.agent says:

```

kernel: net.agent[12455]: add event not handled

```

That's not the problem though, obviously it means that hotplug can't yet handle the start of /etc/init.d/net.ath0 by itself, yes?

Anyway, I start the init script via

```

/etc/init.d/net.ath0 start

```

and here it happens:

```

kernel: no rate table, mode 0------------[ cut here]------------

kernel: kernel BUG at /var/tmp/portage/madwifi-driver-0.1_pre20050420-r1/work/madwifi/ath_rate/amrr/amrr.c:207!

kernel: invalid operand: 0000 [#1]

kernel: PREEMPT

kernel: Modules linked in: ath_pci ath_rate_amrr wlan ath_hal snd_pcm_oss snd_mixer_oss snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_intel8x0 snd_ac97_codec snd_ac97_bus snd_pcm snd_timer snd snd_page_alloc ibm_acpi nvram intel_agp agpgart rtc e1000 uhci_hcd ehci_hcd

kernel: CPU:    0

kernel: EIP:    0060:[<e246b3fc>]    Tainted: P      VLI

kernel: EFLAGS: 00010282   (2.6.14-gentoo-r2)

kernel: EFLAGS: 00010282   (2.6.14-gentoo-r2)

kernel: EIP is at ath_rate_update+0x22c/0x240 [ath_rate_amrr]

kernel: eax: 00000018   ebx: c895bdb4   ecx: dda54000   edx: 00000000

kernel: esi: c895bc00   edi: 00000000   ebp: c97d0240   esp: c9f9dccc

kernel: ds: 007b   es: 007b   ss: 0068

kernel: Process wlanconfig (pid: 12988, threadinfo=c9f9c000 task=cf5b9a10)

kernel: Stack: e246bc58 00000000 00000000 ffe00000 00000000 c895bc00 00000000 00000000

kernel: c97d0240 e246b01d c97d0240 c895bc00 00000000 e2536dc9 c97d0240 c895bc00

kernel: 00000000 00000314 c0223be2 c9f9dd30 00000020 00000000 de932454 de932240

kernel: Call Trace:

kernel: [<e246b01d>] ath_rate_node_init+0x1d/0x30 [ath_rate_amrr]

kernel: [<e2536dc9>] ath_node_alloc+0xb9/0x130 [ath_pci]

kernel: [<c0223be2>] sub_alloc+0x62/0x180

kernel: [<e2588596>] ieee80211_alloc_node+0x26/0x1c0 [wlan]

kernel: [<e25876f8>] ieee80211_reset_bss+0x58/0x140 [wlan]

kernel: [<c0223e8d>] idr_get_new+0x1d/0x50

kernel: [<e2587096>] ieee80211_node_latevattach+0x36/0x170 [wlan]

kernel: [<e257cc12>] ieee80211_vap_attach+0x32/0x150 [wlan]

kernel: [<e2599532>] ieee80211_sysctl_vattach+0x1b2/0x220 [wlan]

kernel: [<e257cab7>] ieee80211_vap_setup+0x1d7/0x300 [wlan]

kernel: [<e2588010>] ieee80211_sta_join1_tasklet+0x0/0x40 [wlan]

kernel: [<e25313c5>] ath_vap_create+0x295/0x580 [ath_pci]

kernel: [<e257ded0>] ieee80211_media_change+0x0/0xd0 [wlan]

kernel: [<e257dfa0>] ieee80211_media_status+0x0/0xe0 [wlan]

kernel: [<c0228cd6>] copy_from_user+0x46/0x80

kernel: [<e25985c5>] ieee80211_ioctl_create_vap+0xe5/0x170 [wlan]

kernel: [<c0142137>] find_get_page+0x27/0x50

kernel: [<e253e540>] ath_ioctl+0x0/0x160 [ath_pci]

kernel: [<e253e691>] ath_ioctl+0x151/0x160 [ath_pci]

kernel: [<c034771c>] dev_ifsioc+0x13c/0x440

kernel: [<c0347bf4>] dev_ioctl+0x1d4/0x330

kernel: [<c033c6d4>] sock_ioctl+0xd4/0x250

kernel: [<c017724e>] do_ioctl+0x9e/0xb0

kernel: [<c03aa639>] do_page_fault+0x1b9/0x61d

kernel: [<c0177415>] vfs_ioctl+0x65/0x200

kernel: [<c01775f5>] sys_ioctl+0x45/0x70

kernel: [<c010315b>] sysenter_past_esp+0x54/0x75

kernel: Code: 43 22 00 e9 36 ff ff ff c6 43 27 00 c6 43 23 00

e9 5e ff ff ff 8b 85 30 0d 00 00 c7 04 24 58 bc 46 e2 89 44 24 04 e8 e4 17 cb dd <0f> 0b cf 00 a8 bb 46 e2 e9 fe fd ff ff 8d b4 26 00 00 00 00 83

kernel: rc-scripts: preup ath0 failed

```

After that the whole system gets somewhat flaky; when rebooting it hangs at brining down lo0, for example.

EDIT: As can be seen in the reply to my filed bug one needs to do

```

# find /lib/modules -name "*amrr*" | xargs rm

```

That resolves the segmentation fault.

However, using wpa_supplicant 0.4.6 and the madwifi-driver-0.1-pre20051111 ebuild doesn't seem to work. wpa_supplicant, with WPA-PSK, TKIP et al. is unable to connect to my access point. There are several things that seem to be a bit messed up, for example the wpa_supplicant init scripts not looking for the wpa_* binaries in the right directory (now in /sbin instead of /usr/sbin, apparently).

Now this might be documented in the madwifi.org wiki but I still can't access that website.

----------

## mortar

My card seems to be broken from the new driver also, i've read through this topic but can't seem to solve it, the card is being detected correctly as far as I can tell.

I've removed the old net.ath0 symlink and put in a wifi0 symlink.  

Is /etc/conf.d/wireless still the default configuration file?  

When I /etc/init.d/net.wifi0 start, it seems to bring the device up ok but can't get a DHCP address.

When I manually do an ifconfig wifi0 up and then a iwlist wifi0 scan it complains that wifi0  Interface doesn't support scanning.

Just looking now, after an emerge sync today, it's seem to have installed older versions of the drivers, although ~x86 is still in my package.keywords?

madwifi-drivers is : 0.1_pre20050420-r1

madwifi-tools is: 0.1_pre20050420

Any ideas?

----------

## Insanity5902

Mortar :: Okay appearently you haven't been reading

1) wifi0 is the hardware devicename, not the a device that can be configure, you have to create the ath0 device using the wlanconfig tool, read back in the thread for the proper command

2) you are correct the 20051111 version, which is based on the new code set,  is now hard masked, therefore a package keywords of ~x86 will not emerge it.

----------

## mortar

Ahh sorry skipped over that part.. So do I do this?

 *jamapii wrote:*   

>  *hlevyn wrote:*   
> 
> How do I modify src_install() to install wlanconfig?
> 
> Thanks  
> ...

 

or emerge the newest version again and set it up similar to how daff did?

----------

## Insanity5902

that post gets it to were you have the wlanconfig util that is new to the package.  then with that util you can follow the other post in this thread that set up the ath0 device to configure your wireless, which can be done following daff's post

----------

## adastra

Thanks for all the help in this thread, I was surprised to find my wireless card not working after updating world.  I had to delete the the old modules by hand and mask any versions >0.1_pre20050420-r1 to get it working again.  Now I get these crazy messages about the driver being built with version 16 but this is version 17 or some such crap when I boot but at least it works.  

So I was just wondering, should we be going to the newer version and trying to get it working with the wlanconfig thing or are we OK just sticking with the older version for the rest of our lives?  Anyone see any reason to upgrade?

----------

