Tuesday 8 May 2012

Raspberry Pi meets Edimax EW-7811Un wireless adapter

This post contains my notes - what I did to make it work properly, so next time I build the system, I have a step by step guide. In case you lived under the rock for the last months and don't know what Raspberry Pi is, you should visit www.raspberrypi.org now.

Raspberry Pi

I bought Edimax EW-7811Un adapter for my Pi - small factor, b/g/n type, so why not... especially when vendor says it provides Linux drivers (wohoo!). Sadly as it turns out, compiling drivers on x86 or x64 and ARM architectures can be totally different experience - especially with Raspberry Pi being in it's software infancy. In all seriousness - Pi is for those that like to solve problems (at least at the current stage), but the community works hard to catch up very quickly - great stuff!

The wireless adapter

Under the hood, EW-7811Un runs Realtek's rtl8192cu chipset. Kernel module for this chipset is actually included in Debian 6 image (19-04-2012) distributed via Raspberry Pi website, but it will not work with the card. This is for device with USB ID 7392:7811 - there may be other hardware revisions that will.
Actually after the whole procedure described here, running lsusb shows totally different chipset

EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
so I'm not sure which one it really is... and to be fair, I don't care - it works :-)

Debian6-19-04-2012 image

Debian image is really nice to start with but it has some issues. Maybe I'm purist but working for some time with ARM devices I learned to value resources they offer. I was a bit surprised how many unneeded things were turned on by default and that SSH was actually disabled. We will get those things fixed a bit further down...

Putting the bits together

I had to change the procedure a bit, because the whole system wasn't very stable. I was getting a lot of kernel panics and segfaults that were causing Pi to freeze (read hang up) all the time. First suspicion was power supply (I use iPhone PSU - it's rated 5V/1A) but it turned out to be firmware/kernel issue it seems, so we start with fixing it first. Some of the steps below (especially firmware part) were found on the Raspberry Pi forums in thread about XBMC so kudos to their authors - you guys rock!

  • Start with debian6-19-04-2012 image
  • Download the latest firmware from GitHub - I used revision a8f8d24
  • Copy all files from firmware/boot to /boot
  • Replace /opt/vc with firmware/opt/vc
  • Replace /lib/modules/3.1.9+ with firmware/modules/3.1.9+
  • Download the latest tools from GitHub - I used revision 3aba47b
  • Copy arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root/lib/libstdc++.so.6.0.14 from https://github.com/raspberrypi/tools to /usr/lib and run: sudo ldconfig
Now the wireless part:
  • Download the compiled driver module from here, unpack and move to /lib/modules/3.1.9+/kernel/net/wireless/
  • Run: sudo depmod -a
  • We need to block the kernel module that comes with Debian image - edit /etc/modprobe.d/blacklist.conf and add the following line: blacklist rtl8192cu
  • We want the new module to always load on boot, regardless of hardware being present or not - edit /etc/modules and add the following line: 8192cu
Automatically connect to WPA2 network at boot - no GUI needed:
  • Configure wpa_supplicant - edit /etc/wpa_supplicant.conf:
    # to get encoded PSK run: wpa_passphrase <ESSID>
    psk=<psk returned by wpa_passphrase>
  • Make interface come up automatically - edit /etc/network/interfaces:
auto wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant.conf -B

Various fixes for Debian6-19-04-2012 image

  • Enable SSH at boot if you need it (I do, very much):
sudo update-rc.d ssh defaults
or rename boot_enable_ssh.rc to boot.rc and reboot - this file is on FAT partition so you can do it even under Windows
  • Broken /etc/apt/sources.list - apt-get complains about duplicate sources, easy to fix - debian sources should be in one line, not two:
deb http://ftp.uk.debian.org/debian/ squeeze main contrib non-free
  • Disable services you possibly don't need (I know I don't) but come enabled by default:
sudo update-rc.d -f portmap remove
sudo update-rc.d -f nfs-common remove
sudo update-rc.d -f xinetd remove
  • Fix NTP drift file location permissions - Raspberry Pi doesn't keep time (no battery) so it syncs with NTP after every boot:
sudo chown root:root /var/lib/ntp


Raspberry Pi boots up, brings up wireless interface and connects to the network. After firmware update I have not seen a single kernel panic or segfault yet, which is huge change to how my Pi behaved before. Basically it was dying on any operations that required some more wifi network use (wget was enough), more CPU and/or more RAM... and having 192MB of usable RAM (because we share RAM with GPU) made it really common situation.


Standard disclaimer - it works for me!


  1. t00ty2000.myopenid.com18 May 2012 at 09:17

    Hi Tomasz,
    great tutorial, is it possible to set the wifi to Master mode? I'd like to setup the Raspberry pi as a simple access point.

  2. Most likely yes, not sure if that card would do though... and even if it does, the antenna it has is 'not the best', so to say - definitely I wouldn't use it as an access point. For that I would suggest some wifi card with external antenna and proper chipset that doesn't require all this acrobatics above (something that works out of the box basically).

  3. Hey Tomasz, thanks a ton for putting the above together. This is the 3rd adapter that I've tried on my rapi and was pretty hopeful that with your detailed instructions it would work. My lsusb shows the same chipset and I've followed everything. The dmesg shows no complaints (but shows wlan0 renamed to wlan1, is this normal?). Only thing that worries me is "usbcore: registered new interface driver rtl8192cu" when this entry is in /etc/modprobe.d/blacklist.conf
    iwconfig shows (wlan1 unassociated Nickname:"", Mode:Auto Frequency=2.412 GHz Access Point: Not-Associated, etc) and "iwlist wlan1 scan" returns immediately with "No scan results" (I'd have thought there'd be a delay while it actually looked!)
    Keen to learn more about this. What should I try next? Help greatly appreciated. Thanks in advance,

  4. @skwelsh
    The fact rtl8192cu got loaded means that it's not blacklisted properly - please check the entry is in a separate line and that there is a newline after it... run 'depmod -a' again and reboot.
    As for the wlan0 vs wlan1 - if you go to /etc/udev/rules.d/70-persistent-net.rules you will see wlan0 and MAC address of the interface you tried earlier. Some systems remember interfaces using distinctive elements, like MAC address, USB bus address etc (see my post about building cheap console server for more details). If you want to change device name, just remove both entries and on next reboot it will come up as wlan0.
    Hope it helps ;)

  5. Fantastic! Removing the lines in /etc/udev/rules.d/70-persistent-net.rules seemed to do it. When I rebooted and that blue light flashed on the adapter I knew all was well and after a bit of a change of config for plain old WPA I'm connected! (but your tip on wpa_passphrase was essential). Nice to know an easy available adapter (£10 on Ebay) can work without too much fuss.
    I must read more more of your posts. Got anything on setting up a cross compiler for rapi? ;)
    Many thanks again Tomasz - please keep up the great posts.

  6. Sadly nothing for cross compiler - I plan to look more into it soon, there is several software projects I want to port to RasPi :-)

  7. Works well for my WiFi, but unfortunately after completing the procedure, I can no longer run any OpenGL ES applications, I get the error:
    vchiq_lib: Very incompatible VCHIQ library - cannot retrieve driver version
    * failed to open vchiq instance
    I've tried reverting my /opt/vc back to its original form, but to no avail. (The WiFi continues to work flawlessly.)
    Can someone help?

  8. Thanks for this, very useful. I am using a 3.2.18 kernel so the binary driver you linked to was no good for me. I've found the source for one that worked with a couple of tiny changes and I've uploaded it here in case anyone else is in the same situation: http://nathan.chantrell.net/downloads/raspberry_pi/rtl8192_8188CU_linux_v3.0.2164.20110715.tar.gz

  9. @axedog - I'm sorry but I've not seen it before and sadly I don't have a solution for you at this time. Few questions - did you use the latest version of files from GitHub or the same one as I was using? If the same, then please let me know what app exactly fails, I will try to replicate the issue when time allows.
    @nathanchantrell - awesome stuff, thanks for posting - I'm sure it will be very handy for many people!

  10. matt5384.wordpress.com8 June 2012 at 22:07

    When I boot, it says cannot load wlan0.
    when I run sudo depmod -a, i get tons of errors like this. what do I need to do?
    WARNING: Can't read module /lib/modules/3.1.9+/kernel/drivers/net/wireless/ath/.AppleDouble/ath.ko: Exec format error

  11. @matt5384 - as you copied files to the card using Mac... all hell broke loose, because Macs create additional files that nobody except them would ever need. If you google for "AppleDouble" first three links will explain it.
    Just find all occurrences of the directory .AppleDouble and delete them with all the files inside. You can find those running this command as root:
    find /lib/modules -name '.AppleDouble' -print

  12. Hi,
    Thanks for that nice explanation, but unfortunately it doesn't work for me. I copied everything like you said but now I get an error like this:
    8192cu: disagrees about version of symbol module_layout
    Do you know how to solve that?

  13. This error would suggest you are running another version of the kernel... something is different but remotely (over the net) I can't tell what it is, sorry :-(
    You will have to check everything again, especially the kernel and module versions.

  14. Hi Tomasz - me again. I'm trying the new debian wheezy beta and getting the same "8192cu: disagrees about version of symbol module_layout". How was the driver you have above compiled? Any change of one for wheezy? Thanks in advance.

  15. Are there any changes to this process for the new Raspian image do you know.
    Thank you for producing such a comprehensive guide.
    - Neil.

  16. @skwelsh - I have no idea how it was compiled, I took binary blob only and it worked. As people get other kernel/module versions the symbols may not match and this error will be coming up. Sorry, I'm not much help :-(
    @Neil Ford - I don't know yet, didn't have time to try Raspian. Will do my best to squeeze it into my schedule but can't give exact dates :-(