Topic: Adding rt2800 wifi support to the OpenEmbedded kernel build

I'm building my kernel using the OpenEmbedded tools, so I spent some time figuring out how to incorporate RT2800 drivers into the OE build.  Here is a quick summary of what worked for me.

When I bought my Chumby Hackers Board from the good folks at Adafruit, I also bought the TP-LINK TL-WN321G USB wifi dongle they recommend.  The Adafruit tutorial explains that the original supply of this device used the RT73 chipset which is directly supported by the supplied kernel, but newer ones use the RT2800 chipset which requires additional drivers.  Adafruit provides a binary driver update that adds rt2800 drivers to the default kernel.

The rt2800 drivers are not in the 2.6.28 kernel, but they have been backported as part of the most excellent  compat-wireless project.  This is the basis of the update available from Adafruit.

Add compat-wireless

The OpenEmbedded version that works with the Chumby build includes recipes for compat-wireless, but does not include a recipe for a minimal rt2x00 compat-wireless build.  Creating such a recipe is trivial: create compat-wireless-rt2x00.bb in openembedded/recipes/compat-wireless with these lines:

include compat-wireless.inc

do_configure() {
        cd ${S}
        ./scripts/driver-select rt2x00
}

and then add task-base-wifi and compat-wireless-rt2x00 to the list of IMAGE_INSTALL packages.

Add the led class module

The rt2x00 driver requires the led-class kernel module. Without this module loaded you will get an error message like this when you try to load the driver:

 compat: Unknown symbol led_classdev_unregister

The led class library is enabled as a module in the falconwing Linux kernel configuration, but is not installed by the chumby-starterimage receipe.  Resolve this by adding kernel-module-led-class to the list of IMAGE_INSTALL packages.

Install Ralink Firmware

The next barrier is device firmware.  The rt2x00 driver needs to be able to load firmware at boot time.  If the firmware is not available you will see an error message like this when the driver tries to load:

   phy0 -> rt2x00lib_request_firmware: Error - Failed to request Firmware.

I believe same error appears when either the firmware file is not found, or when the udev firmware rules have not been configured.

At this point it is important to know that the USB wifi module uses the Ralink RT2870.  Firmware for the RT2870 is available from the Ralink website. At the time of writing there are a couple of versions available for download.  I've tested version 26 (3/31/2010) and version 2.4.0.1 (7/9/2010) and both seem to load okay.  I haven't really properly tested wifi functionality, but at first glance it appears that 2.4.0.1 supports more features.

Below are the md5sum of these bin files (to help identify versions).

4613706159f1b75b9e6c040c19e09388  v2.4.0.1/rt2870.bin
2bb89af3a7d446deb4695c9a3daa7f9d  v26/rt2870.bin

You need to copy the firmware bin file to /lib/firmware/rt2870.bin on your chumby root file system.

Add udev rules for compat-wireless

There is one more step.  Firmware loading depends upon the rules defined in /lib/udev/rules.d/50-firmware.rules.  You need a new rule to support compat-wireless.  Add this to the end of 50-firmware.rules.  It should look identical to the existing rule, except for the insertion of "compat_".

  SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="firmware --firmware=$env{FIRMWARE} --devpath=$env{DEVPATH}"

That's it.  now after booting I see:

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 74:EA:3A:89:09:FF
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0:avahi Link encap:Ethernet  HWaddr 74:EA:3A:89:09:FF
          inet addr:169.254.9.25  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1

Once I have this rolled into my OE recipes I'll post a link to them.

Re: Adding rt2800 wifi support to the OpenEmbedded kernel build

The drivers for the TP-LINK TL-WN321G USB wifi are now incorporated into this OE build for the hackers board.  Seems to work fine - installs the required kernel drivers, firmware and the udev rules to trigger firmware loading.

The RT2870 recipe is here:
   https://github.com/clearwater/chumby-oe … pes/rt2870

Re: Adding rt2800 wifi support to the OpenEmbedded kernel build

Wow - this is excellent work! Thank you for putting that github repo together. In the process of building a chumby image with the wifi drivers and a few other bits.

Re: Adding rt2800 wifi support to the OpenEmbedded kernel build

Great, hope it is useful.  It took a bit more messing around to configure the wi-fi to automatically connect to a WPA2 PSK network at boot time and then to acquire an IP address via DHCP.   I used wpa_supplicant.  FWIW here are the key network interface configuration files. 

#----------------------------------------------------------------------
# /etc/network/interfaces
#----------------------------------------------------------------------
# The loopback interface
auto lo                 
iface lo inet loopback
                      
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant.conf                      
    wpa-driver wext     
#----------------------------------------------------------------------
# /etc/wpa_supplicant.conf
# To generate the psk key:
# wpa_passphrase networkname password
#----------------------------------------------------------------------
ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1
network={
        ssid="clearwater"
        scan_ssid=1
        proto=WPA RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        psk=ed00742deab3743400deaa7b90058949b91581129426bfd52505bae556313935
}