Wifi NetworkManager: Difference between revisions
(30 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default | <!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default | ||
--> {{# | --> {{INIT_RELEASE_PARAM|RELEASE_SUMO_V1.0_DART-MX8M}}<!-- | ||
--> {{#lst: | --> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!-- | ||
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!-- | |||
--> {{PageHeader|Wireless}} | --> {{PageHeader|Wireless}} | ||
{{DocImage|category1=Yocto|category2=Debian}}[[Category:DART-MX8M]][[Category:DART-MX8M-MINI]][[Category:DART-MX8M-PLUS]] __toc__ | {{DocImage|category1=Yocto|category2=Debian}}[[Category:DART-MX8M]][[Category:DART-MX8M-MINI]][[Category:DART-MX8M-PLUS]] __toc__ | ||
= | = {{#var:HARDWARE_NAME}} Overview = | ||
The {{#var:HARDWARE_NAME}} supports the following WiFi modules: | |||
= | {| class="wikitable" | ||
|- | |||
! Module | |||
! Chipset | |||
! Features | |||
! Network Interface(s) | |||
|- | |||
| Sterling LWB | |||
| Cypress CYW4343W | |||
| 802.11 b/g/n | |||
| wlan0 | |||
|- | |||
| Sterling LWB5 | |||
| Cypress CYW43353 | |||
| 802.11 ac/a/b/g/n, | |||
| wlan0 | |||
|- | |||
{{#ifeq: {{#var:WIFI_IW612_SUPPORT}}|yes| | |||
{{!}}- | |||
{{!}} Murata LBEE5PL2DL | |||
{{!}} NXP IW611 | |||
{{!}} 802.11 a/ac/ax/b/g/n | |||
{{!}} wlan0, uap0, wfd0 | |||
{{!}}- | |||
{{!}} Murata LBES5PL2EL | |||
{{!}} NXP IW612 | |||
{{!}} 802.11 a/ac/ax/b/g/n, 802.15.4 | |||
{{!}} wlan0, uap0, wfd0 | |||
}} | |||
|} | |||
This guide demonstrates how to configure WiFi using NetworkManager. It is important to use the correct network interface for the module assembled on your {{#var:HARDWARE_NAME}}. | |||
= Managing WiFi using NetworkManager = | |||
{{NM_INTRO}} | |||
== Enabling and disabling WiFi == | |||
{{NM_ENABLE|dev=wlan0}} | |||
== Configuring WiFi Client == | == Configuring WiFi Client == | ||
{{NM_CLIENT|dev=wlan0}} | |||
== Configuring WiFi Access Point with NetworkManager == | |||
== Configuring WiFi Access Point == | |||
NetworkManager can also be used to turn WiFi interface into Access Point.<br> | NetworkManager can also be used to turn WiFi interface into Access Point.<br> | ||
Line 111: | Line 84: | ||
Use the following commands to create the initial AP setup | Use the following commands to create the initial AP setup | ||
{{NM_CREATE_AP_CMDS}} | |||
{{NM_CREATE_AP_CMDS_EXAMPLE|dev=wlan0|module=Sterling LWB/LWB5}} | |||
{{#ifeq: {{#var:WIFI_IW612_SUPPORT}}|yes| | |||
# | {{NM_CREATE_AP_CMDS_EXAMPLE|dev=uap0|module=Murata LBES5PL2XX}} | ||
# | }} | ||
If you are planning to use the 5 GHz band and channel 36, you can partially change the above commands as follow | If you are planning to use the 5 GHz band and channel 36, you can partially change the above commands as follow | ||
Line 168: | Line 120: | ||
For changes in configuration file to take effect, restart NetworkManager by running | For changes in configuration file to take effect, restart NetworkManager by running | ||
# systemctl NetworkManager | # systemctl restart NetworkManager | ||
=== Managing existing connections === | === Managing existing connections === | ||
Line 190: | Line 142: | ||
# nmcli con delete <name> | # nmcli con delete <name> | ||
{{HOSTAPD_ACCESS_POINT}} | |||
== Sterling LWB/LWB5 WiFi STA/AP concurrency == | |||
To get the WiFi module to work in concurrent AP-STA mode on the Sterling LWB/LWB5, a virtual wireless interface is required. | |||
# iw dev wlan0 interface add | This can be achieved creating a virtual ''uap0'' interface, running | ||
# iw dev wlan0 interface add uap0 type __ap | |||
STA setup can be managed simply following the steps described in [[Wifi_NetworkManager#Configuring_WiFi_Client|Configuring WiFi Client]] section. | STA setup can be managed simply following the steps described in [[Wifi_NetworkManager#Configuring_WiFi_Client|Configuring WiFi Client]] section. | ||
AP setup can be managed following the steps described in [[Wifi_NetworkManager#Configuring_WiFi_Access_Point|Configuring WiFi Access Point]] section, but when creating the access point, be careful to use | AP setup can be managed following the steps described in [[Wifi_NetworkManager#Configuring_WiFi_Access_Point|Configuring WiFi Access Point]] section, but when creating the access point, be careful to use uap0 instead of wlan0. | ||
=== Notes === | === Notes === | ||
nmcli commands create a permanent setup, that does not require to be repeated at every boot. | nmcli commands create a permanent setup, that does not require to be repeated at every boot. | ||
However, the ''iw'' command (used to create the virtual | However, the ''iw'' command (used to create the virtual uap0 interface) does not create permanent changes: we suggest to introduce it in the variscite-wifi script (located in /etc/wifi for latest releases), when checking for the wlan0 existance, something like | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
if [ -d /sys/class/net/wlan0 ]; then | if [ -d /sys/class/net/wlan0 ]; then | ||
# create | # create uap0 interface | ||
iw dev wlan0 interface add | iw dev wlan0 interface add uap0 type __ap | ||
return 0 | return 0 | ||
else | else | ||
Line 216: | Line 170: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
... | ... | ||
# delete | # delete uap0 interface | ||
iw dev | iw dev uap0 del | ||
# Down WIFI | # Down WIFI | ||
wifi_down | wifi_down | ||
Line 228: | Line 182: | ||
AP-STA operations are possible, but the local AP channel is actually the one negotiated between the local client and the remote AP. | AP-STA operations are possible, but the local AP channel is actually the one negotiated between the local client and the remote AP. | ||
= | {{#ifeq: {{#var:WIFI_IW612_SUPPORT}}|yes| | ||
= WiFi Direct = | |||
{{WIFI_DIRECT}} | |||
}} | |||
= Testing WiFi throughput = | |||
{{WIFI_IPERF}} | |||
= Configuring WiFi Regulatory Domain = | = Configuring WiFi Regulatory Domain = | ||
Line 308: | Line 256: | ||
|} | |} | ||
<nowiki>*</nowiki> ISED for Sterling LWB is managed using ''ccode=US'', it's not a typo. | <nowiki>*</nowiki> ISED for Sterling LWB is managed using ''ccode=US'', it's not a typo. | ||
{{# | {{#switch: {{#var:MACHINE_NAME}} | ||
| var-som-mx6 | |||
| imx8mn-var-som | |||
| imx93-var-som | |||
| am62x-var-som | |||
= | |||
| #default= | |||
= Note on {{#var:HARDWARE_NAME}} WiFi Initialization = | = Note on {{#var:HARDWARE_NAME}} WiFi Initialization = | ||
<p>WiFi is initialized by '''/etc/wifi/variscite-wifi'''. During initialization, the Linux device tree '''model''' property is read from '''/sys/devices/soc0/machine''' and is used to | <p>WiFi is initialized by '''/etc/wifi/variscite-wifi'''. During initialization, the Linux device tree '''model''' property is read from '''/sys/devices/soc0/machine''' and is used to | ||
determine the Variscite SOM model and configure the SoM GPIO pins.</p> | determine the Variscite SOM model and configure the SoM GPIO pins.</p> | ||
{{# | {{#switch: {{#var:MACHINE_NAME}} | ||
<p>Additionally, on the {{#var:HARDWARE_NAME}}, the WiFi and the SD card share the same SDIO controller and therefore cannot be used simultaneously. The WiFi script looks for a "WIFI" sub-string to determine whether or not the WiFi device tree was selected.</p> | | imx8mq-var-dart | ||
| imx8m-var-dart | |||
| imx8qxp-var-som | |||
= <p>Additionally, on the {{#var:HARDWARE_NAME}}, the WiFi and the SD card share the same SDIO controller and therefore cannot be used simultaneously. The WiFi script looks for a "WIFI" sub-string to determine whether or not the WiFi device tree was selected.</p> | |||
}} | }} | ||
<p>Therefore, customers who choose to modify the Linux device tree '''model''' property should only append to the string provided by Variscite.</p><br> | <p>Therefore, customers who choose to modify the Linux device tree '''model''' property should only append to the string provided by Variscite.</p><br> | ||
}} |
Latest revision as of 22:55, 29 February 2024
This page is using the default release RELEASE_SUMO_V1.0_DART-MX8M.
To view this page for a specific Variscite SoM and software release, please follow these steps:
- Visit variwiki.com
- Select your SoM
- Select the software release
DART-MX8M Overview
The DART-MX8M supports the following WiFi modules:
Module | Chipset | Features | Network Interface(s) |
---|---|---|---|
Sterling LWB | Cypress CYW4343W | 802.11 b/g/n | wlan0 |
Sterling LWB5 | Cypress CYW43353 | 802.11 ac/a/b/g/n, | wlan0 |
This guide demonstrates how to configure WiFi using NetworkManager. It is important to use the correct network interface for the module assembled on your DART-MX8M.
Managing WiFi using NetworkManager
NetworkManager is a program for providing detection and configuration for systems to automatically connect to network.
NetworkManager's functionality can be useful for both wireless and wired networks.
This guide describes how to use NetworkManager to configure wireless networks.
Enabling and disabling WiFi
To check if WiFi is enabled by NetworkManager run
# nmcli dev show wlan0
and check the GENERAL.STATE line. If WiFi is enabled, the state is either connected or disconnected. If WiFi is disabled the state is unavailable.
To enable WiFi run
# nmcli radio wifi on
or if you need to disable it you can run
# nmcli radio wifi off
Configuring WiFi Client
Scanning for available WiFi APs
If WiFi is enabled you can get the list of available APs by running
# nmcli dev wifi list
Connecting to an open WiFi network
To connect to an open WiFi network run
# nmcli dev wifi connect <SSID> ifname wlan0
To connect to an open hidden WiFi network run
# nmcli dev wifi connect <SSID> hidden yes ifname wlan0
To check connection status run
# nmcli con show <SSID>
To check WiFi device status run
# nmcli dev show wlan0
Connecting to a protected WiFi network
To connect to a protected WiFi network run
# nmcli dev wifi connect <SSID> password <password> ifname wlan0
To connect to a protected hidden WiFi network run
# nmcli dev wifi connect <SSID> password <password> hidden yes ifname wlan0
To check connection status run
# nmcli con show <SSID>
To check WiFi device status run
# nmcli dev show wlan0
Managing existing connections
Once established, the connection is preserved across reboots unless deleted explicitly.
To show existing connections, run
# nmcli con show
To disconnect from a WiFi network, run
# nmcli con down <SSID>
To reconnect to a WiFi network, run
# nmcli con up <SSID>
To permanently delete a connection, run
# nmcli con delete <SSID>
Configuring WiFi Access Point with NetworkManager
NetworkManager can also be used to turn WiFi interface into Access Point.
The benefit of using NetworkManager in this scenario is the complete automation of WiFi, DHCP server and NAT configuration.
Disabling standalone dnsmasq service
Dnsmasq is a lightweight DNS forwarder and DHCP server.
By default dnsmasq runs as a standalone service and will conflict with dnsmasq instance launched by NetworkManager.
To prevent the conflict, disable dnsmasq service by running the following commands:
# systemctl disable dnsmasq # systemctl stop dnsmasq
For NetworkManager to run dnsmasq as a local caching DNS server, edit/create /etc/NetworkManager/NetworkManager.conf and add the following
[main] dns=dnsmasq
Creating WiFi AP
Use the following commands to create the initial AP setup
# nmcli con add type wifi ifname <device> mode ap con-name <name> ssid <ssid> && \ nmcli con modify <name> 802-11-wireless.band <band> && \ nmcli con modify <name> 802-11-wireless.channel <channel> && \ nmcli con modify <name> 802-11-wireless-security.key-mgmt <key-mgmt> && \ nmcli con modify <name> 802-11-wireless-security.proto <proto> && \ nmcli con modify <name> 802-11-wireless-security.group <group> && \ nmcli con modify <name> 802-11-wireless-security.pairwise <pairwise> && \ nmcli con modify <name> 802-11-wireless-security.psk <passphrase> && \ nmcli con modify <name> ipv4.method shared && \ nmcli con up <name>
For example, the following commands will create AP configuration named WIFI_AP on wlan0, with SSID MY_AP, 2.4GHz band, channel 1, WPA2-PSK security, CCMP encryption, and passphrase 11223344 for the Sterling LWB/LWB5.
# nmcli con add type wifi ifname wlan0 mode ap con-name WIFI_AP ssid MY_AP && \ nmcli con modify WIFI_AP 802-11-wireless.band bg && \ nmcli con modify WIFI_AP 802-11-wireless.channel 1 && \ nmcli con modify WIFI_AP 802-11-wireless-security.key-mgmt wpa-psk && \ nmcli con modify WIFI_AP 802-11-wireless-security.proto rsn && \ nmcli con modify WIFI_AP 802-11-wireless-security.group ccmp && \ nmcli con modify WIFI_AP 802-11-wireless-security.pairwise ccmp && \ nmcli con modify WIFI_AP 802-11-wireless-security.psk 11223344 && \ nmcli con modify WIFI_AP ipv4.method shared && \ nmcli con up WIFI_AP
If you are planning to use the 5 GHz band and channel 36, you can partially change the above commands as follow
... # nmcli con modify WIFI_AP 802-11-wireless.band a # nmcli con modify WIFI_AP 802-11-wireless.channel 36 ...
The complete list of nmcli configuration parameters is described in https://developer.gnome.org/NetworkManager/stable/ref-settings.html
Configuring DHCP subnet
By default 10.42.0.x/24 subnet is used by NetworkManager DHCP server, with 10.42.0.1 address assigned to AP itself. To modify it use the following command
# nmcli con modify <name> ipv4.addr <ipaddress/prefix>
For example, the following command will set DHCP subnet to 192.168.5.x/24
# nmcli con modify WIFI_AP ipv4.addr 192.168.5.1/24
Editing AP configuration file
NetworkManager will create /etc/NetworkManager/system-connections/WIFI_AP configuration file.
In addition to executing nmcli commands one can also edit this file to modify the AP settings.
For changes in configuration file to take effect, restart NetworkManager by running
# systemctl restart NetworkManager
Managing existing connections
Once created, the AP configuration is preserved across reboots unless deleted explicitly.
To show existing connections, run
# nmcli con show
To temporarily disable AP configuration, run
# nmcli con down <name>
To enable AP configuration, run
# nmcli con up <name>
To permanently delete AP configuration, run
# nmcli con delete <name>
Configuring WiFi access point with hostapd
hostapd is a versatile tool for setting up a WiFi access point and generally offers more options and flexibility compared to NetworkManager. For instance, hostapd enables the creation of a WiFi 6 access point, which is not currently possible with NetworkManager.
While NetworkManager facilitates complete automation of WiFi, DHCP server, and NAT configuration, hostapd provides more granular control over these settings, making it a preferred choice for advanced configurations.
dnsmasq is a suitable option for providing DHCP and DNS services alongside hostapd. It's a lightweight DNS forwarder and DHCP server that can be easily integrated with hostapd.
Make sure interface (uap0) is not managed by NetworkManager
Before starting with hostapd, it's important that NetworkManager is not managing the access point interface (uap0). If NetworkManager is running, make sure uap0 is unmanaged:
# /etc/NetworkManager/conf.d/99-iw61x-unmanaged-devices.conf [keyfile] unmanaged-devices=interface-name:uap0;
Create /etc/hostapd.conf
The next step is to create /etc/hostapd.conf. The following table shows how to configure 802.11bgn, 802.11ac, and 802.11ax access points:
Wi-Fi 2.4GHz (802.11bgn) /etc/hostapd.conf |
Wi-Fi 5 (802.11ac) /etc/hostapd.conf |
Wi-Fi 6 (802.11ax) /etc/hostapd.conf |
---|---|---|
# /etc/hostapd.conf for 2.4 GHz (802.11b/g/n) # AP Net Interface interface=uap0 # 2.4 GHz hw_mode=g # Enable 802.11n (Wi-Fi 4) standard ieee80211n=1 wmm_enabled=1 # Demo was run in the US country_code=US # Our SSID ssid=Var_AP_2G # Automatically select the best channel # Notes about the LWB/LWB5 modules: # - For AP+STA, the channel must match the STA channel # - The LWB does not support auto channel selection. # We recommend using channel 1 channel=0 |
# /etc/hostapd.conf for Wi-Fi 5 (802.11ac) # AP Net Interface interface=uap0 # 5 GHz hw_mode=a # Enable 802.11ac (Wi-Fi 5) standard ieee80211ac=1 wmm_enabled=1 # Demo was run in the US country_code=US # Our SSID ssid=Var_AP_Wifi5 # Automatically select the best channel # Notes about the LWB/LWB5 modules: # - For AP+STA, the channel must match the STA channel # - The LWB5 does not support auto channel selection. # For LWB5, we recommend using channel 36. channel=0 |
# /etc/hostapd.conf for Wi-Fi 6 (802.11ax) # AP Net Interface interface=uap0 # 5 GHz hw_mode=a # Enable 802.11ax (Wi-Fi 6) standard ieee80211ax=1 wmm_enabled=1 # Demo was run in the US country_code=US # Our SSID ssid=Var_AP_Wifi6 # Automatically select the best channel channel=0 |
Note: When copying the text above, your file may contain zero width spaces at the end of each line (appearing as `^^k` in nano or hex `e2 80 8b` in hexdump). This will cause hostapd to fail. You can fix it by running:
# sed 's/\xe2\x80\x8b//g' /etc/hostapd.conf > /etc/hostapd_cleaned.conf && mv /etc/hostapd_cleaned.conf /etc/hostapd.conf
Configure /etc/dnsmasq.conf
# /etc/dnsmasq.conf interface=uap0 # Use the interface uap0 for DHCP no-dhcp-interface=eth0 # Disable DHCP on eth0 no-dhcp-interface=wlan0 # Disable DHCP on wlan0 no-dhcp-interface=wfd0 # Disable DHCP on wfd0 # Configure ipv4 address range dhcp-range=192.168.10.10,192.168.10.100,12h # Set the DHCP range and lease time # Configure ipv6 address range dhcp-range=fd00:1234::10,fd00:1234::100,12h # Set the DHCPv6 range and lease time # Enable Router Advertisement (RA) to inform clients of the IPv6 prefix enable-ra
Then, assign uap0 an ip and start hostapd and dnsmasq:
# ip addr add 192.168.10.1/24 dev uap0 # ip -6 addr add fd00:1234::1/64 dev uap0 # systemctl restart hostapd # systemctl restart dnsmasq
At this point, devices can connect and dhcp an ip address using the access point on uap0.
Optionally configure NAT between uap0 and eth0:
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT # iptables -A FORWARD -i uap0 -o eth0 -j ACCEPT
and allow ip forwarding by appending /etc/sysctl.conf:
# /etc/sysctl.conf net.ipv4.ip_forward=1 net.ipv6.conf.all.forwarding=1
Now, devices connecting to the access point on uap0 will have network access through eth0.
Sterling LWB/LWB5 WiFi STA/AP concurrency
To get the WiFi module to work in concurrent AP-STA mode on the Sterling LWB/LWB5, a virtual wireless interface is required.
This can be achieved creating a virtual uap0 interface, running
# iw dev wlan0 interface add uap0 type __ap
STA setup can be managed simply following the steps described in Configuring WiFi Client section.
AP setup can be managed following the steps described in Configuring WiFi Access Point section, but when creating the access point, be careful to use uap0 instead of wlan0.
Notes
nmcli commands create a permanent setup, that does not require to be repeated at every boot.
However, the iw command (used to create the virtual uap0 interface) does not create permanent changes: we suggest to introduce it in the variscite-wifi script (located in /etc/wifi for latest releases), when checking for the wlan0 existance, something like
if [ -d /sys/class/net/wlan0 ]; then
# create uap0 interface
iw dev wlan0 interface add uap0 type __ap
return 0
else
...
Also, in the same file, just before shutting down wlan0, you may want to delete this virtual interface, something like
...
# delete uap0 interface
iw dev uap0 del
# Down WIFI
wifi_down
...
Limitations
By HW design, Sterling-LWB/LWB5 WiFi modules provide a single channel tuner.
AP-STA operations are possible, but the local AP channel is actually the one negotiated between the local client and the remote AP.
Testing WiFi throughput
Establish connection to WiFi network and use iperf3 tool on target and another host:
iperf3 server (on Target/Host):
# iperf3 -s
iperf3 client (on Host/Target):
Run UDP test for 30 seconds # iperf3 -c <IP_ADDRESS_OF_IPERF_SERVER> -t 30 -u -b 0
Run TCP test for 30 seconds # iperf3 -c <IP_ADDRESS_OF_IPERF_SERVER> -t 30
Configuring WiFi Regulatory Domain
According the mounting option of the SoM in use, the kernel loads dedicated firmware files from the folder /lib/firmware/brcm:
mounting option | WiFi chip | firmware files |
---|---|---|
WB | Sterling LWB | brcmfmac43430-sdio.bin / brcmfmac43430-sdio.txt |
WBD | Sterling LWB5 | brcmfmac4339-sdio.bin / brcmfmac4339-sdio.txt |
Each txt file contains the ccode parameter selecting the regulatory domain.
Additionally, for Sterling LWB5 only, the regrev parameter must change according the ccode (it's always zero for Sterling LWB).
By default, the BSP ships firmware configurations matching FCC Regulatory Domain, one of the most restrictive in terms of available channels.
For Sterling LWB5 and FCC you can read
ccode=US regrev=911
The following table reports the valid options for ccode / regrev parameter.
regulatory authority |
Sterling LWB | Sterling LWB5 | ||
---|---|---|---|---|
ccode | regrev | ccode | regrev | |
FCC | US | 0 | US | 911 |
ETSI | EU | 0 | EU | 116 |
ISED | US* | 0 | CA | 938 |
MIC | JP | 0 | JP | 101 |
* ISED for Sterling LWB is managed using ccode=US, it's not a typo.
Note on DART-MX8M WiFi Initialization
WiFi is initialized by /etc/wifi/variscite-wifi. During initialization, the Linux device tree model property is read from /sys/devices/soc0/machine and is used to determine the Variscite SOM model and configure the SoM GPIO pins.
Additionally, on the DART-MX8M, the WiFi and the SD card share the same SDIO controller and therefore cannot be used simultaneously. The WiFi script looks for a "WIFI" sub-string to determine whether or not the WiFi device tree was selected.
Therefore, customers who choose to modify the Linux device tree model property should only append to the string provided by Variscite.