Skip to main content
Version: BSP 6.x.y

Toradex’s Linux Images - How to connect to a Wi-Fi network

Introduction

This article shows how to set up Linux to connect to a Wi-Fi network in Client mode.

If this is not the information you are looking for, please, refer to the Wi-Fi Connectivity with Toradex’s Computer on Module (CoM) article for more Wi-Fi related information.

Antenna Configuration

In order to use Wi-Fi properly, set the antenna as described in the article Operating Toradex Wi-Fi/BT Capable Modules Using Dual and Single Antenna Configuration.

Enable the Kernel Support for the Wireless Adapter

Click here to see a complete list of Toradex Computer on Modules (COMs) with integrated Wi-Fi/Bluetooth

Toradex SoMs featuring the U-BLOX MAYA-W160-00B Wi-Fi / Bluetooth module:

System on ModuleProduct NumberVersion
Verdin AM62 Quad 2GB Wi-Fi / Bluetooth0076V1.1A and newer
Verdin AM62 Dual 1GB Wi-Fi / Bluetooth0075V1.1A and newer
Verdin AM62 Solo 512MB Wi-Fi / Bluetooth0072V1.1A and newer

Toradex SoMs featuring the Azurewave AW-CM276NF Wi-Fi / Bluetooth module:

System on ModuleProduct NumberVersion
Apalis iMX8 QuadMax 4GB Wi-Fi / Bluetooth IT0037V1.0A and newer
Apalis iMX8 QuadPlus 2GB Wi-Fi / Bluetooth0048V1.0A and newer
Colibri iMX8X QuadXPlus 2GB Wi-Fi / Bluetooth IT0038V1.0A and newer
Colibri iMX8X DualX 1GB Wi-Fi / Bluetooth0051V1.0A and newer
Colibri iMX6ULL 512MB Wi-Fi / Bluetooth IT0040V1.1A and newer
Colibri iMX6ULL 512MB Wi-Fi / Bluetooth0045V1.1A and newer
Verdin iMX8M Mini Quad 2GB Wi-Fi / Bluetooth IT0055V1.0B and newer
Verdin iMX8M Mini DualLite 1GB Wi-Fi / Bluetooth IT0060V1.1A and newer
Verdin iMX8M Plus Quad 2GB Wi-Fi / Bluetooth IT0064V1.1A and newer
Verdin iMX8M Plus Quad 4GB Wi-Fi / Bluetooth IT0058V1.0B and newer
Verdin iMX8M Plus Quad 8GB Wi-Fi / Bluetooth IT0070V1.1A and newer

Toradex SoMs featuring the Wi2Wi WM828CC6 Wi-Fi / Bluetooth module:

info

Wi2Wi WM828CC6 has been replaced by Azurewave AW-CM276NF on newer Toradex SoMs.

System on ModuleVersion
Colibri iMX6ULL 512MB Wi-Fi / BluetoothV1.0x

Wi-Fi adapter characteristics summary:

Wi-fi AdapterWi-Fi StandardsBluetooth versionAdapter's ChipsetAntenna Configuration
AzureWave AW-CM276NF802.11 a/b/g/n/ac5.3NXP 88W89972.4/5 GHz Dual-band 2x2 Wi-Fi 5 (802.11ac)
Wi2Wi WM828CC6802.11 a/b/g/n/ac4.2NXP 88W88872.4/5 GHz Dual-band 1x1 Wi-Fi 5 (802.11ac)
u-blox MAYA-W160-00B802.11 a/b/g/n5.2NXP IW4162.4/5 GHz Dual Band 1x1 Wi-Fi 4 (802.11n)

Toradex's Embedded Linux BSPs only provide out-of-the-box software support for the LM816 USB WiFi, and Azurewave AW-CM276NF Wi-Fi & Bluetooth module (integrated on some of our CoMs). If you are using a Toradex CoM with embedded Wi-Fi, (see list above), the kernel support for the dual-antenna Wi-Fi client mode without concurrent Bluetooth use case is enabled by default on Toradex's Embedded Linux BSPs and you can proceed to the next step. For other use cases, read the article Azurewave AW-CM276NF Wi-Fi & Bluetooth module.

For modules that don't come with on-module Wi-Fi hardware, a mini-PCIe, SDIO or USB Wi-Fi module can be used. Please refer to Setting up 3rd Party Wi-Fi Adapters Linux Kernel Support for Toradex’s Linux Images before proceeding.

List the Available Interfaces

List all the available interfaces and check if the kernel support was properly enabled:

ip addr
Click here for an example of the expected output for a Colibri iMX6ULL with embedded Wi-Fi:
# 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

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

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

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

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

In this example, these are the available interfaces:

lo: Loopback interface
eth0: wired Ethernet
can0: MCP2515 SPI CAN controller available on the Colibri Evaluation board
usb0: USB RNDIS
mlan0: Regular station Wi-Fi interface (e.g. to connect to Wi-Fi networks)
uap0: Access point Wi-Fi interface (e.g. to be used with hostapd)

If the access point interface is not required, it is possible to delete the following module configuration:

# cat /etc/modprobe.d/mwifiex.conf
options mwifiex driver_mode=0x3

Wi-Fi Connection Bring Up

info

Before proceeding with the next steps, make sure the kernel support is enabled for your Wi-Fi module as the instructions above.

On the Reference Images for Yocto Project, the connman package provides connectivity management.

Automatic (GUI)

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

Interactively

info

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 <HASH> 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


Send Feedback!