Monday, December 9, 2013

[FAILED] Getting Ralink RT3290 Wifi working on Linux Mint 15 (and HP Envy 17)

After almost 2 months of procrastinating and hoping that the default wifi drivers did in fact work well, I've finally bitten the bullet and gone ahead to replace the wifi drivers for my HP Envy 17 under Linux.

A bit of history:
- When I tried the LiveCD way back in late September/early October, wifi stability was spotty at best - frequently timing out, dropping out, and gradually getting slower as a session wore on.
- After installing Linux for real though, I didn't encounter any more of these stability problems during everyday use. At least for the first month!
- Last month, I started observing a few cases where wifi stability was really crap:
  1) At uni, where not only was signal strength weak, but the connection would frequently drop or refuse to connect, even after I fixed the logon issues,
  2) it was impossible to use the wifi on this laptop in the lounge, especially with about 3 other devices nearby, yet this setup worked perfectly under Windows 8!
- After returning from holiday, my connection has been really bad and spotty. In fact, it's been really hard trying to upload photos and posts on my blog (like the one yesterday), as everything just kept timing out and/or randomly dropping out. Google web apps like Blogger and Picasa seemed to be hit the worst, though even Google+ image loading was affected. All in all, it was a really frustrating experience!

EDIT: Moments after writing the last paragraph of this post, I got a kernel panic. Depending on how things go, I may/may not need to revert these changes if this instability continues...

EDIT 2: It appears that the kernel panics aren't a random occurrence, but rather something more pathological. So, I've been forced to roll back to the crappy and unstable (but non-crashing) default drivers :(

EDIT 3: After some more digging, it appears that my wifi router's firewall has apparently been hell-banning my laptop for apparent DoS activity (usually corresponding with me trying to load image-heavy, Google-hosted sites!) on some of the days when I haven't been able to connect at all. This follows some suspicious activity coming from an unknown (and untraceable) IP address last week. All in all, there've been a lot of weird happenings since I got back!

Solution:
I ended up following the instructions at http://askubuntu.com/a/253660
I'm repeating the steps I took here for posterity (copied from that original answer, but with some modifications made to make it work - indicated in yellow highlighting).

 1. Go to Mediatek and download the Ralink RT3290 Driver for Linux  (NOTE: you will have to do a bit of a registration thing to get this to work)

 2. Rename the file to 2012_0508_RT3290_Linux_STA_v2.6.0.0.tar.bz2 because Mediatek did a great job on making sure the file works correctly.

 3. Extract the file and it should create a folder named DPO_RT3290_LinuxSTA_V2600_20120508

 4. Go to DPO_RT3290_LinuxSTA_V2600_20120508/os/linux/ and edit the file config.mk

 5. On line 31 you should find the following variable:
  HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n
  change it to
  HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
  and save the file.

  Also make sure that HAS_WPA_SUPPLICANT in the lines above is also set to y

 5. On Mint 15, you'll also need to modify the source code a bit to work around some changes in the Linux kernel:
  
$ gedit os/linux/pci_main_dev.c
and adding the following after the "#include " block near the top
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
#define __devexit
#define __devinit
#define __devinitdata
#endif
then change the portion of the file which says
#if LINUX_VERSION_CODE >= 0x20412 
 remove:     __devexit_p(rt2860_remove_one), 
#else 
 remove:     __devexit(rt2860_remove_one), 
#endif 
to
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
 remove:     rt2860_remove_one,
#else
 #if LINUX_VERSION_CODE >= 0x20412 
  remove:     __devexit_p(rt2860_remove_one), 
 #else 
  remove:     __devexit(rt2860_remove_one), 
 #endif 
#endif


 6. Go to your main extracted folder (It should be the DPO_RT3290_LinuxSTA_V2600_20120508 folder) and type the following:
 sudo make    
 sudo make install
 
 The extra "sudo" on the make command is needed so that it can copy its driver  to a new file called"/tftpboot". (NOTE: on second inspection, this does look a bit suspicious. Hopefully it's just sloppy programming around some paths issues...)

 7. Blacklist conflicting wireless drivers. Do the following:
 $ sudo gedit /etc/modprobe.d/blacklist.conf
 
Add the following lines (Make sure they are not there in the first place):
# Wireless drivers conflicting with rt3562sta
blacklist rt2800pci
blacklist rt2x00pci

Add this driver to the list of modules loaded upon every boot. (NOTE: although the original guide recommended testing whether the driver works without problems first (using sudo modprobe rt3290sta), I couldn't actually get it to work at that point, since I think the original drivers were still loaded (and blocking things).

   1) $ sudo gedit /etc/modules
   2) Add a line at the end of the file that says rt3290sta. Save and exit.

 9. Update initramfs (i.e. the stub os loaded at boot; we want to make sure it knows to load these new drivers instead). Do the following:
  $ sudo update-initramfs -u

 10. Restart.

 We need to do this to make sure that the drivers we want are the only ones loaded at this point.

 Upon restart, you should be prompted with a notice that Wifi Networks were found. If not, something probably went wrong, and you'll need to wind back the driver install. While I don't have any experience in knowing what to do here, my guess is that you should start by basically undoing any changes you made (i.e. remove the blacklisting and /etc/modules entries, running "sudo update-initramfs -u", and restarting).

 In my case, I found that it took several attempts of pushing punching in my password in different places, and/or checking on the settings for the Wifi network (and pressing save on that), before my connection magically worked.

2 comments:

  1. awesome blog. Really helped me out. HP Probook 4340s, Fedora 17 64bit, except i didnt need steps 8 & 9 went straight to reboot after step 7. :-)

    ReplyDelete