Wifi on Linux 2.6.32: Difference between revisions
Line 221: | Line 221: | ||
ifconfig wlan0 up | ifconfig wlan0 up | ||
Scan for access points (limiting output): | Scan for access points (limiting output): |
Revision as of 15:09, 2 February 2014
Background
Basically wireless doesn't work for many WiFi adaptors in the Linux 2.6.32 or similar kernels. To solve this problem, the Linux kernel wireless group created compat-wireless, which is a backport of kernel modules and drivers for the newest Linux kernel. After a while other non-wifi driver needed to be backported, so the effort was renamed compat-drivers. Finally they settled on the name backports.
This HowTo shows which packages are used with Linux 2.6.32 to support recently introduced WiFi modules, along with the configuration needed.
backports package
I used backports version 3.12.2-1 using allmodconfig for the DEFCONFIG. Before building the package, make sure your kernel configuration (linux*/.config) has the following entries:
CONFIG_NET_SCHED=y CONFIG_CFG80211=m CONFIG_MII=m
If you are using the RidgeRun SDK, the following command will dump the three lines above:
egrep 'CONFIG_NET_SCHED=|CONFIG_CFG80211=|CONFIG_MII=' $DEVDIR/bsp/mach/bspconfig
Configuring backports in RidgeRun SDK
In Kernel configuration -> Networking support -> Networking options ->
- QoS and/or fair queueing (build into kernel)
Kernel configuration -> Networking support -> Wireless ->
- cfg80211 (build as module)
Kernel configuration -> Device Drivers -> Network device support -> Ethernet (10 or 100Mbit)
- Generic Media Independent Interface device support
For defconfig-cw1200, I also needed USB Ethernet enabled (CONFIG_USB_USBNET=m)
Kernel configuration -> Device Drivers -> Network device support -> USB Network Adapters
- Multi-purpose USB Networking Framework
Configuring backports
The backport supported configurations, as reported by the backports make help target, includes:
Configuration targets: menuconfig - Update current config utilising a menu based program allyesconfig - New config where all options are accepted with yes oldconfig - Update current config utilising a provided .config as base silentoldconfig - Same as oldconfig, but quietly, additionally update deps allnoconfig - New config where all options are answered with no allmodconfig - New config selecting modules when possible alldefconfig - New config with all symbols set to default randconfig - New config with random answer to all options listnewconfig - List new options olddefconfig - Same as silentoldconfig but sets new symbols to their default value
The defconfig-help backports make defconfig-help target lists the supported configurations. Example output is:
Driver or subsystem configuration targets: defconfig-alx defconfig-ar5523 defconfig-ath10k defconfig-ath5k defconfig-ath6kl defconfig-ath9k defconfig-b43 defconfig-b43legacy defconfig-brcmfmac defconfig-brcmsmac defconfig-carl9170 defconfig-cw1200 defconfig-ieee802154 defconfig-iwlwifi defconfig-media defconfig-nfc defconfig-regulator defconfig-rtlwifi defconfig-wifi defconfig-wil6210 defconfig-wwan
For the Sagrad SG901-1091 WiFi SDIO module, I used defconfig-cw1200.
backports usage
The details of how to use hardware that relies on backport is dependent on the hardware being supported. Various hardware devices are shown below.
Sagrad SG901-1091 WiFi SDIO module
Using defconfig-cw1200 created the kernel modules needed to support the Sagrad SG901-1091 WiFi SDIO module. I also installed linux-firmware as the cw1200 driver set needs the firmware file wsm_22.bin.
Plugging in the SDIO card causes the kernel to report:
mmc0: new SDIO card at address 0001
To verify information regarding the SDIO card:
cd /sys/devices/platform/davinci_mmc.0/mmc_host/mmc0/mmc0:0001/mmc0:0001:1 echo class: `cat class`, vendor: `cat vendor`, device: `cat device`
With the response:
class: 0x00, vendor: 0x0020, device: 0x2280
The debugfs file system contains entries that contain the current settings for the MMC/SD/SDIO interface of interest.
mount -t debugfs none /sys/kernel/debug cat /sys/kernel/debug/mmc0/ios
With the expected output:
clock: 25000000 Hz vdd: 20 (3.2 ~ 3.3 V) bus mode: 2 (push-pull) chip select: 0 (don't care) power mode: 2 (on) bus width: 2 (4 bits) timing spec: 0 (legacy)
Load the appropriate set of drivers:
COMPAT_KDIR=/lib/modules/2.6.32-17-ridgerun/updates insmod $COMPAT_KDIR/compat/compat.ko insmod $COMPAT_KDIR/net/wireless/cfg80211.ko insmod $COMPAT_KDIR/net/mac80211/mac80211.ko insmod $COMPAT_KDIR/drivers/net/wireless/cw1200/cw1200_core.ko insmod $COMPAT_KDIR/drivers/net/wireless/cw1200/cw1200_wlan_sdio.ko
The filtered output is shown below:
Loading modules backported from Linux version v3.12.2-0-g050dcf4 Backport generated by backports.git v3.12.2-1-0-gb4b7ee5 cfg80211: Calling CRDA to update world regulatory domain cw1200_wlan_sdio: Probe called CW1x00 Cut 2.2 silicon detected. cw1200_wlan_sdio mmc0:0001:1: firmware: requesting wsm_22.bin Firmware download completed. CW1200 WSM init done. Input buffers: 8 x 1632 bytes Hardware: 261.5 WSM firmware [WSM_A30.02.0395_PTA4W Jun 18 2012 10:13:51], ver: 3002, build: 395, api: 1044, cap: 0x000B Registered as 'phy0'
At this point you can follow the general Linux WiFi configuration steps.
USB TL-WN722N WiFi dongle using chipset Atheros AR9271
After booting the target, plug in the USB dongle. Example output:
usb 1-1: new high speed USB device using musb_hdrc and address 3 usb 1-1: configuration #1 chosen from 1 choice
You can check the interface class is 09 using
cat /sys/devices/platform/musb_hdrc/usb1/1-0:1.0/bInterfaceClass
Load the appropriate set of drivers:
COMPAT_KDIR=/lib/modules/2.6.32-17-ridgerun/updates find $COMPAT_KDIR -name \*.ko modprobe compat modprobe compat_firmware_class modprobe cfg80211 modprobe mac80211 modprobe ath modprobe ath9k_hw modprobe ath9k_common modprobe ath9k_htc
The filtered output is shown below:
Loading modules backported from Linux version v3.12.2-0-g050dcf4 Backport generated by backports.git v3.12.2-1-0-gb4b7ee5 cfg80211: Calling CRDA to update world regulatory domain
At this point you can follow the general Linux WiFi configuration steps.
Starting up the wireless network
Once you have your wifi dongle's driver installed successfully the next step is configure linux wireless and network settings.
Reference: Table of iw commands
Start by verifying there is no connection
iw dev wlan0 link
Expected output:
Not connected.
Power on the adaptor:
ifconfig wlan0 up
Scan for access points (limiting output):
iw dev wlan0 scan | fgrep SSID
Example output:
SSID: MOTOROLA-C0D8B SSID: linksys
Connect to access point
Connect to an open access point
If your access point doesn't require a password, connections are easy!
AP=linksys iw dev wlan0 connect "$AP"
Example output:
wlan0: authenticate with 00:13:10:ea:bd:66 wlan0: send auth to 00:13:10:ea:bd:66 (try 1/3) wlan0: authenticated cw1200_wlan_sdio mmc0:0001:1: wlan0: disabling HT as WMM/QoS is not supported by the AP cw1200_wlan_sdio mmc0:0001:1: wlan0: disabling VHT as WMM/QoS is not supported by the AP wlan0: associate with 00:13:10:ea:bd:66 (try 1/3) wlan0: RX AssocResp from 00:13:10:ea:bd:66 (capab=0x401 status=0 aid=8) wlan0: associated
Connect to an WEP encrypted access point
If you like weak security and have enabled WEP encryption, you can connect using:
AP=linksys PASS=DEADBEEF iw dev wlan0 connect "$AP" key 0:$PASS
Example output not shown as I have no AP's that use WEP.
Connect to WPA encrypted access point
You need to use The WPA supplicant. For netlink support, I used WPA supplicant 2.0 with libnl3.
cat <<EOF >/etc/wpa_supplicant/wpa_supplicant.conf # Example wpa_supplicant network={ ssid="Baily" psk="very secret passphrase" priority=5 } EOF wpa_supplicant -d -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -Dnl80211 &
Assign IP address
You can use a DHCP client daemon or assign a fixed IP address. To assign a fixed IP address, use:
IP=10.0.0.221 ifconfig wlan0 $IP netmask 255.255.255.0
Testing
Measuring performance
On fast host PC:
ifconfig iperf --server
On target device:
HOST_IP=10.0.0.4 iperf --client $HOST_IP
WiFi adaptor comparisions
On a DM368, I measured the following results
WiFi adaptor | Test duration (-t100) |
Bandwidth Mbits/sec (from iperf2) |
CPU IRQ load (from top) |
CPU SIRQ load (from top) |
---|---|---|---|---|
TL-WN722N (Atheros AR9271) |
100 sec | 17.1 | 44% | 40% |