Using the EDIMAX EW-7811Un with the EV3 Brick

EDIMAX-EW-7811Un
PDF24    Send article as PDF   
Instructions on how to get the EDIMAX EW-7811Un adaptor working on the EV3 brick using the LMS2012 Code. These instructions could be modified to get any WiFi dongle to work provided that the appropriate wireless driver can be compiled and inserted into the 2.6.33 kernel.

Firmware file:

A Lego EV3 firmware bin file which is compatible with the EDIMAX EW-7811Un adaptor can be downloaded here or at http://tinyurl.com/ev3edimax. This file can be uploaded through the Firmware Update option in the official Lego Mindstorms software.

Note: this will work with the offical Lego Mindstorms software (ignore the warning to upgrade the firmware message).

SD card files:

The uImage and file system archive which are compatible with the EDIMAX EW-7811Un adaptor can be downloaded from here and here.

Required tasks:

By default the brick supports only a Netgear WNA1100 WiFi dongle. To get the EV3 working with the EDIMAX EW-7811Un adaptor you must

  1. Download and compile the rtl8192CU Linux driver against the EV3 Linux kernel to generate the 8192cu.ko kernel module.
  2. Modify the c_wifi.c code in ~/projects/lms2012/c_com/source such that the EV3 brick can detect and use the new adaptor.

Once this is the done, the generated files can be copied to an SD card image and run on the EV3 brick. The EDIMAX EW-7811Un adaptor will then be detectable by the EV3 brick and can be used with the EV3 software. Note this will require the EV3 build environment to be installed on your machine as per the instructions here.

Compiling and installing the RTL8192cu Driver:

The source code for the driver can be found here (obtained from the archive at the edimax website here).

Unpack the driver archive into ~/projects/rtl8192CU_linux_v2.0.939.20100726. The module can then be made with the following bash script

#!/bin/bash # add the arm compiler to the path PATH=~/CodeSourcery/Sourcery_G++_Lite/bin:$PATH<br /> # make the module make -C ~/projects/extra/linux-03.20.00.13 MOD=8192cu M=`pwd` ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi

The 8192cu.ko file should be copied from ~/projects/rtl8192CU_linux_v2.0.939.20100726 into the EV3 LMS2012_EXT partition

sudo cp 8192cu.ko /media/$USER/LMS2012_EXT/lib/modules/*/kernel/drivers/net/wireless/

The module file can be inserted manually be using insmod on system start up or a better solution is to remove the modules.dep file

sudo rm /media/$USER/LMS2012_EXT/lib/modules/*/modules.dep

This will force the new 8192cu.ko to be discovered and installed into the running kernel.

Modifying c_wifi.c:

Five functions in the c_wifi.c file need to be modified to allow the EDIMAX EW-7811Un adaptor to be used. The edited version of c_wifi.c can be downloaded here.

  1. RESULT cWiFiDeepDongleSearch(void)

    The following lines should look like the following (starting on line 1296)

    if (FilePointer)<br /> {<br /> // while((getline(&amp;OneLine, &amp;NumberOfBytes, FilePointer) &gt; 0) &amp;&amp; OneLine)<br /> // {<br /> // if((OneLine = strstr(OneLine, HARDWARE_SEARCH_STRING)) &gt; 0)<br /> // {<br /> Result = OK;<br /> // break;<br /> // }<br /> // }<br /> pclose(FilePointer);<br /> }

    This removes the HARDWARE_SEARCH_STRING check which is set to “ ID 0846:9030 NetGear, Inc.”.

  2. RESULT cWiFiKnownDongleAttached(void)

    The following lines should look like the following (starting on line 1311)

    if((pIdVendor != NULL) &amp;&amp; (pIdProduct != NULL))<br /> {<br /> // if(fgets(VendorBuffer, sizeof (VendorBuffer), pIdVendor) != NULL)<br /> // {<br /> // if(fgets(ProductBuffer, sizeof (ProductBuffer), pIdProduct) != NULL)<br /> // {<br /> // if((strstr(ProductBuffer, WIFI_DONGLE_ID) &gt; 0) &amp;&amp; (strstr(VendorBuffer, WIFI_VENDOR_ID) &gt; 0))<br /> Result = OK;<br /> // }<br /> // }<br /> }

    This removes the WIFI_DONGLE_ID and WIFI_VENDOR_ID check which is set to “ 0846” and “ 9030” respectively.

  3. RESULT cWiFiGetLogicalName(void)

    The following lines should look like the following (starting on line 2582)

    if (FilePointer)<br /> {<br /> char *OneLine = NULL;<br /> size_t NumberOfBytes;<br /> while((getline(&amp;OneLine, &amp;NumberOfBytes, FilePointer) &gt; 0) &amp;&amp; OneLine)<br /> {<br /> //if(strstr(OneLine, "IEEE 802"))<br /> //{<br /> OneLine[5] = 0x00;<br /> strcpy(LogicalIfName, "wlan0");<br /> Result = OK;<br /> // break;<br /> //}<br /> }<br /> pclose(FilePointer);<br /> }

    Before the adaptor is brought up with ifconfig, the EDIMAX EW-7811Un adaptor is termed “unassociated” when the iwconfig command is run. Thus the string check for “IEEE 802” needs to be removed and the expected device name of “ wlan0” should be copied into LogicalIfName.

  4. void cWiFiLoadAthHwModules(void)

    The following lines should be inserted into the cWiFiLoadAthHwModules function (starting on line 3296)

    //#define DEBUG<br /> #undef DEBUG<br /> #ifdef DEBUG<br /> if(!(cWiFiCheckForLoadedModule("8192cu")))<br /> system("/sbin/insmod /lib/modules/2.6.33-rc4/kernel/drivers/net/wireless/8192cu.ko");<br /> #else<br /> if(!(cWiFiCheckForLoadedModule("8192cu")))<br /> system("/sbin/insmod /lib/modules/2.6.33-rc4/kernel/drivers/net/wireless/8192cu.ko &amp;&gt; /dev/null");<br /> #endif

    This checks to make sure that the 8192cu module is loaded into the kernel.

  5. void cWiFiUnLoadAthHwModules(void)

    The following lines should be inserted into the cWiFiUnLoadAthHwModules function (starting on line 3389)

    //#define DEBUG<br /> #undef DEBUG<br /> #ifdef DEBUG<br /> if(cWiFiCheckForLoadedModule("8192cu"))<br /> system("/sbin/rmmod 8192cu.ko");<br /> #else<br /> if(cWiFiCheckForLoadedModule("8192cu"))<br /> system("/sbin/rmmod 8192cu.ko &amp;&gt; /dev/null");<br /> #endif

    This checks to make sure that the 8192cu module is unloaded from the kernel.

After these changes have been made, the lms2012 program needs to be recompiled ( make lms2012. clean followed by make lms2012) and copied on to the EV3 brick file system again.

Future work:

The EDIMAX EW-7811Un adaptor works with the LEGO Mindstorms software and with sending remote commands to the VM. There is however large reported packet loss with this adaptor – Raspberry PI users have also reported similar problems with the EDIMAX EW-7811Un adaptor as discussed here and here.

QUT
Created by Liam O’Sullivan

Previous Post
BrickHID EV3 - PS3 Controller

Direct connection of Bluetooth gamepads to the EV3 Brick

In this project we show that a small C program running on the EV3, brickhid, can handle Bluetooth communications with a PlayStation 3 controller and translate stick positions and button codes into motor ... Read more

Next Post
Vertical-Lift-Span Railway Bridge

Computerised Vertical-Lifting-Span Railway Bridge

Movable Vertical-Lift-Span Bridges have a movable portion deck which remains horizontal as it is lifted vertically. The amount of headroom available is determined by the variations between water levels and ... Read more

Short URL: http://tinyurl.com/japfb47

Leave a Reply

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



Do NOT follow this link or you will be banned from the site!
error: Content is protected !!