BeagleBoard Rev C5 Wifi Enablement with Ralink USB Dongle

BeagleBoard Rev C5 Wifi Enablement with Ralink USB Dongle


This is a simple tutorial on how to use Buildroot (http://buildroot.uclibc.org/ ) to build a simple embedded Linux system for the BeagleBoard RevC5 ( http://beagleboard.org/) and enble Ralink drivers for an inexpensive Panda Wirelessv ( http://wirelessusbcentral.blogspot.com/ ) USB Wifi Dongle from Amazon ( http://www.amazon.com/Panda-150Mbps-Wireless-N-2-4GHz-Adapter/dp/B003283M6Q ).

This was done on an Ubuntu 10.04 Virtual Machine. I assume you know how to connect up your board with power and serial to USB connections. I also assume you have a SD card reader connected to your machine with at least a 4 GB SD card inserted. You need to format the SD card to have 2 partitions. The first is a FAT partition marked with a boot flag and the second is an EXT3 ( Linux ) journaled partition to hold the root file system. Check out this post for a script to do this for you-->http://cgit.openembedded.org/cgit.cgi/openembedded/tree/contrib/angstrom/omap3-mkcard.sh.

This tutorial also depends on the information in my last post ( http://ptrackapp.com/apclassys-notes/beagleboard-rev-c5-simple/) in order to configure a basic system with Buildroot, such as console and other basic configuration options. The only difference is I used the Linux 3.2.23 Kernel instead of 3.4.4.

Download buildroot (http://buildroot.uclibc.org/download.html ). I used the 2012.05 version. Enter the buildroot directory and type the following in a terminal:

make menuconfig

This will open a Menu Configuration program similar to what is used to configure the Linux Kernel.

Make sure your Buildroot config has the 'dhcpclient' package installed. You need to check the 'Show Packages That BusyBox Includes' option under 'Packages for Target', and then choose 'isc dhclient' under 'Networking Applications'. This is shown in the following couple screenshots.

Also enable the 'wireless tools' package under 'Hardware handling'.

From the main menuconfig for Buildroot go to the 'Kernel' configuration page and configure it to use a 'Custom Version' and choose 3.2.23. I was unable to get the USB / Ralink drivers to work under 2.6.X and 3.4.4. 3.2.23 just works.


Now that you've configured Buildroot for the Beagleboard using my last post ( http://ptrackapp.com/apclassys-notes/beagleboard-rev-c5-simple/) and these new options, do the initial build by running from the top level Buildroot directory:

make

When Buildroot is done building your system, run the following command from the top level Buildroot directory:

make linux-menuconfig

What this does is open the Linux 3.2.23 menu configuration utility. Navigate to the 'USB Support' sub menu and ensure that you enable 'EHCI Support for OMAP3 and later chips' and 'EHCI HCD (USB 2.0) Support'. This is important so that your Kernel supports USB to recognize the USB wifi dongle.

Specifically, check your .config file in output/build/linux-3.2.23/ and ensure that it has the following options enabled:

CONFIG_USB_EHCI_HCD=y

CONFIG_USB_EHCI_HCD_OMAP=y

Back in the linux menuconfig enable the Ralink driver support under the 'Networking Drivers' submenu on the main 'Drivers' menu. Refer to the following screenshot. For me, it was the rt2800usb driver that I needed.

Now copy buildroot/output/images/* to /media/boot and buildroot/output/target/* to /media/rfs.

Power on your BeagleBoard and login in using Serial via Minicom or some other terminal application.

Manually load the driver ( located in /lib/modules/3.2.23/kernel/drivers/net/wireless/rt2x00/ ) using modprobe. You should see a new interface driver registered.

# modprobe rt2800lib

# modprobe rt2800usb

[ 3908.792114] usb 1-2.3: reset high-speed USB device number 3 using ehci-omap

[ 3908.965362] phy0 -> rt2x00_set_chip: Info - Chipset detected - rt: 3070, rf: 0005, rev: 0201.

[ 3909.025634] usbcore: registered new interface driver rt2800usb

Check to see if iwconfig can see your USB wifi device using iwconfig ( part of 'wireless-tools' package ).

# iwconfig

lo no wireless extensions.


wlan0 IEEE 802.11bgn ESSID:off/any

Mode:Managed Access Point: Not-Associated Tx-Power=0 dBm

Retry long limit:7 RTS thr:off Fragment thr:off

Encryption key:off

Power Management:on

Run 'dmesg' command to once again verify your device is registered.

# dmesg

[ 3908.707641] rt2800usb 1-2.3:1.0: usb_probe_interface

[ 3908.707672] rt2800usb 1-2.3:1.0: usb_probe_interface - got id

[ 3908.792114] usb 1-2.3: reset high-speed USB device number 3 using ehci-omap

[ 3908.965362] phy0 -> rt2x00_set_chip: Info - Chipset detected - rt: 3070, rf: 0005, rev: 0201.

[ 3909.020721] ieee80211 phy0: Selected rate control algorithm 'pid'

[ 3909.025634] usbcore: registered new interface driver rt2800usb

Bring up the 'wlan0' interface.

# ifconfig wlan0 up

[ 4111.599945] phy0 -> rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'.

[ 4111.644653] phy0 -> rt2x00lib_request_firmware: Info - Firmware detected - version: 0.29.

[ 4112.299468] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 3, CWmax: 4, Aifs: 2.

[ 4112.313171] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 4, CWmax: 5, Aifs: 2.

[ 4112.327056] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 5, CWmax: 10, Aifs: .

[ 4112.340423] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 5, CWmax: 10, Aifs: .

It should also show up with the 'ifconfig' command.

# ifconfig

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

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 7C:DD:90:0C:E0:9A

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)

Edit your target board's /etc/wpa_supplicant.conf file to look like below. Insert your password for your router here as well as your Router Name ( SSID ).

# cat /etc/wpa_supplicant.conf

# config file using WPA/WPA2-PSK Personal key.

ctrl_interface=/var/run/wpa_supplicant

network={

ssid=”NETGEAR”

scan_ssid=1

key_mgmt=WPA-PSK

psk=”<your - password>″

}

This is how you manually would run the wpa_supplicant program ( from the 'wpa_supplicant' package ... obviously ).

# wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

Trying to associate with c4:3d:c7:66:9b:34 (SSID='NETGEAR' freq=2437 MHz)

[ 4461.380462] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 4, CWmax: 10, Aifs: .

[ 4461.396362] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 4, CWmax: 10, Aifs: .

[ 4461.409973] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 3, CWmax: 4, Aifs: 2.

[ 4461.423858] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 2, CWmax: 3, Aifs: 2.

Associated with c4:3d:c7:66:9b:34

WPA: Key negotiation completed with c4:3d:c7:66:9b:34 [PTK=TKIP GTK=TKIP]

CTRL-EVENT-CONNECTED - Connection to c4:3d:c7:66:9b:34 completed (auth) [id=0 id_str=]

Now create a shell script that looks like the following named 'start-wireless.sh':

I learned alot of these commands from:

1.) http://capuzzo.free.fr/beagleboard/wifi.html

2.) http://deautomatized.wordpress.com/2012/04/08/ubuntu-11-10-on-beagleboard-rev-c5/

Thanks guys!

#!/bin/sh

## Define the interface

iface=wlan0

## Bring down the interface if it's up

rm /var/run/wpa_supplicant/wlan0

ifconfig $iface down

## Set adhoc management of wireless device

iwconfig $iface mode Managed

## Load the Ralink driver

modprobe rt2800usb.ko

## Bring up the wireless interface

ifconfig $iface up

## Apply WPA/WPA2 personal settings to device

wpa_supplicant -B -Dwext -i$iface -c/etc/wpa_supplicant.conf -dd

## Obtain an IP address

/sbin/udhcpc -i wlan0 --hostname=beaglehost

Now run that script by doing ./start-wireless.sh. At the end you should see a message saying 'bound to 192.168.1.XX. At that point you should be able to ping google like 'ping -c 5 www.google.com' and see a response. Congrats you're on the internet!

It would be nice to connect automatically on boot. Here is how I accomplished this ( thanks to http://www.nunoalves.com/open_source/?p=308 ).

Move your script to /usr/bin with:

mv start-wireless.sh /usr/vin

Edit your /etc/inittab file on the board to enable this script to start automatically on boot. Add the following lines to the center of the file and save. Now when you press the reset button on the BeagleBoard your 'start-wireless.sh' script will automatically be executed and by the time you get a login prompt your BeagleBoard will be connected wirelessly to the internet!

# Start Wifi Service

::wait:/usr/bin/wireless-wpa.sh

Feel free to leave feedback - happy coding!



ClassyBits 2016