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.
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 all the available interfaces and check if the kernel support was properly enabled:
ip addr
Note: Before proceeding with the next steps, make sure the kernel support is enabled for your Wi-Fi module as the instructions above.
Select your Linux BSP image below to see how to proceed to connect to a Wi-Fi Network.
TorizonCore supports two Wi-Fi modes: client mode and access point (AP) mode.
This mode is used when you want TorizonCore to connect to a Wi-Fi access point.
To see a list of available Wi-Fi access points:
# nmcli device wifi list
To connect to a Wi-Fi access point:
# nmcli -a device wifi connect <WIFI_NAME>
This mode is used when you want TorizonCore to act as a Wi-Fi access point.
Run the following commands to configure TorizonCore as a Wi-Fi access point, substituting <WIFI_AP_NAME>
, <WIFI_SSID>
, <WIFI_PASSWORD>
and <IPV4_ADDR>
accordingly:
# nmcli con add type wifi ifname uap0 mode ap con-name <WIFI_AP_NAME> ssid <WIFI_SSID>
# nmcli con modify <WIFI_AP_NAME> 802-11-wireless-security.key-mgmt wpa-psk
# nmcli con modify <WIFI_AP_NAME> 802-11-wireless-security.proto rsn
# nmcli con modify <WIFI_AP_NAME> 802-11-wireless-security.group ccmp
# nmcli con modify <WIFI_AP_NAME> 802-11-wireless-security.pairwise ccmp
# nmcli con modify <WIFI_AP_NAME> 802-11-wireless-security.psk <WIFI_PASSWORD>
# nmcli con modify <WIFI_AP_NAME> ipv4.addresses <IPV4_ADDR>
# nmcli con modify <WIFI_AP_NAME> ipv4.method manual
# nmcli con up <WIFI_AP_NAME>
Besides a Wi-Fi access point, you also need to activate a DHCP server in TorizonCore. To do that, you can leverage systemd's built-in DHCP server support, creating the file /etc/systemd/network/80-wifi-ap.network
with the following content (substitute <IPV4_ADDR>
, <IPV4_ADDR_NETMASK>
, <DHCPD_POOL_OFFSET>
and <DHCPD_POOL_SIZE>
accordingly):
/etc/systemd/network/80-wifi-ap.network[Match] Name=uap0 Type=wlan WLANInterfaceType=ap [Network] Address=<IPV4_ADDR>/<IPV4_ADDR_NETMASK> DHCPServer=yes [DHCPServer] PoolOffset=<DHCPD_POOL_OFFSET> PoolSize=<DHCPD_POOL_SIZE>
Now just restart the systemd-networkd
service:
$ sudo systemctl restart systemd-networkd
For more information, see the Networking with TorizonCore page.
On the Reference Images for Yocto Project, the connman package provides connectivity management.
The connections can be configured by starting the configuration program connman-properties or by starting the taskbar applet connman-applet.
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
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 readyEnabled wifi
And scan for available networks:
root@colibri-t30:~# connmanctl scan wifiScan 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 = wifiName = <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 readyConnected
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 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 networkSSID=544f52414445585f4252 ← Name of your network in hexadecimal formatFavorite=trueIPv4.method=manual ← Method to be used (in our case manual IP)IPv4.netmask_prefixlen=24IPv4.local_address=192.168.0.133 ← Desired IP addressIPv4.gateway=192.168.0.1Passphrase=<PASS> ← Wi-Fi network passwordAutoConnect=true
In this next step, we have three options, one can use what is best suited to the application:
echo '1-1' > /sys/bus/usb/drivers/usb/unbindecho '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
On images V1.x the following brings up the connection from the command line:
ifconfig wlan0 upiwlist wlan0 scanningwpa_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 running with debugging (-dd) enabled:
wlan0: skip - no WPA/RSN proto match
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.