Fixing RT2870 USB wireless in Ubuntu (or Debian)

There’s a bunch of posts all over about installing the vendor proprietary kernel module for the RT2870 chipset. The open source drivers are slow and very flaky. In fact sometimes my machine locked up when using them.

This is one of the best posts about how to install the vendor-provided module.

There’s one thing I could not find: how to install the module with DKMS. What’s DKMS? Dynamic Kernel Module Support. Here’s the Ubuntu wiki topic on it. Basically it automatically compiles your kernel modules so you don’t have to re-compile each module every time you have a new kernel. Ubuntu users know that new kernels pop up pretty often. Besides, it’s the Right Way to add kernel modules.

So here’s how to do it, based on the above RT2870 instructions and with what I could figure out elsewhere with DKMS.

  1. Get the vendor source.

  2. Move the file, such as 2010_0709_RT2870_Linux_STA_v2.4.0.1.tar.bz2, to /usr/src. You will need to be root or use sudo.

  3. Uncompress it while in /usr/src:

    # tar -jxvf 2010_0709_RT2870_Linux_STA_v2.4.0.1.tar.bz2
    
  4. Rename the directory according to linux kernel (and really general sanity) standards and then go that that directory:

    # mv 2010_0709_RT2870_Linux_STA_v2.4.0.1 rt2870sta-2.4.0.1
    # cd rt2870sta-2.4.0.1
    
  5. Edit the config file to enable WPA support:

    # vi os/linux/config.mk
    

    Make these changes:

    # Support Wpa_Supplicant
    HAS_WPA_SUPPLICANT=y
    
    # Support Native WpaSupplicant for Network Manger
    HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
    
  6. Try compiling it:

    # make
    
  7. Don’t worry about warnings, but does it barf out with a bunch of errors? If you have a very recent kernel, Ubuntu 10.10 and afterwards I think, it probably will. Go to the next step. If it compiled okay, skip the next step.

  8. Update one of the files to reflect renamed functions in newer Linux kernels. The instructions to do that are here. Run ‘make’ again and hopefully it works okay.

  9. Clean it all out since we’re going to make it with DKMS instead:

    # make clean
    
  10. Create dkms.conf with the following contents, replacing version number with the driver version number if different than my example. Here’s what mine looks like:

    PACKAGE_NAME=rt2870sta
    PACKAGE_VERSION=2.4.0.1
    MAKE="make"
    CLEAN="make clean"
    BUILT_MODULE_NAME=rt2870sta
    BUILT_MODULE_LOCATION="os/linux/"
    DEST_MODULE_LOCATION="/kernel/updates/dkms"
    AUTOINSTALL="YES"
    
  11. dkms add, build install:

    # dkms add -m rt2870sta -v 2.4.0.1
    # dkms build -m rt2870sta -v 2.4.0.1
    # dkms install -m rt2870sta -v 2.4.0.1
    
  12. Manually create the /etc/Wireless directories and file that the module wants:

    # mkdir /etc/Wireless
    # mkdir /etc/Wireless/RT2870STA
    # cp RT2870STA.dat /etc/Wireless/RT2870STA/
    
  13. Blacklist and remove your old modules:

    # vi /etc/modprobe.d/blacklist-network.conf
    

    Add these lines:

    blacklist rt2800usb
    blacklist rt2x00lib
    blacklist rt2x00usb
    

    Remove these modules from running modules:

    # rmmod rt2800usb rt2x00lib rt2x00usb
    
  14. Pull out your USB wireless adapter, wait a few seconds, plug it back in. Everything should work, at least it did for me. Verify the new module is in use:

    # lsmod | grep -i rt2870
    rt2870sta             450556  1 
    crc_ccitt              12667  1 rt2870sta
    

Things I Skipped

A lot of other posts talk about an ra0 interface, or editing the file in /etc/Wireless, or updating USB IDs, or updating firmware. I didn’t do any of that. It seems to work fine, but your mileage may vary. You might want to have a look at the first link way at the top for more ideas if this does not work. The key part I’m trying to get across here is installing the rt2870sta module with DKMS.