Connecting Raspberry to a EW-7811Un


After succesfully getting my Raspberry set up and playing around with it I thought it would be a good idea to unleash the beast. So I decided to get rid of the network cable and looked for an appropriate WLAN adapter. The small size of the raspberry lead me straight to the Edimax EW-7811Un – a nano USB adapter.

So after unboxing the adapter and plugging in it turns out that the running Raspbian has no working driver for it. No problem.

I started the journey by updating the running kernel to the latest one available on github. Basically this step is descibed at elinux.org but instead of upgrading just the boot code and loader I upgraded the kernel and modules as well:

cd /opt
git clone --depth 1 git://github.com/raspberrypi/firmware.git
cd firmware/boot
cp * /boot
cd ../modules
cp -r * /lib/modules

A reboot finalized this step. Afterwards the Raspberry was running kernel version 3.2.27+. The next step was the most time consuming part: compiling the kernel and modules of that version (also as described here).

cd /opt
mkdir raspberrypi
cd raspberrypi
git clone --depth 1 git://github.com/raspberrypi/linux.git
cd linux
zcat /proc/config.gz > .config
tmux new -s make
nice make; nice make modules
[Ctrl]+[B],[D]
##############… 8 to 11 hours later…
tmux a -t m
[Ctrl]+[D] 

After some hours the complete kernel along with the modules was compiled. In order to make this available for the driver compilation it is required to link it with the running kernel. Thus

cd /lib/modules/3.2.27+
ln -s /opt/raspberrypi/linux build

incorporates the source tree into the running system.

Now to the driver for the WLAN adapter. It turns out that the driver available on the Edimax web site was not a good choice. Instead of this one the better choice is to get the drivers directly from Realtek (HOME > Downloads > Communications Network ICs > Wireless LAN ICs > WLAN NIC > IEEE 802.11b/g/n Single-Chip > Software and select RTL8192CU). As of this writing Version 3.4.3_4369 was available there. I put the archive RTL819xCU_USB_linux_v3.4.3_4369.20120622.zip onto the Raspberry and extracted the containing source:

unzip RTL819xCU_USB_linux_v3.4.3_4369.20120622.zip
cd RTL8188C_8192C_USB_linux_v3.4.3_4369.20120622/driver
tar xzf rtl8188C_8192C_usb_linux_v3.4.3_4369.20120622.tar.gz
cd rtl8188C_8192C_usb_linux_v3.4.3_4369.20120622

At that was needed now was compiling the driver.As the Raspberry states to be armv6l architecture I needed to provide the right architecture to compile.

make ARCH=arm

When the compile finishes all I needed to do was copying the driver into the module folder:

cp 8192cu.ko /lib/modules/3.2.27+/kernel/net/wireless

The following steps are also explained here. As the system would load the unusable rtl8192cu driver instead of the new one it is required to a line into /etc/modprobe.d/blacklist.conf

blacklist rtl8192cu

To get the new driver loaded at boot time I added a line into /etc/modules

8192cu

So I rebooted the Raspberry andafter it was back online a lsmod showed me that everthing is fine. The driver was loaded and is operational. To check the later I issued a iwlist scan getting a list of visible wireless networks. At the end I followed the steps as listed here:

  • Configure wpa_supplicant – edit /etc/wpa_supplicant.conf:

ctrl_interface=/var/run/wpa_supplicant
network={
ssid=”MyWPA2wifi”
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
# 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

To start that NIC I simply entered ifup wlan0.

That’s it. My Raspberry now has a wlan0 interface which connects to my wireless network giving more freedom in placement.

Leave a comment