rt2800usb fix for Ralink/MediaTek 3070 [Gentoo / Linux]

I just received a $4.39 USB WiFi adapter from a Hong Kong eBay seller (auction titled “Mini 150M USB WiFi Wireless N LAN Network Adapter 802.11n/g/b”) that has a Ralink 3070 chipset. I tried the rt2800usb driver in gentoo-sources-3.7.9 and got “Invalid RF chipset 0x3070 detected” in dmesg when I plugged the adapter in. The 2012-11-29 drivers from the MediaTek website compiled and loaded OK but they wouldn’t work with wpa_supplicant, and they spammed dmesg. But, luckily I was able to get rt2800usb working by making a few changes to the kernel sources. I’m not getting stellar transfer rates (max ~20 Mbps even though wavemon claims 150 Mbps), but it’s fine for my uses.

lsusb shows this for the adapter:

148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter

I basically just made the driver treat the 0x3070 RF module as a 0x5370:

--- /usr/src/linux/drivers/net/wireless/rt2x00/rt2800.h
+++ rt2800.h
@@ -68,6 +68,7 @@
 #define RF3320            0x000b
 #define RF3322            0x000c
 #define RF3053            0x000d
+#define RF3070            0x3070
 #define RF3290            0x3290
 #define RF5360            0x5360
 #define RF5370            0x5370
--- /usr/src/linux/drivers/net/wireless/rt2x00/rt2800lib.c
+++ rt2800lib.c
@@ -2221,6 +2221,7 @@
      break;
   case RF5360:
   case RF5370:
+   case RF3070:
   case RF5372:
   case RF5390:
   case RF5392:
@@ -2234,6 +2235,7 @@
       rt2x00_rf(rt2x00dev, RF3322) ||
       rt2x00_rf(rt2x00dev, RF5360) ||
       rt2x00_rf(rt2x00dev, RF5370) ||
+      rt2x00_rf(rt2x00dev, RF3070) ||
       rt2x00_rf(rt2x00dev, RF5372) ||
       rt2x00_rf(rt2x00dev, RF5390) ||
       rt2x00_rf(rt2x00dev, RF5392)) {
@@ -2746,6 +2748,7 @@
   case RF3290:
   case RF5360:
   case RF5370:
+   case RF3070:
   case RF5372:
   case RF5390:
   case RF5392:
@@ -4775,6 +4778,7 @@
   case RF3322:
   case RF5360:
   case RF5370:
+   case RF3070:
   case RF5372:
   case RF5390:
   case RF5392:
@@ -5094,6 +5098,7 @@
         rt2x00_rf(rt2x00dev, RF3322) ||
         rt2x00_rf(rt2x00dev, RF5360) ||
         rt2x00_rf(rt2x00dev, RF5370) ||
+        rt2x00_rf(rt2x00dev, RF3070) ||
         rt2x00_rf(rt2x00dev, RF5372) ||
         rt2x00_rf(rt2x00dev, RF5390) ||
         rt2x00_rf(rt2x00dev, RF5392)) {
@@ -5182,6 +5187,7 @@
   case RF3290:
   case RF5360:
   case RF5370:
+  case RF3070:
   case RF5372:
   case RF5390:
   case RF5392:

I also had to download firmware for the dongle:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
cd linux-firmware
cp -a rt*.bin /lib/firmware

EDIT 9/11/2013:
I’m not actually using the dongle anymore with Linux; even though this fix allows it to work in some cases, it will still intermittently drop out or refuse to associate with my AP. Since the patch has worked for so many people, I might just have a flaky unit. In any case, I’m going to swap out my mini-PCIe card instead.

This entry was posted in hacks. Bookmark the permalink.

18 Responses to rt2800usb fix for Ralink/MediaTek 3070 [Gentoo / Linux]

  1. Gadi says:

    The solution worked perfectly.

    Had to do the changes manually – since “patch” failed, but it took 5 minutes in total.

    Thanks

  2. geekamole says:

    I’m glad it worked for you too. I don’t manually patch my kernel often, so I think the paths are incorrect for “patch.”

  3. Petr says:

    Thank you for posting the how-to!
    I have managed to apply your changes and compile the module for openSUSE 12.2 (Mantis) (x86_64) (3.4.33-2.24 kernel) and then cross compile for Raspbian wheezy (3.6.11 kernel).
    You could submit the patch to the Linux kernel.

  4. Nick says:

    PLEASE HELP!!!
    I’ve spent 7 hours, its currently 3am right now, trying to get this stupid adapter to work. Im desperate. Im noobish at best with linux. Im using a raspberry pi kernal 3.6.11+ and have no clue what to do. If you can guide me on how to do all this but with the pi, tha’d be awesome. Also on the pi /usr/src/linux/drivers/net/wireless/rt2x00/rt2800lib.c doesnt exist. the /src folder is completely empty.

  5. Petr says:

    There are some tx power issues of the rt2x00 driver in 3.6.11.
    I have cross compiled today’s 3.9.5 kernel for Raspberry Pi and TX power seems to be changeable now.

    Someone proposed the patch in the mailing list:
    http://rt2x00.serialmonkey.com/pipermail/users_rt2x00.serialmonkey.com/2013-June/006101.html

  6. Mike says:

    Your algorithm (“[make] the driver treat the 0×3070 RF module as a 0×5370”) worked for me using rpi-3.6.y kernel source from github. Thanks!

  7. Kasun says:

    Hi,

    I have the same problem but as im new to linux (using lubuntu) im not sure how to carry out the above procedure. Any help is well appreciated.

  8. Harry says:

    I’ve also bought a cheap adapter from China that I want to use with the Raspberry Pi. It seems some people here have got it working by “cross compiling kernel” I don’t know what this means! I wonder what I need to do to get this working? Any other comments to help with Raspberry Pi users?

  9. Martinlbb says:

    Hey, I made a pull request to add this on 3.6.x branch for Raspberry Pi.
    Here it is:
    https://github.com/martinlbb/linux/compare/raspberrypi:rpi-3.6.y…patch-2

    and
    https://github.com/martinlbb/linux/compare/raspberrypi:rpi-3.6.y…patch-1

  10. gazsiazasz says:

    How can I compile the kernel with these patch for the OpenELEC (Raspberry Pi) distribution? Can you help me? 🙂

  11. geekamole says:

    I don’t own a pi nor do I have experience with them. But try these instructions and just change the appropriate files before running “make.” Ask on a pi forum if you have problems.

    http://elinux.org/RPi_Kernel_Compilation

  12. Ron says:

    Hi

    I have some problems compiling the drivers from MediaTek website. When I run make the script fails at:
    “make[1]: Entering directory `/lib/modules/3.6.11/build’
    make[1]: *** No rule to make target `modules’. Stop.”

    At the make file LINUX_SRC is “/lib/modules/3.6.11/build”. I have tried also with “/usr/src/linux-headers-3.6.11/” but then it complains about not finding file called “memory.h”.

    I have no idea about kernel patching, maybe someone could get some help with that?

    I’m running on raspbmc. Uname -a says:
    “Linux raspbmc 3.6.11 #2 PREEMPT Sat Jun 15 21:45:28 UTC 2013 armv6l GNU/Linux”

  13. Stephan Raue says:

    best would be to report the issue and provide the patch to the kernel developers so it would be included there. only this way all would benefit from this and it will be solved.

  14. jose orlando says:

    Petr,

    could you provide a link to the drivers that you compiled? I couldn’t understand how to cross-compile.

    thanks,

    orlando

  15. jose orlando says:

    Finally I could understand how to compile a new driver for the Raspberry Pi and posted it on a blog. It is in portuguese, but I think that google can translate fairly well :

    http://androideia.wordpress.com/2013/07/20/problemas-com-adaptador-usb-wi-fi-ralink-2870-3070-em-raspberry-pi-e-linux/

    Later I will link the binary that I compiled for my raspberry (kernel 3.6.y), for people that are having problems to compile it by themselves.

    Thanks for sharing the solution!

  16. Kenichi Nisikawa says:

    Thank you for the precious information.
    I can also use Wifi now by my Pie.
    It is very hot in today’s Nagoya (Japan).

  17. Martinlbb says:

    Following your excellent post, I suggested a commit in Raspberry PI kernel.

    https://github.com/raspberrypi/linux/commit/876ddb40b773c8e29583cb9ec6946b6b5f3d1179

    This patch is not accepted and functionnal 😀

    Just do an rpi-update, reboot and 3070 ralink is now available 🙂

  18. Valent says:

    Good news 🙂
    Your patch is being pushed upstream as we speak…

    https://bugzilla.redhat.com/show_bug.cgi?id=974072

Leave a Reply

Your email address will not be published.