Setting Up a USB WiFi Dongle on Raspberry Pi Arch

September 1, 2012

For my AirPi, I needed to make my Raspberry Pi wireless. Being the man of thrift that I am, I found the cheapest dongle on eBay: a (Digitaz) RaLink RT5370.

Now Arch isn’t exactly plug and play, but that’s part of the fun. Plugging it in, the only way you’ll know it is there is using:

lsusb
...
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter 
...

Linux includes module for RaLink adaptors: ‘rt2x00usb’ and it turns out that they work with this adaptor too. Getting it running is a simple case of installing ‘wireless_tools’, then rebooting and letting udev do its thing and load the module up. Using lsmod it appears that ‘rt2x00usb’, ‘rt2x00lib’, ‘rt2800lib’ and ‘rt2800usb’ are all loaded, so you can use modprobe and load this modules manually.

wpa-supplicant

You’ve got the adaptor connected, the process of actually using it to join a network require a few more steps. Start by the details of the network that you want to join to /etc/wpa_supplicant.conf, this is best achieved using wpa_passphrase, which converts the password to hex for you.

pacman -S wpa_supplicant
wpa_passphrase mywireless_ssid "secretpassphrase" >> /etc/wpa_supplicant.conf

Now bring the wireless device up (change wlan0 to your device).

ip link set wlan0 up

Then get wpa_supplicant to associate the adaptor with the first available network inf wpa_supplicant.conf.

wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf 

The last thing to do is get an ip address using dhcp.

dhcpcd wlan0

Connecting at Boot

All of the above will require repeating on each reboot. To do this automatically, add the above to a script and add it to /etc/rc.local. Here is mine, which I placed in /usr/local/sbin/wireless_up.sh

#!/bin/bash
wpa_supplicant -B Dxext -i wlan0 -c /etc/wpa_supplicant.conf
dhcpcd wlan0

UPDATE 02/01/2013
The cross-through was pre-systemd being used as the service manager. Follow the instructions on the Arch wiki to set-up boot on current builds: https://wiki.archlinux.org/index.php/Wireless#Manual_wireless_connection_at_boot_using_systemd

Basically:

sudo systemctl enable wpa_supplicant@wlan0.service
sudo ln -s /etc/wpa_supplicant.conf /etc/wpa_supplicantwpa_supplicant-wlan0.conf # service looks here
$ cat /etc/systemd/network/wlan0.network
[Match]
Name=wlan0
[Network]
DHCP=yes