Debian Lenny Madwifi and Hostapd stability issues

Hopefully this saves somebody some time. I upgraded my router (a mini-itx Intel Atom box running Debian) to the new Lenny release, which was surprisingly painless. I updated madwifi from the old 0.9.2 version to the 0.9.4 current release included with Lenny.

After this upgrade, I found that the wireless would stop working after 30-90 minutes. This often (but not always) coincided with a couple of error messages often repeated every couple of seconds:

kernel: wifi0: ath_rxorn_tasklet: Receive FIFO overrun; resetting.
kernel: wifi0: ath_bstuck_tasklet: Stuck beacon; resetting (beacon miss count: 11)

These would be matched by a load of messages from hostapd repeated, during which no wireless client would stay connected:

hostapd: ath0: STA 00:13:ce:76:d2:2e IEEE 802.11: associated
hostapd: ath0: STA 00:13:ce:76:d2:2e IEEE 802.11: deauthenticated due to local deauth request
hostapd: ath0: STA 00:13:ce:76:d2:2e IEEE 802.11: disassociated

Reloading hostapd or the madwifi modules would make it work again for another short period.

I tried one of the newest madwifi snapshots which made the problem worse - many more of the beacon miss count errors, extremely poor throughput and high latency and after a few minutes the router locked up.

I also tried a number of fixes recommended to clear up the problem, none of which really made any difference:

echo 0 > /sys/devices/system/cpu/cpu1/online
iwpriv ath0 bgscan 0
iwpriv ath0 protmode 0
iwpriv ath0 rssi11a 11
iwpriv ath0 rssi11b 11
iwpriv ath0 rssi11g 11
iwpriv ath0 bintval 500
iwpriv ath0 mode 3
iwpriv ath0 turbo 0 
sysctl -w dev.wifi0.diversity=0
sysctl -w dev.wifi0.txantenna=1
sysctl -w dev.wifi0.rxantenna=1

In the end I found a couple of independent suggestions that madwifi 0.9.4rc2 worked ok but no longer compiled against recent kernel versions, and that madwifi patch 3696 would fix that. I applied the patch against that 0.9.4rc2, and it built just fine.

Wireless has now been stable for over 24 hours, and I've not seen any more of the missed beacon messages at all, so it looks promising.

I didn't bother attempting to package it 'the debian way' as I was getting a bit fed up at this point, and madwifi has now been officially removed from debian as the ath5k driver is going to be used in future. Unfortunately ath5k doesn't yet work in accesspoint mode, but that is apparently coming soon.

I've archived the files here, just in case they get hard to find.