Ralink RT2870

This article is on how to use USB WiFi adaptors based on RT2870 or RT3070 chips by Ralink Corp, e.g. Belkin N1 F5D8051 (3100uk) and Vigor N61 USB.

What are the choices?
In kernel >= 3.0, there's only one driver,.

Probably you'll also have to install the necessary firmware  provided by kernel.org, which is included in

In kernels &lt;= 2.6.39, there also existed "staging" drivers, considered to be "experimental", explained below.

Ralink Corp also provides their own version of module. See.

Kernel versions
The staging Ralink 3070 driver in 2.6.32 kernel works fine, but it does not seem to work for newer kernels 2.6.34 and 2.6.35.

Historical background
The long-term aim of the kernel wireless team is to develop support for all Ralink cards within the rt2x00 project; as of December 2009, rt2x00 doesn't support RT2870 so you'll need to use the Ralink-supplied driver, either from "staging" or direct from the vendor.

The staging drivers were originally released by Ralink Tech.

If it works
To see if your adaptor is supported by the driver you chose (after loading the module, if necessary) run :

root ~ $ ifconfig -a dummy0   Link encap:Ethernet  HWaddr fa:db:16:55:98:b3 [snip]

lo       Link encap:Local Loopback [snip]

wlan0    Link encap:Ethernet  HWaddr 4c:e6:76:07:1d:56 inet addr:192.168.11.2 Bcast:192.168.11.255  Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500  Metric:1 ...

If there appears,   or something like that, it's ok.

Using the "staging" sources
IF it successfully creates a wlan0 interface, continue with

and configure using iwconfig / wpa_supplicant / NetworkManager / whatever.

Using the Ralink sources
Download one from their site -> Support -> Linux.

It doesn't compile with 2.6.39 kernel.

Kernel Configuration - Ralink sources
Configure the kernel to enable operation of the RT2870:

Installation
Read the README file well included in the Ralink's source.

The July 2011 driver can be compiled anywhere, but for older drivers, you may have to create a folder for holding the downloaded driver from the Ralink site.

Download (see above) the driver and unpack it. (Ralink may provide a different driver for the rt3070)

For example package 'RT2870_LinuxSTA_V2.3.0.0.tar.tar.bz2' can be saved to:

Now unpack it:

Some adjustments are required to the supplied source before it is compiled.

Basically two lines of the configuration file require editing to enable the RT2870:

Once this has been done, make sure you are in the appropriate directory and compile and install the driver:

The DAT file should be copied to as part of the make install.

Usage
At this point you should have the rt2870sta module available, it to get the adapter up and running:

You can get this to load automatically on boot by adding the following to your modules configuration file:

Add a link for the adapter in :

Please see Wireless/Configuration for notes on configuring the device for your access point.

Finally the adapter can be brought up for network access:

If you want the adapter to be started at boot time add it to your default runlevel as follows:

You should now have the Belkin N1 USB adapter working on a 64bit Gentoo build at 270Mbps and capable of connecting using WPA2.

Troubleshooting
Ensure that you arrange for the re-compilation of the RT2870 driver if you compile and install a new kernel configuration on your system. Compiling your kernel and then rebooting without re-compiling and installing the RT2870 driver may result in no network connectivity.

Kernel 2.6.35
Ralink hasn't upgraded their RT2870 driver since July 2010. The version provided on the website http://www.ralinktech.com/support.php?s=2 doesn't compile in 2.6.35, due to some errors. The kernel developers renamed some functions.

How to fix
-Go to: [driver_dir]/include/os/ and open rt_linux.h -Go to line 1077 and replace it with: -Go to line 1078, replace it with:
 * 1) define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_alloc_coherent(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
 * 1) define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_free_coherent(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)

You should be able to compile the driver now. However, you will see some warnings. If you have played around with some alternatives drivers, unload them. Restart linux. The driver should work now.

When similar adapters are supported, but yours not
If you know similar products are supported by some driver, but when yours is not (yet), you can try patching sources. Warning: this may damage your device. The file to fix is (in Ralink's or stanging driver)  or  (in official), and the patch looks like this: --- linux-3.0.4/drivers/net/wireless/rt2x00/rt2800usb.c.orig 2011-10-11 21:04:16.893188320 +0900 +++ linux-3.0.4/drivers/net/wireless/rt2x00/rt2800usb.c 2011-10-11 21:04:16.893188320 +0900 @@ -1039,6 +1039,7 @@ 	{ USB_DEVICE(0x0411, 0x012e) }, { USB_DEVICE(0x0411, 0x0148) }, { USB_DEVICE(0x0411, 0x0150) }, +	{ USB_DEVICE(0x0411, 0x0158) }, { USB_DEVICE(0x0411, 0x015d) }, /* Corega */ { USB_DEVICE(0x07aa, 0x0041) },

These items are IDs of the device, which you can tell by  command included in. $ lsusb ... Bus 001 Device 002: ID 0411:0158 MelCo., Inc.

sysfs "new_id"
There's an alternative to patching, by using sysfs, like this: echo "0411 0158" > /sys/bus/usb/drivers/rt2870/new_id

However, at least there's one case this trick does not work, even when patching is ok.