A blog by Devendra Tewari
Raspberry Pi does not have Wi-Fi on board. You’ll need to use a Wi-Fi dongle and discover the driver to build into the kernel. One way to find the driver is to plug the dongle into a Raspberry Pi running Raspbian, and run lsmod
to see which module gets loaded. The following text assumes you’re building a custom embedded Linux system using Buildroot.
Invoke the Kernel configuration utility using make linux-menuconfig
.
Enable Wireless Networking support under Networking support
Enable cfg80211 - wireless configuration API, and Generic IEEE 802.11 Networking Stack (mac80211), under Networking Support, Wireless
Enable EEPROM 93CX6 support under Device Drivers, Misc devices, EEPROM support. Required for RTL8187 module in my Wi-Fi dongle, may not be needed for your particular adapter
Enable Wireless LAN driver support under Device Drivers, Network device support
Enable Realtek 8187 and 8187B USB support under Device Drivers, Network device support, Wireless LAN. Select the driver appropriate for your adapter
Invoke make menuconfig
within the buildroot folder from a command prompt.
Select package iw required to configure wireless networking, under Target packages, Networking applications. Enable iproute2 if you want to use the ip utility instead of ifconfig.
Select package wpa_supplicant and its sub-packages for WPA/WPA2 support
Perform the build by invoking make, copy the newly minted system to an SD card, and use it to boot up your Raspberry Pi.
List your wireless interfaces
iw list
If you’ve selected the iproute2 package above, the following should list all network interfaces
ip link
Bring up the wlan0 interface
ip link set wlan0 up
Or
ifconfig wlan0 up
Find the access point you want to connect to
iw dev wlan0 scan
Assuming you’re using WPA/WPA2, invoke wpa_passphrase to create config file, and wpa_supplicant to connect to network
wpa_passphrase your_SSID your_passphrase > your_SSID.conf
wpa_supplicant -B -i wlan0 -c your_SSID.conf
Instead, if you want to connect to an open network
iw dev wlan0 connect your_SSID
Request IP address using DHCP
dhcpcd wlan0
Check link status
iw dev wlan0 link
Add nameserver entries to /etc/resolv.conf e.g.
nameserver 8.8.8.8
nameserver 8.8.4.4
Test internet connectivity using ping
ping www.google.com