{"id":266,"date":"2014-07-20T21:37:51","date_gmt":"2014-07-20T19:37:51","guid":{"rendered":"http:\/\/paguilar.org\/?p=266"},"modified":"2014-07-20T21:37:51","modified_gmt":"2014-07-20T19:37:51","slug":"installing-the-wireless-usb-adapter-edimax-ew-7811un-in-an-embedded-device","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=266","title":{"rendered":"Installing the wireless USB adapter Edimax EW-7811Un in an embedded device"},"content":{"rendered":"<p>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 <a href=\"http:\/\/www.edimax.com\/en\/support_detail.php?pl1_idSelect=support.php%3Fpl1_id%3D1%26mwsp%3D0&#038;pl1_id=1&#038;pd_id=347&#038;button=Go\">Edimax EW-7811Un<\/a>.<\/p>\n<p>There are several wireless USB adapters  that run under Linux, you can have a look at the official site <a href=\"http:\/\/linuxwireless.org\/\">here<\/a> for supported devices and their chipsets. However, this list is far from complete and out-dated.<br \/>\nOf 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.<\/p>\n<p>This was my case because I&#8217;m using an old 2.6.35 kernel and the <strong>8192cu.ko<\/strong> driver was not part of the mainline kernel. It was included in the 2.6.39 under the name <strong>rtl8192cu.ko<\/strong>.<\/p>\n<p>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.<\/p>\n<pre lang=\"bash\">\r\n--- rtl8192CU_8188CU_linux_v2.0.939.20100726.orig\/driver\/rtl8192CU_linux_v2.0.939.20100726\/Makefile 2010-07-26 15:15:06.000000000 +0200\r\n+++ rtl8192CU_8188CU_linux_v2.0.939.20100726\/driver\/rtl8192CU_linux_v2.0.939.20100726\/Makefile  2012-09-10 09:05:53.798611131 +0200\r\n@@ -18,7 +18,9 @@\r\n CONFIG_SDIO_HCI            =   n   \r\n CONFIG_MP_INCLUDED         =   n   \r\n \r\n-CONFIG_PLATFORM_I386_PC    =   y\r\n+CONFIG_PLATFORM_ARM_AT91   =   y\r\n+\r\n+CONFIG_PLATFORM_I386_PC    =   n\r\n \r\n CONFIG_PLATFORM_ARM_S3C2K4 =   n   \r\n CONFIG_PLATFORM_ARM_PXA2XX =   n   \r\n@@ -88,6 +90,15 @@\r\n \r\n PWD := $(shell pwd)\r\n \r\n+ifeq ($(CONFIG_PLATFORM_ARM_AT91), y)\r\n+EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN\r\n+ARCH := arm\r\n+CROSS_COMPILE := arm-linux-\r\n+KVER  := 2.6.35.14\r\n+KSRC ?= \/opt\/buildroot-2011.08\/output\/build\/linux-2.6.35.14\r\n+endif\r\n+\r\n+\r\n \r\n ifeq ($(CONFIG_PLATFORM_I386_PC), y)\r\n EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN\r\n\r\n<\/pre>\n<p>As you can see from the above patch, I&#8217;m using the kernel provided by <a href=\"http:\/\/buildroot.org\/\" title=\"Buildroot\" target=\"_blank\">buildroot<\/a> as the sources for building the driver, but you can change the <em>KSRC<\/em> variable as you need.<\/p>\n<p>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).<\/p>\n<pre lang=\"bash\">\r\nmake ARCH=arm CROSS_COMPILE=arm-linux- modules\r\n<\/pre>\n<p>For testing quickly the driver in your embedded device you can copy it to the rootfs and insmod&#8217;it:<\/p>\n<pre lang=\"bash\">\r\ncp 8192cu.ko \/path\/to\/your\/rootfs\r\ncd \/path\/to\/your\/rootfs\r\n\r\n# In your embedded device\r\ninsmod 8192cu.ko\r\n\r\n# Start wpa_supplicant assuming that you already configured it in \/etc\/wpa.conf\r\nwpa_supplicant -Dwext -iwlan0 -c\/etc\/wpa.conf\r\nifup wlan0\r\n\r\n# If you want to use it with DHCP, start a client\r\nudhcpc -i wlan0\r\n\r\n# And if you're doing everything by yourself, you'll need a default gateway too.\r\nifaces=$(cat \/etc\/network\/interfaces)\r\ngw_wlan0=$(echo $ifaces | awk -F'iface wlan0 inet' '{print $2}' | awk -F'gateway ' '{print $2}' | awk -F' ' '{print $1}')\r\n\r\nroute add default gw $gw_wlan0\r\n<\/pre>\n<p>I&#8217;ve been using this driver for several months and it is quite stable using different WPA encryption methods with b\/g wireless networks.<\/p>\n<p>That&#8217;s it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=266\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8,14],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-compiling","category-driver","category-networking"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266"}],"version-history":[{"count":3,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":395,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions\/395"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}