Search by Tags

Wi-Fi (Linux)

 

Compare with Revision




Subscribe for this article updates

For modules that don't come with on-module Wi-Fi hardware, support can easily be added using either a mini-PCIe, SDIO or USB Wi-Fi module. Our Embedded Linux BSPs only support the LM006 and LM816 Wi-Fi dongles (available through the web shop) and the Wi2Wi WM828CC6 and AzureWave AW-CM276NF out-of-the-box. See the list of Toradex modules that come with on-module Wi-Fi in the table below:

Module Version Product Description Wi-Fi Adapter Antenna Configuration
Colibri iMX6ULL V1.0A 512MB Wi-Fi / Bluetooth Wi2Wi WM828CC6 Dual-Band 802.11ac 1x1 spatial stream
Colibri iMX6ULL V1.1A 512MB Wi-Fi / Bluetooth AzureWave AW-CM276NF Dual-Band 802.11ac 2x2 MU-MIMO
Apalis iMX8 V1.0B QuadMax 4GB Wi-Fi / Bluetooth AzureWave AW-CM276NF Dual-Band 802.11ac 2x2 MU-MIMO
Colibri iMX8X V1.0A QuadXPlus 2GB Wi-Fi / Bluetooth AzureWave AW-CM276NF Dual-Band 802.11ac 2x2 MU-MIMO

Alternatively, many off-the-shelf Wi-Fi modules will work just fine once the matching driver is compiled into a custom Linux kernel. Please note however that most Wi-Fi modules require matching firmware as well. The easiest is to first test respective module on a regular PC running Linux (e.g. using a mini-PCIe to PCIe adapter if required). Make sure to use a Linux kernel version as close to the version running on the Toradex module as possible. Not only do you see whether it works reliably, but one can also simply copy matching firmware from there if required.

Note: Since the Embedded Linux BSP 2.7b4, the driver backports are added to the Toradex pre-built image. Please see the article below for further information:

Kernel Driver Backports Integration

Also see the Linux BSP Release, where you can filter for information about the Wi-Fi Subsystem, and the official Linux Wireless wiki, where you can get information such as the supported chips and their drivers status, as well as how to install firmware, among other information.

Custom Kernel

To enable support for other Wi-Fi hardware a custom Linux kernel is required. Please refer to the following article concerning its setup/compilation:

Build U-Boot and Linux Kernel from Source Code

And once completed continue with the driver backports article:

Kernel Driver Backports Integration

Colibri iMX6ULL Station vs. Access Point Wi-Fi Interfaces

root@colibri-imx6ull:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,DYNAMIC,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:14:2d:2e:e4:94 brd ff:ff:ff:ff:ff:ff

=> wired Ethernet

3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
    link/can 

=> MCP2515 SPI CAN controller available on the Colibri Evaluation board

4: usb0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:14:2d:ff:ff:ff brd ff:ff:ff:ff:ff:ff

=> USB RNDIS

5: mlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:19:88:5e:10:de brd ff:ff:ff:ff:ff:ff

=> Regular station Wi-Fi interface (e.g. to connect to Wi-Fi networks)

6: uap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:19:88:5e:11:de brd ff:ff:ff:ff:ff:ff

=> Access point Wi-Fi interface (e.g. to be used with hostapd)

If the access point interface is not required one may just delete the following module configuration:

root@colibri-imx6ull:~# cat /etc/modprobe.d/mwifiex.conf
options mwifiex driver_mode=0x3

Mini-PCIe

Our embedded Linux BSPs so far do not support any mini-PCIe Wi-Fi modules out-of-the-box. However we successfully tested various mini-PCIe Wi-Fi modules based on Broadcom (e.g. BCM4311KFBG) and Intel (e.g. 4965AGN, 6230AGN, ,N-1000 and N-7260) chip sets.

To configure e.g. support for the Intel 6230AGN mini-PCIe module one has to enable CONFIG_IWLAGN as follows:

[user@host linux-toradex]$ make menuconfig
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
<*> Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlagn)
< Exit > (4 times)
Do you wish to save your new configuration? < Yes >

Then just compile and deploy the custom kernel as explained in the above mentioned article.

During boot one gets the following kernel messages:

[ 7.290881] Intel(R) Wireless WiFi Link AGN driver for Linux, in-tree:
...
[ 7.344598] iwlagn 0000:04:00.0: HW Revision ID = 0x34
[ 7.357966] iwlagn 0000:04:00.0: Detected Intel(R) Centrino(R) Advanced-N 6230 AGN, REV=0xB0
[ 7.369558] iwlagn 0000:04:00.0: L1 Disabled; Enabling L0S
[ 7.396050] iwlagn 0000:04:00.0: device EEPROM VER=0x716, CALIB=0x6
[ 7.405308] iwlagn 0000:04:00.0: Device SKU: 0X1f0

USB

The following USB Wi-Fi sticks with the Realtek RTL8188CUS/RTL8188EUS chip set are supported out-of-the-box. However we successfully tested various USB Wi-Fi modules based on Ralink(e.g RT5370, RT5572), Realtek(e.g RTL8188CUS, RTL8192EU chipset), Zydas(e.g ZD1211B).

  • LM006 USB Wi-Fi
  • LM816 USB Wi-Fi

During boot or upon insertion the following kernel messages identify the LM006 stick:

[ 55.779953] usb 3-1: new high speed USB device number 3 using tegra-ehci
[ 55.971825] usb 3-1: New USB device found, idVendor=0bda, idProduct=8176
[ 55.978538] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 55.985743] usb 3-1: Product: 802.11n WLAN Adapter
[ 55.990587] usb 3-1: Manufacturer: Realtek
[ 55.994688] usb 3-1: SerialNumber: 00e04c000001
[ 56.151090] rtl8192cu: MAC address: 5c:f3:70:24:97:e5
[ 56.156167] rtl8192cu: Board Type 0
[ 56.171585] rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1

In user space it can be identified by lsusb as follows:

root@colibri_t20:~# lsusb
...
Bus 003 Device 003: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
...
Legacy information regarding the Ambicon WL250N USB WiFi firmware

SDIO

We successfully tested the WiBear 11n SDIO Wifi wireless adapter module based on Marvel 8787 chipset. In addition, Wi2Wi WM828CC6 is employed as the on-module Wi-Fi for some models of the Colibri iMX6ULL SoM, and thus supported out-of-the-box in our BSP.

To configure support for the Marvel 8787 SDIO wireless adapter module one has to enable CONFIG_MWIFIEX, CONFIG_MWIFIEX_SDIO as follows:

[user@host linux-toradex]$ make menuconfig
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
<*> Marvell WiFi-Ex Driver
<*> Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897
< Exit > (4 times)
Do you wish to save your new configuration? < Yes >

During boot one gets the following kernel messages:

[ 392.591781] mmc1: new high speed SDIO card at address 0001
[ 393.583165] mwifiex_sdio mmc1:0001:1: WLAN FW is active
[ 394.068554] mwifiex_sdio mmc1:0001:1: ignoring F/W country code US
[ 394.118806] mwifiex_sdio mmc1:0001:1: driver_version = mwifiex 1.0 (14.66.35.p52)
[ 429.748907] IPv6: ADDRCONF(NETDEV_UP): mlan0: link is not ready

Firmware

Most Wi-Fi hardware uses specific firmware to operate properly. Certain such firmware can easily be installed as follows:

opkg update
opkg --force-depends install linux-firmware

Wi-Fi Connection Bring Up

Wi-Fi Connection Bring Up BSP V1.x

On images V1.x the following brings up the connection from the command line:

ifconfig wlan0 up
iwlist wlan0 scanning
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
# -dd for debugging
# -B for background daemon

To do WEP, WPA or WPA2 just edit /etc/wpa_supplicant.conf and add the information about your wireless network infrastructure.

If you erroneously specify proto=WPA but do have a WPA2 infrastructure, wpa_supplicant returns the following error message if run with debugging (-dd) enabled:

wlan0: skip - no WPA/RSN proto match

Wi-Fi Connection Bring Up BSP V2.x

On images V2.x the connman package provides connectivity management.

http://connman.net

Automatic (GUI)

The connections can be configured by starting the configuration program connman-properties or by starting the taskbar applet connman-applet.

Interactively

Note: On the Colibri iMX6ULL make sure to connect to the mlan0 Wi-Fi interface which may be distinguished based on their MAC addresses.

root@colibri-imx6ull:~# connmanctl 
Error getting VPN connections: The name net.connman.vpn was not provided by any
connmanctl> enable wifi
[  426.104116] IPv6: ADDRCONF(NETDEV_UP): mlan0: link is not ready
[  426.145123] IPv6: ADDRCONF(NETDEV_UP): uap0: link is not ready
Enabled wifi
connmanctl> scan wifi
[  452.706815] ieee80211 phy0: mwifiex_cfg80211_sched_scan_start : Invalid Sched_scan parameters
Scan completed for wifi
connmanctl> agent on
Agent registered
connmanctl> services
    testnet             wifi_0019885e10de_666167776c616e32_managed_psk
    testnet             wifi_0019885e11de_666167776c616e32_managed_psk
connmanctl> connect wifi_0019885e10de_666167776c616e32_managed_psk
Agent RequestInput wifi_0019885e10de_666167776c616e32_managed_psk
  Passphrase = [ Type=psk, Requirement=mandatory ]
Passphrase? testpw
connmanctl> [  637.111283] mwifiex_sdio mmc1:0001:1: info: trying to associate to 'testnet' bssid 44:d9:e7:fa:cf:d5
[  637.137213] mwifiex_sdio mmc1:0001:1: info: associated to bssid 44:d9:e7:fa:cf:d5 successfully
[  637.194021] IPv6: ADDRCONF(NETDEV_CHANGE): mlan0: link becomes ready
[  676.632838] ieee80211 phy0: mwifiex_cfg80211_sched_scan_start : Invalid Sched_scan parameters
Connected wifi_0019885e10de_666167776c616e32_managed_psk
connmanctl> quit

Manual

Our latest V2.x images also include a command-line configuration tool called connmanctl:

https://gist.github.com/kylemanna/6930087

As follows how to connect to a WPA PSK enabled Wi-Fi using an LM006 USB stick, or the Colibri iMX6ULL 512MB WB on-module Wi2Wi WM828CC6 adapter.

First plug in the Wi-Fi USB stick (LM006 only):

[ 55.779953] usb 3-1: new high speed USB device number 3 using tegra-ehci
[ 55.971825] usb 3-1: New USB device found, idVendor=0bda, idProduct=8176
[ 55.978538] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 55.985743] usb 3-1: Product: 802.11n WLAN Adapter
[ 55.990587] usb 3-1: Manufacturer: Realtek
[ 55.994688] usb 3-1: SerialNumber: 00e04c000001
[ 56.151090] rtl8192cu: MAC address: 5c:f3:70:24:97:e5
[ 56.156167] rtl8192cu: Board Type 0
[ 56.171585] rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1

Then enable the Wi-Fi technology layer:

root@colibri-t30:~# connmanctl enable wifi
[ 531.793311] rtl8192cu: MAC auto ON okay!
[ 531.857315] rtl8192cu: Tx queue select: 0x05
[ 531.863386] rtl8192c_common: Loading firmware file rtlwifi/rtl8192cufw.bin
[ 532.376983] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Enabled wifi

And scan for available networks:

root@colibri-t30:~# connmanctl scan wifi
Scan completed for wifi

Now show what the above actually found:

root@colibri-t30:~# connmanctl services
*AR Wired { ethernet_00142d486cef_cable }
<SSID> { wifi_<HASH>_managed_psk }

Finally adjust the security aka WPA PSK configuration:

root@colibri_t30:~# vi /var/lib/connman/<SSID>-psk.config
[service_wifi_<HASH>_managed_psk]
Type = wifi
Name = <SSID>
Passphrase = <PASSPHRASE>

Last but not least attempt to connect:

root@colibri_t30:~# connmanctl connect wifi_<HASH>_managed_psk
[ 1165.219739] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Connected

If you still have wired Ethernet connected make sure to disconnect the cable in order for Wi-Fi to take over:

root@colibri-t30:~# [ 653.968178] eth0: ax88772b - Link status is: 0
[ 654.026020] ADDRCONF(NETDEV_UP): eth0: link is not ready

Configuring Wi-Fi with static IP address

Configuring Wi-Fi with a static IP address can be done using the connman-applet with a graphical user interface. If one does not have a GUI, the process must be done via the command line interface.

When a WPA PSK configuration file is created, connman automatically configures Wi-Fi to use DHCP and does not allow manual changes to the IP address as it would for an Ethernet connection using connmanctl.

If the following file was created before, it needs to be deleted, as it conflicts with a new file that will be created:

/var/lib/connman/<SSID>-psk.config

First create the following directory (where is the hash identifier assigned to the device by connman):

mkdir /var/lib/connman/wifi_<HASH>_managed_psk

Inside the directory, create a file named “settings”:

vi /var/lib/connman/wifi_<HASH>_managed_psk/settings

The file should contain the following:

[wifi_<HASH>_managed_psk]
Name=<SSID> ← Name of your network
SSID=544f52414445585f4252 ← Name of your network in hexadecimal format
Favorite=true
IPv4.method=manual ← Method to be used (in our case manual IP)
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.0.133 ← Desired IP address
IPv4.gateway=192.168.0.1
Passphrase=<PASS> ← Wi-Fi network password
AutoConnect=true

In this next step we have three options, one can use what is best suited to the application:

  • reboot the module;
  • disconnect and reconnect the Wi-Fi module (if it was already connected);
  • restart the USB bus port with the following commands:
echo '1-1' > /sys/bus/usb/drivers/usb/unbind
echo '1-1' > /sys/bus/usb/drivers/usb/bind

Now enable the Wi-Fi technology layer:

connmanctl enable wifi

Finally, simply connect to the network:

connmanctl connect wifi_<HASH>_managed_psk

With all the steps concluded, the module should be connected with the chosen static IP address and it is now possible to freely change the IP address using connmanctl.