Compiling MT7601U/RT2870 WiFi Driver in Fedora

We don’t have enough LAN sockets at work (part-time job) so I decided to just use WiFi in my desktop there. So I bought a cheap USB Network Adapter for WiFi from CD-R King (150Mbps Wireless-N USB Network Adapter WU-NETA-025(A)-CC).

150Mbps Wireless-N USB Network Adapter WU-NETA-025(A)-CC

Unfortunately, Fedora (and it seems other Linux distributions too) don’t have the needed driver for its chipset (MT7601U from Ralink Tech Inc., which seems to be based on RT2870 chipset), so I have to compile it on my own. The package has a CD inside which has the driver for Windows and the source code of the driver for Linux (which you could also get here).

But the driver won’t compile 😮

  CC [M]  /home/kyoushuu/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.o
...
/home/kyoushuu/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.c: In function ‘__RtmpOSFSInfoChange’:
/home/kyoushuu/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.c:1121:20: error: incompatible types when assigning to type ‘int’ from type ‘kuid_t’
   pOSFSInfo->fsuid = current_fsuid();
                    ^
/home/kyoushuu/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.c:1122:20: error: incompatible types when assigning to type ‘int’ from type ‘kgid_t’
   pOSFSInfo->fsgid = current_fsgid();
                    ^
...
make[2]: *** [/home/kyoushuu/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.o] Error 1
make[1]: *** [_module_/home/kyoushuu/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.13.6-200.fc20.x86_64'
make: *** [LINUX] Error 2

Seems like it doesn’t support my current kernel which is Linux 3.13.6.

After some searches in Google, I found out that Linux changed some structs around version 3.8. Some fields changed from int to kuid_t and kgid_t. I only changed two lines in a struct, and finally, it compiled :D.

Here’s the patch. And here’s the complete instructions on how to compile it:

$ su -c 'yum install kernel-devel'
$ tar xjf ~/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2
$ cd DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/
$ patch -p0 < ~/rt2870-mt7601Usta-kuid_t-kgid_t.patch
$ make

(This assumes that the source tarball and the patch is in your home directory. Change the paths if necessary.)

Install the default settings:

$ su -c 'mkdir -p /etc/Wireless/RT2870STA/'
$ su -c 'cp RT2870STA.dat /etc/Wireless/RT2870STA/RT2870STA.dat'

Then load the driver:

$ su -c '/sbin/insmod os/linux/mt7601Usta.ko'

Insert the WiFi adapter to a USB port. Check if you could connect to a network using the WiFi adapter.

WiFi in GNOME 3.12

If it works, install the driver:

$ su -c 'make install'

You could also read the file README_STA_usb in the root of the tarball for these instructions, though it says “rt2870sta.ko” instead of “mt7601Usta.ko”.

Note that you have to reinstall the driver when you update your kernel, since we are not using DKMS here. I don’t know how to use that though.

Advertisements

10 thoughts on “Compiling MT7601U/RT2870 WiFi Driver in Fedora”

  1. I’m on Fedora 20 and got almost the same adapter from the same vendor (WU-NETA-009-R). After plugging it was recognised within seconds. After rebooting (I know you can just load the kmod manually, but it’s Sunday and all..) the kernel modules are loaded and everything works fine. Also, no need to re-compile anything after kernel update. Don’t know why yours was not recognised, any ideas?

  2. Hello,

    Thank you for the guide. However, I am not able to spot the wireless over my phone.

    #lsmod shows the MT760Usta as loaded.

    #lshw -C network shows,
    *-network
    description: Wireless interface
    physical id: 1
    logical name: ra0
    serial: 12:34:56:00:01:3a
    capabilities: ethernet physical wireless
    configuration: broadcast=yes driver=RALINK WLAN multicast=yes wireless=Ralink STA

    Whereas #iwconfig lists,
    *-network
    description: Wireless interface
    physical id: 1
    logical name: ra0
    serial: 12:34:56:00:01:3a
    capabilities: ethernet physical wireless
    configuration: broadcast=yes driver=RALINK WLAN multicast=yes wireless=Ralink STA

    How do I proceed?
    I am using Fedora 20(64 bit) with the kernel 3.14.8-200.

    1. #iwconfig

      ra0 Ralink STA ESSID:”11n-AP” Nickname:”MT7601STA”
      Mode:Auto Frequency=2.412 GHz Access Point: Not-Associated
      Bit Rate:1 Mb/s
      RTS thr:off Fragment thr:off
      Encryption key:off
      Link Quality=10/100 Signal level:0 dBm Noise level:0 dBm
      Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
      Tx excessive retries:0 Invalid misc:0 Missed beacon:0

Blog is now moved to www.kyoushuu.com, please leave your comments there instead.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s