Wifi SystemdNetworkd: Difference between revisions
No edit summary |
No edit summary |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 83: | Line 83: | ||
<pre> | <pre> | ||
[DHCPv4] | |||
RouteMetric=9 | |||
[IPv6AcceptRA] | |||
RouteMetric=9 | |||
</pre> | </pre> | ||
Line 92: | Line 92: | ||
<pre> | <pre> | ||
ctrl_interface=/var/run/wpa_supplicant | |||
eapol_version=1 | |||
ap_scan=1 | |||
fast_reauth=1 | |||
</pre> | </pre> | ||
Restart the services | To set your network's SSID and password: | ||
<pre> | |||
# wpa_passphrase <SSID> <PASSWORD> >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf | |||
</pre> | |||
Enable Wi-Fi interface: | |||
<pre> | |||
# networkctl up wlan0 | |||
</pre> | |||
Restart the services: | |||
<pre> | <pre> | ||
Line 106: | Line 117: | ||
</pre> | </pre> | ||
Wait a few seconds and | Wait a few seconds and then check if wlan0 is up and has an assigned IP: | ||
<pre> | <pre> | ||
Line 112: | Line 123: | ||
</pre> | </pre> | ||
== Configuring WiFi Access Point | Check if the gateway and the DNS server are reachable: | ||
<pre> | |||
# ping -I wlan0 192.168.1.1 | |||
# ping -I wlan0 8.8.8.8 | |||
</pre> | |||
== Configuring WiFi Access Point with Hostapd == | |||
hostapd is a versatile | hostapd is a versatile option for setting up a WiFi access point. It offers more options and flexibility compared to other tools.<br> | ||
For instance, hostapd | For instance, hostapd can even enable the creation of a WiFi 6 access point.<br> | ||
udhcpd is a suitable option for providing DHCP services alongside hostapd. It's a lightweight DHCP server that can be easily integrated with hostapd. | |||
udhcpd is a suitable option for providing DHCP services alongside hostapd. It's a lightweight DHCP server that can be easily integrated with hostapd.<br> | |||
The following steps describe how to create an access point using hostapd and udhcpd.<br> | |||
=== Create /etc/hostapd.conf === | === Create /etc/hostapd.conf === | ||
Line 224: | Line 245: | ||
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_SYSTEMD_NETWORKD}} | |||
}} | |||
= Testing WiFi throughput = | |||
{{WIFI_IPERF}} | |||
= 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: | |||
{| class="wikitable" style="text-align: center;" | |||
! mounting option | |||
! WiFi chip | |||
! firmware files | |||
|- | |||
| WB | |||
| [https://www.lairdconnect.com/wireless-modules/wifi-modules-bluetooth/sterling-lwb-24-ghz-wifi-module Sterling LWB] | |||
| brcmfmac43430-sdio.bin / brcmfmac43430-sdio.txt | |||
|- | |||
| WBD | |||
| [https://www.lairdconnect.com/wireless-modules/wifi-modules-bluetooth/sterling-lwb5-dual-band-wifi-module-bluetooth-42 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. | |||
{| class="wikitable" style="text-align: center;" | |||
! rowspan=2 | regulatory<br>authority | |||
! colspan=2 | Sterling LWB | |||
! colspan=2 | Sterling LWB5 | |||
|- | |||
! ccode | |||
! regrev | |||
! ccode | |||
! regrev | |||
|- | |||
| [https://www.fcc.gov/ FCC] | |||
| US | |||
| 0 | |||
| US | |||
| 911 | |||
|- | |||
| [https://www.etsi.org/ ETSI] | |||
| EU | |||
| 0 | |||
| EU | |||
| 116 | |||
|- | |||
| [https://www.ic.gc.ca/ ISED] | |||
| US* | |||
| 0 | |||
| CA | |||
| 938 | |||
|- | |||
| [https://www.soumu.go.jp/english/ MIC] | |||
| JP | |||
| 0 | |||
| JP | |||
| 101 | |||
|} | |||
<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 = | |||
<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> | |||
{{#switch: {{#var:MACHINE_NAME}} | |||
| 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> | |||
}} |
Latest revision as of 21:25, 22 November 2024
This page is using the default release mx95-yocto-scarthgap-6.6.23_2.0.0-v1.0.
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-MX95 Overview
The DART-MX95 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 |
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 systemd-networkd. It is important to use the correct network interface for the module assembled on your DART-MX95.
Managing WiFi using systemd-networkd
systemd-networkd is a system daemon that manages network configurations. It detects and configures network devices as they appear.
systemd-networkd's functionality can be useful for both wireless and wired networks.
This guide describes how to use systemd-networkd to configure wireless networks.
Enabling and disabling WiFi
To enable WiFi run
# networkctl up wlan0
To disable WiFi run
# networkctl down wlan0
Configuring WiFi Client
Scanning for available WiFi APs
If WiFi is enabled you can get the list of available APs by running
# iw dev wlan0 scan | grep SSID
Connecting to a protected WiFi network
Create /etc/systemd/network/80-wifi-station.network as following:
# cp /lib/systemd/network/80-wifi-station.network.example /etc/systemd/network/80-wifi-station.network
Append the following content to /etc/systemd/network/80-wifi-station.network:
[DHCPv4] RouteMetric=9 [IPv6AcceptRA] RouteMetric=9
Create /etc/wpa_supplicant/wpa_supplicant-wlan0.conf with the following content:
ctrl_interface=/var/run/wpa_supplicant eapol_version=1 ap_scan=1 fast_reauth=1
To set your network's SSID and password:
# wpa_passphrase <SSID> <PASSWORD> >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Enable Wi-Fi interface:
# networkctl up wlan0
Restart the services:
# systemctl restart systemd-networkd.service # systemctl restart wpa_supplicant@wlan0.service
Wait a few seconds and then check if wlan0 is up and has an assigned IP:
# ifconfig wlan0
Check if the gateway and the DNS server are reachable:
# ping -I wlan0 192.168.1.1 # ping -I wlan0 8.8.8.8
Configuring WiFi Access Point with Hostapd
hostapd is a versatile option for setting up a WiFi access point. It offers more options and flexibility compared to other tools.
For instance, hostapd can even enable the creation of a WiFi 6 access point.
udhcpd is a suitable option for providing DHCP services alongside hostapd. It's a lightweight DHCP server that can be easily integrated with hostapd.
The following steps describe how to create an access point using hostapd and udhcpd.
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 |
Add the Control interface directory and group to /etc/hostapd.conf:
# Control interface directory and group ctrl_interface=/var/run/hostapd ctrl_interface_group=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 DHCP server
# Sample udhcpd configuration file (/etc/udhcpd.conf) # The start and end of the IP lease block start 192.168.5.20 #default: 192.168.0.20 end 192.168.5.25 #default: 192.168.0.254 # The interface that udhcpd will use interface uap0 opt dns 8.8.8.8 8.8.4.4 # public google dns servers option subnet 255.255.255.0 opt router 192.168.5.1 option lease 864000 # 10 days of seconds
Then, assign uap0 an ip and start hostapd and udhcpd:
ifconfig uap0 192.168.5.1 sleep 1 systemctl restart hostapd sleep 1 udhcpd /etc/udhcpd.conf
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:
echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
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
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.
WiFi Direct
Wi-Fi Direct is a standard that allows devices to connect with each other without a wireless access point or network infrastructure. It facilitates a direct, peer-to-peer connection between two devices using Wi-Fi for data transfer, media sharing, and other communication types.
Variscite SOMs with the Murata LBES5PL2xx (NXP IW61x) modules support WiFi Direct. Verify if your SOM supports WiFi Direct by checking for the wfd0 interface:
# ifconfig wfd0 wfd0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether f6:b2:ba:f8:49:59 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The following process describes how to connect two Variscite SOMs (Device A and Device B) using WiFi Direct:
Device A (WiFi Direct) <================> Device B (WiFi Direct)
Device A Configuration:
Create the wpa supplicant folder:
# mkdir -p /etc/wpa_supplicant/
Create a configuration file for device A, e.g., /etc/wpa_supplicant/wfd0_A.conf, with the following content:
ctrl_interface=/var/run/wpa_supplicant # Control interface directory driver_param=use_p2p_group_interface=1 # Enable dedicated P2P group interface update_config=1 # Allow configuration updates device_name=Device_A # Set device name device_type=1-0050F204-1 # Define device type (e.g., computer) p2p_go_intent=1 # Set group owner intent (0-15) p2p_listen_reg_class=81 # Regulatory class for listen channel p2p_listen_channel=11 # Listen channel number for discovery p2p_oper_reg_class=81 # Regulatory class for operating channel p2p_oper_channel=11 # Operating channel number as group owner
Start wpa_supplicant on device A for the wfd0 interface:
# wpa_supplicant -i wfd0 -c /etc/wpa_supplicant/wfd0_A.conf -D nl80211,wext -B
Device B Configuration:
Create a configuration file for device B, e.g., /etc/wpa_supplicant/wfd0_B.conf, with similar content but different device name:
ctrl_interface=/var/run/wpa_supplicant # Control interface directory driver_param=use_p2p_group_interface=1 # Enable dedicated P2P group interface update_config=1 # Allow configuration updates device_name=Device_B # Set device name device_type=1-0050F204-1 # Define device type (e.g., computer) p2p_go_intent=9 # Set group owner intent (0-15) p2p_listen_reg_class=81 # Regulatory class for listen channel p2p_listen_channel=11 # Listen channel number for discovery p2p_oper_reg_class=81 # Regulatory class for operating channel p2p_oper_channel=11 # Operating channel number as group owner
Start wpa_supplicant on device B for the wfd0 interface:
# wpa_supplicant -i wfd0 -c /etc/wpa_supplicant/wfd0_B.conf -D nl80211,wext -B
Connecting the Devices:
Find peers from device A:
# wpa_cli -i wfd0 p2p_find
From device B, do the same to find peers:
# wpa_cli -i wfd0 p2p_find
After a few moments, list the peers from device A to find the device B's P2P Device Address:
# wpa_cli -i wfd0 p2p_peers
Connect to device B from device A using the P2P Device Address you found (replace XX:XX:XX:XX:XX:XX with the actual address):
# wpa_cli -i wfd0 p2p_connect XX:XX:XX:XX:XX:XX pbc go_intent=0
Verify Connection on Device B: Run a similar p2p_connect command with PBC (Push Button Connect) on Device B, like:
# wpa_cli -i wfd0 p2p_connect <Device_A_MAC_Address> pbc
Verify the Connection on Both Devices, look for wpa_state=COMPLETED in the output.:
# wpa_cli -i wfd0 status
Assign IP Addresses (use ifconfig to determine the dynamically-created P2P interface. Run "ifconfig" to check the interfaces names. Examples: like p2p-wfd0-1 and p2p-wfd0-0:
# ifconfig p2p-wfd0-1 192.168.10.1 (On Device A) # ifconfig p2p-wfd0-0 192.168.10.2 (On Device B)
Try pinging:
# ping 192.168.10.2 # From Device A # ping 192.168.10.1 # From Device B
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-MX95 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.
Therefore, customers who choose to modify the Linux device tree model property should only append to the string provided by Variscite.