WiFi Tethering

Hello all,
Anyone who has implemented or can implement the WiFi Tethering function, please advise.

I got the below information from Chat gpt.
it is possible to control both AP (Access Point) and STA (Station) functionalities simultaneously without the need for a virtual wireless interface. Some wireless chips, like the Broadcom BCM43455, support concurrent operation, allowing a single physical wireless interface to handle both roles.
is this right?
I would appreciate it if you could give me the specific commands to implement tethering.

Looking forward to a positive response.
TianLong

The phy is able to do both simultaneously but the virtual interfaces are still need for controlling the two interfaces separately from userspace. If you have connman installed the simplest method is to enable tethering mode, tether wifi on <ssid> <passphrase>, and then use connmanctrl to connect to your access point. Connmand will take care of setting up the forwarding, NAT, and DHCP/DNS for the clients that connect to the AP.

Thanks for answering.
I have one question.
I keep getting errors in the wireless settings, but I think there is a problem with the kernel.
Is the Yocto layer (“meta-murata-wireless”) added to SolidRun/meta-solidrun-arm-imx8?

It is not, we include the firmware tested for our devices directly in our BSP. Are you using our kirkstone meta-layer? What errors are you getting?

1 Like

Yes, I’m using kirkstone-imx8m.

root@imx8mpsolidrun:~# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: k[ 54.660975] ieee80211 phy0: brcmf_cfg80211_add_iface: iface validation failed: err=-16
ernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
Failed to create interface p2p-dev-wlan0: -16 (Device or resource busy)
nl80211: Failed to create a P2P Device interface p2p-dev-wlan0
P2P: Failed to enable P2P Device interface

This is most likely because connmand or networkmanagerd is already controlling the interface. If you want to manually configure the interfaces then you need to exclude them from being controlled by the networking daemons, or disable the networking daemons running.

1 Like

I added the following command to the local.conf file when building core-minimal-image.
DISTRO_FEATURES:append=" bluez5 bluetooth wifi iw wpa-supplicant packagegroup-tools-bluetooth"
Isn’t this necessary?

Is it possible to implement the wifi tethering function only with the initial core-minimal-image build image?

yes this is possible, but by default Yocto still has wpa_supplicant services that start on boot. You need to shutdown and or disable them if you want to run wpa_supplicant from the commandline.

1 Like

Hello,
Please check my commands for configuring WiFi tethering.

#ifconfig wlan0 up
#iw dev wlan0 interface add wlan1 type __ap
#ifconfig wlan1 192.168.2.1 up
#wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
#wpa_cli -p /var/run/wpa_supplicant -i wlan0 status
#udhcpc -i wlan0 up
#hostapd /etc/hostapd.conf -B

But my phone couldn’t connect to wlan1 AP.
Does it need a DHCP server for wlan1 configuration?

yes, wpa_supplicant doesn’t handle the networking configuration. That is why using a networking daemon makes the entire setup much simpler.

1 Like

Is the networking daemon you’re talking about networkmanager or nmi?

The default one shipped with NXP’s BSP is connmand, but NetworkManager is also an option I have documented how to include it at the end of the Kirkstone readme

1 Like

Tested wifi tethering like below.
#iw dev wlan0 interface add wlan1 type __ap
#ifconfig wlan1 192.168.2.1 up
#wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
#udhcpc -i wlan0 up
#hostapd /etc/hostapd.conf -B
#sysctl -w net.ipv4.ip_forward=1
#iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
#iptables -A FORWARD -i wlan1 -j ACCEPT

it is working fine.
but tethering allows us to connect one device at a time.
if we disconnect the first one, the second one gets connected.
Would you please check if there is an option to connect multiple devices?

I attached hostapd.conf
interface=wlan1
ssid=TetheringTest
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

What dhcp server are you running to provide networking to the connected devices? You should enable verbose logging for all the daemons and see what configuration is disallowing device connections. There are no hardware limitations regarding this.

1 Like

I’m using dnsmasq.

/etc/dnsmasq.conf
interface=wlan1
dhcp-range=192.168.2.10,192.168.2.100,255.255.255.0,24h
server=8.8.8.8
server=8.8.4.4

Now, up to 3 phones are connected, but the 4th phone fails.
One of the three phones that are already connected must be disconnected before the fourth phone is connected.
I looked at the log of hostapd daemon.
There is no log in hostapd while the phone tries to connect and fails.

P2P interface must be present to enable tethering mode using connman?

I built the above github, there is no p2p interface.

I tested it by adding connman in Yocto, but the error below comes out.
IMAGE_INSTALL:append = “iw wpa-supplicant hostapd dnsmasq iptables connman connman-client”

root@imx8mpsolidrun:~# connmanctl tether wifi on APTest 12345678
Wifi SSID set
Wifi passphrase set
Error enabling wifi tethering: Permission denied