Feb 11

Making the MT7601UN driver work with Raspbian

I didn’t have ethernet available at the location I wanted my Raspberry Pi to be so I opted to go for a small WiFi USB module to get connected. The one discussed in this blogpost is sold by DealExtreme as Mini 100mW 150Mbps IEEE802.11b/g/n USB WiFi Wireless Network Adapter w/Antenna. The interface comes up as “ralink0” and the company who provides the driver is called MediaTek. The actual chip is called MT7601UN.

This post sums up what errors I got, as a recap here are some things I bumped into while getting the driver to work and which I have been able to resolve:

  • “ERROR: could not insert ‘mt7601Usta’: Exec format error” while modprobing
  • “make[1]: *** No rule to make target `modules’. Stop.” while trying to compile the driver from sources
  • “wpa_supplicant: /sbin/wpa_supplicant daemon failed to start” when trying to connect to an AP
  • “/etc/network/if-up.d/secure-rmc: line 9: let: remainder = % 2: syntax error: operand expected (error token is “% 2”)
    /etc/network/if-up.d/secure-rmc: line 10: let: result = ( / 2): syntax error: operand expected (error token is “/ 2)”)” while having the interface up and running and trying to connect to an AP

Now that is out of our way, let’s take a closer look on how to get a working driver for your Raspbian version. At the time of writing I’m using using the following kernel: Linux 3.12.31 #2 PREEMPT Wed Oct 29 09:24:56 UTC 2014

Let’s look at some of the steps you need to take:

  1. Go to System Info in Kodi and check your kernel version (or ssh and use uname)
  2. Activate “Download kernel headers” in Kodi, we’ll need the Module.symvers file it’ll grab for you
  3. Go to the GitHub page for the rPi Linux kernel and choose the branch that corresponds to your kernel version. When I was trying to get things to work, I forgot about this and used master which was already at 3.18.y instead of 3.12.y and things didn’t work.
  4. While you’re cloning or downloading the Linux kernel grab the driver sources from the MediaTek website, look for MT7601U USB
  5. If you’re using 3.12.y you’ll need to fix the Kconfig file for the Kirkwood soc audio (I put the line it errors on while make’ing in comments)
  6. I couldn’t get the symlink to work that links /lib/…/build to the Linux sources we downloaded from GitHub. At least when I hardcoded the path in the driver’s makefile it worked but only then.
  7. By now your Linux download should be finished. cd into the folder and do
    1. make mrproper
    2. zcat /proc/config.gz > .config
    3. cp .config .config.org
    4. make modules_prepareNote that you’ll need to be root to do the zcat (type sudo -s to stay root)
  8. Copy over the Module.symvers file from the Linux headers folder Kodi downloaded for you
  9. Now go into the driver’s folder and type
    1. make
    2. make install
  10. If all goes well, you now have an interface for your wifi module! (if not, try rebooting)
  11. Type lsusb and see if “Bus 001 Device 007: ID 148f:7601 Ralink Technology, Corp.” pops up
  12. Type iwconfig to check if the interface is there, it’s called ra0
  13. Let’s configure the interface, create the following file /etc/udev/rules.d/70-persistent-net.rules
  14. Add the following in the file:
    1. ACTION==”add”, SUBSYSTEM==”net”, ATTR{type}==”1″, KERNEL==”ra*”, NAME = “wlan0”
  15. Open up /etc/network/interfaces (use nano or vim or whatever editor you like)
  16. Enter the following settings and edit to match with your WiFi setup (address, gateway, ssid and psk):

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1
wpa-ap-scan 1
wpa-scan-ssid 1
wpa-ssid “YOUR-WIFI-NAME”
wpa-psk “YOUR-WIFI-PASSWORD”

You could use dhcp instead of static if you’d like the rPi to have a dynamically assigned IP address however I’d like to keep it static so I know at all times what IP address I can use to reach it.

There you go, things should work now. If they don’t, feel free to leave a comment below and I’ll try to help you out.

The guides I’ve used, merged and mixed together to get it working for myself were:

Make sure you take a look at those pages for some more inspiration if you’re stuck!