I have a Yocto Linux device equipped with a Laird 450-0152r wifi module. When the system boots, a systemd service creates an access point using the following script:
#!/bin/bash
modprobe brcmfmac
iw dev wlan0 interface add wlan1 type __ap
ifconfig wlan1 192.168.3.1 up
udhcpd /etc/udhcpd.conf
hostapd /etc/myhostapd.conf
At a certain time a python script may stop the access point service and connect to a wifi using the following commands:
subprocess.call(['systemctl', 'stop', 'access_point'])
subprocess.call(['killall', 'wpa_supplicant'])
subprocess.call(['ifconfig', 'wlan0', 'up'])
subprocess.call(['iw', 'wlan0', 'set', 'power_save', 'off'])
wc_path = WIFI_CREDENTIALS_PATH # path to my conf file generated with wpa_passphrase
subprocess.call(['wpa_supplicant', '-c', wc_path,
'-i', 'wlan0', '-B', '-ddd'],
stderr=subprocess.STDOUT)
time.sleep(4)
subprocess.call(['udhcpc', '-i', 'wlan0', '-b'],
stderr=subprocess.STDOUT)
This works fine but there are some places (i.e. some routers) where wpa_supplicant
often fails to connect. The wpa_supplicant log is not very informative (I don't see any error message). The kernel shows some warnings but I'm not sure they are relevant and I don't know if they are always displayed:
[ 91.642083] ieee80211 phy0: brcmf_run_escan: error (-52)
[ 91.647486] ieee80211 phy0: brcmf_cfg80211_scan: scan error (-52)
My question is: how can I diagnose the problem that prevents wpa_supplicant
to connect? Unfortunately I don't have access to the router where this problem occurs more frequently.
Additional info:
- MAC address randomization is disabled
- Power saving does not seem to be relevant
- The driver is brcmfmac43430
- NetworkManager is not available
Output of iw dev wlan0 info:
Interface wlan0
ifindex 2
wdev 0x1
addr 00:25:ca:6b:d3:e5
ssid SR09142
type managed
wiphy 0
channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz
txpower 31.00 dBm