Installing the wireless USB adapter Edimax EW-7811Un in an embedded device

By | July 20, 2014

Recently, I needed to install and configure a Wireless 802.11/b/g/n USB Adapter in an ARM-based device that runs a 2.6.35 Linux. The adapter was an Edimax EW-7811Un.

There are several wireless USB adapters that run under Linux, you can have a look at the official site here for supported devices and their chipsets. However, this list is far from complete and out-dated.
Of course, the chipsets listed in this site are the ones inside the mainline kernel, but several vendors provide drivers that for one reason or another are not part of the mainline kernel and we have to compile them out-of-tree.

This was my case because I’m using an old 2.6.35 kernel and the 8192cu.ko driver was not part of the mainline kernel. It was included in the 2.6.39 under the name rtl8192cu.ko.

The Makefile provided is for compiling for an i386 based processor, so I created this small patch for compiling for an AT91 ARM processor. You could do the same by just changing the CONFIG_PLATFORM_ARM_AT91 by the one that defines your processor.

--- rtl8192CU_8188CU_linux_v2.0.939.20100726.orig/driver/rtl8192CU_linux_v2.0.939.20100726/Makefile 2010-07-26 15:15:06.000000000 +0200
+++ rtl8192CU_8188CU_linux_v2.0.939.20100726/driver/rtl8192CU_linux_v2.0.939.20100726/Makefile  2012-09-10 09:05:53.798611131 +0200
@@ -18,7 +18,9 @@
 CONFIG_SDIO_HCI            =   n   
 CONFIG_MP_INCLUDED         =   n   
@@ -88,6 +90,15 @@
 PWD := $(shell pwd)
+ifeq ($(CONFIG_PLATFORM_ARM_AT91), y)
+ARCH := arm
+CROSS_COMPILE := arm-linux-
+KVER  :=
+KSRC ?= /opt/buildroot-2011.08/output/build/linux-
 ifeq ($(CONFIG_PLATFORM_I386_PC), y)

As you can see from the above patch, I’m using the kernel provided by buildroot as the sources for building the driver, but you can change the KSRC variable as you need.

Now you can build the driver with the ARCH and CROSS_COMPILE environment variables according to your platform and toolchain. In my case, I have an ARM processor (an AT91SAM9 from STMicroelectronics).

make ARCH=arm CROSS_COMPILE=arm-linux- modules

For testing quickly the driver in your embedded device you can copy it to the rootfs and insmod’it:

cp 8192cu.ko /path/to/your/rootfs
cd /path/to/your/rootfs

# In your embedded device
insmod 8192cu.ko

# Start wpa_supplicant assuming that you already configured it in /etc/wpa.conf
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa.conf
ifup wlan0

# If you want to use it with DHCP, start a client
udhcpc -i wlan0

# And if you're doing everything by yourself, you'll need a default gateway too.
ifaces=$(cat /etc/network/interfaces)
gw_wlan0=$(echo $ifaces | awk -F'iface wlan0 inet' '{print $2}' | awk -F'gateway ' '{print $2}' | awk -F' ' '{print $1}')

route add default gw $gw_wlan0

I’ve been using this driver for several months and it is quite stable using different WPA encryption methods with b/g wireless networks.

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *