2011/06/12

Fixing the rt2860 wifi chipset under Ubuntu 11.4

I have a Medion Akoya MD96888 that ran ubuntu just fine from day 1. Unfortunately, with the latest Ubuntu versions the wifi connection is really unstable, unreliable and very slow. This post explains how to identify the problem and how to resolve it.

Diagnosis
The following commands will identify which driver ubuntu uses for your wifi card:
nm-tool
...
- Device: wlan0 ----------------------------------------------------------------
Type: 802.11 WiFi
Driver: rt2800pci
State: disconnected
Default: no
HW Address: 00:22:43:13:7F:7B

Capabilities:

Wireless Properties
WEP Encryption: yes
WPA Encryption: yes
WPA2 Encryption: yes ...

 lsmod | grep rt2800pci
rt2800pci 18159 0
rt2800lib 43824 1 rt2800pci
rt2x00pci 13986 1 rt2800pci
rt2x00lib 39075 3 rt2800pci,rt2800lib,rt2x00pci
eeprom_93cx6 12653 1 rt2800pci

sudo lshw -C network
*-network
description: Ethernet interface
product: RTL8101E/RTL8102E PCI Express Fast Ethernet controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:01:00.0
logical name: eth0
version: 02
serial: 00:21:85:4c:75:cc
size: 100Mbit/s
capacity: 100Mbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full ip=192.168.1.60 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
resources: irq:42 ioport:d000(size=256) memory:ffd10000-ffd10fff memory:ffd00000-ffd0ffff memory:dfd00000-dfd0ffff
*-network
description: Wireless interface
product: RT2860
vendor: Ralink corp.
physical id: 0
bus info: pci@0000:02:00.0
logical name: wlan0
Conclusion: ubuntu uses the rt2800pci driver for accessing the RT2860 wifi chipset. This driver causes the instability.

Solution
Currently the only solution is to download the driver directly from Ralink and manually compiling and installing it. Although the command line steps are quite tedious, I did get a stable wifi back. The following steps are copied and slightly updated from http://ubuntuforums.org/showthread.php?t=1592731.

  1. Download latest RT2860 driver source code from Ralink at http://www.ralinktech.com/support.php?s=2. The driver is tagged RT2860PCI/mPCI/CB/PCIe(RT2760/RT2790/RT2860/RT2890). Put the tar into your home directory.

  2. Extract the tar file and go to the expanded directory (ignore the bz2 extensions, bunzip2 won't work):
    tar -xvf ~/2010*
    cd ~/2010*
  3. Edit the config.mk file:
    gedit ./os/linux/config.mk 
    Find the following lines (by default set to "n") and set them to be "y":
    HAS_WPA_SUPPLICANT=y
    HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
    Save and close the file.

  4. Back in the terminal window perform the following command
    gedit ./common/cmm_wpa.c
    For the warning message choose "Western" then "Retry".

    Use the find command to locate "MIX_CIPHER_NOTUSE". Replace the entire line with this code:
    WPA_MIX_PAIR_CIPHER FlexibleCipher = WPA_TKIPAES_WPA2_TKIPAES;
    Save and close the file.

  5. Make sure gcc is installed (usually is by default but if not install it via synaptic) then from the terminal window perform the following commands:
    sudo make
    sudo make install
    sudo ifconfig wlan0 down (on some hardware it is ra0)
    sudo rmmod rt2860sta
    sudo mv /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/rt2860sta.ko /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/rt2860sta.ko.dist
  6. Still in the terminal window perform the following commands:
    sudo depmod -a
    sudo modprobe rt2860sta
    sudo ifconfig wlan0 up (on some hardware it is ra0)
  7. Check that network manager can now select networks and connect to them.

  8. Back in the terminal window perform the following command:
    sudo cp ./os/linux/rt2860sta.ko /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/
  9. In the terminal window perform the following command:
    gksudo gedit /etc/modules
    Add "rt2860sta" on a line at the end of the file then save and close it.

  10. Reboot and check that wifi still works


10 comments:

SimonNZG said...
This comment has been removed by the author.
SimonNZG said...

I've been struggling with an EeePC with similar problems. Same buggy 2800-series driver, but with the RT3090 network card. I broadly followed your example and got a working card at the end and *then* found drivers at https://launchpad.net/~markus-tisoft/+archive/rt3090 that sort-of fixed the problem once and for all, if there ever is such a thing with Ubuntu...

Jeffrey said...

Thankyou, did you find a way to get dual channel? Only getting 135mbps on a 300mbps router...

s2o said...

thank you!
this help me with my eepc901

mackemint said...

Hey, I'm trying to do this under Linux Mint Katya.
All is fine until step 5, I get some messages of unrecognition when entering the command lines:

sudo mv /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/rt2860sta.ko /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/rt2860sta.ko.dist

Did I make a typo or is it different on Linux mint?

Thanks for the initiative on the tut!
Regards
/M

fonso said...

This is actually quite weird.
I followed your instructions with the official ubuntu 11.10 and I can see no diff between the module I compile and the module in the system (which is actually at /lib/modules/3.0.0-12-generic-pae/kernel/drivers/net/wireless/ )

Sasha said...

Courtesy of Ralink changing their website's structure, the source download link has changed:

http://www.ralinktech.com/en/04_support/license.php?sn=5018

Anonymous said...

Thank you. I have been struggling the past couple days to get a Asus wireless pci card working with the rt3562 chipset and your blog had all the hints to build the driver. Much appreciated.

SimW said...

Thanks that worked perfectly for me but note that the move step just needs the file name rt2860sta.ko.dist as the final argument (not the whole directory path again) and on my eeepc the ifconfig step required me to do ra0 up not wlan0 up.

Anonymous said...

Thank you. Great job!
Wifi now working OK on netbook eCafé EC-900/H60G with Lubuntu 11.04 :-)