Hostapd startup race problem

We are using Torizon 7 on an imx8m-plus. We are using the mlan0 interface in normal (client) mode and the uap0 interface in AP mode based on the documentation here:

For the most part it works well. However, on a reboot, about 25% of the time, hostapd will launch on boot but then mysteriously exit - leaving the AP not working. If I log in and manually start it with systemctl, it will properly run and the AP is fine.

Does anybody know what race condition might be causing this and how to ensure hostapd reliably starts on every boot? I’m suspecting that the wpa_supplicant running on mlan0 might be somehow occasionally interfering with hostapd but I’m not sure.

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your detailed description of the issue.

What you are experiencing is a known race condition related to the timing between hostapd starting and the uap0 network interface becoming available on Torizon OS. By default, hostapd may attempt to start before the uap0 device is ready, causing the service to fail intermittently.

Solution:
You can ensure reliable startup by modifying the hostapd.service file so that the service waits for the uap0 device. Here’s how:

  1. Edit the hostapd systemd service file at /usr/lib/systemd/system/hostapd.service.

  2. Update the [Unit] section to explicitly bind hostapd to the uap0 device:

    [Unit]
    Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
    BindsTo=sys-subsystem-net-devices-uap0.device
    After=sys-subsystem-net-devices-uap0.device
    
  3. Save the file.

  4. Reload the systemd configurations:

    sudo systemctl --system daemon-reload
    

This change will force hostapd to wait until the uap0 Wi-Fi AP interface is fully created by the driver before starting. It addresses the race condition and ensures the AP comes up reliably after every boot.

For further details, please refer to the documentation:
Networking with Torizon OS: Wi-Fi Access Point Mode

Let me know if this resolves your issue or if you have any additional questions.

Best regards,
Toradex AI Assistant.

Thanks but we followed the directions in the linked documentation - including setting up the service file with the [unit] section set exactly like that.

With hostapd debugging turned on, this is what the output looks like:

torizon@verdin-imx8mp-15230201:~$ systemctl status aktina-hostapd
○ aktina-hostapd.service - Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
     Loaded: loaded (/etc/systemd/system/aktina-hostapd.service; enabled; preset: disabled)
     Active: inactive (dead) since Mon 2025-08-04 13:51:46 UTC; 5s ago
   Duration: 430ms
    Process: 730 ExecStart=/usr/sbin/hostapd /etc/hostapd.conf -P /run/hostapd.pid -B -dd (code=exited, status=0/SUCCESS)
   Main PID: 732 (code=exited, status=0/SUCCESS)
        CPU: 71ms

Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Add own interface ifindex 6 (ifidx_reason -1)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: if_indices[16]: 6(-1)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: phy: phy0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: uap0: interface state UNINITIALIZED->COUNTRY_UPDATE
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: Previous country code 00, new country code US
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: Continue interface setup after channel list update
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: ctrl_iface not configured!
Aug 04 13:51:46 verdin-imx8mp-15230201 systemd[1]: Started Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator.
Aug 04 13:51:46 verdin-imx8mp-15230201 systemd[1]: aktina-hostapd.service: Deactivated successfully.
torizon@verdin-imx8mp-15230201:~$ journalctl -u aktina-hostapd
Aug 04 13:51:46 verdin-imx8mp-15230201 systemd[1]: Starting Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator...
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: random: Trying to read entropy from /dev/random
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: Configuration file: /etc/hostapd.conf
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: TDLS supported
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: TDLS external setup
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supported cipher 00-0f-ac:1
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supported cipher 00-0f-ac:5
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supported cipher 00-0f-ac:2
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supported cipher 00-0f-ac:4
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supported cipher 00-14-72:1
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supported cipher 00-0f-ac:6
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Supports Probe Response offload in AP mode
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: TDLS channel switch
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Use separate P2P group interface (driver advertised support)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x894f97ac0 rrm_flags=0x0 probe_resp_offloads=0x7 max_stations=8 max_remain_on_chan=5000 max_scan_ssids=10
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: interface uap0 in phy phy0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Set mode ifindex 6 iftype 3 (AP)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Setup AP(uap0) - device_ap_sme=1 use_monitor=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Subscribe to mgmt frames with AP handle 0x55c63955b0 (device SME)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=04 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=0501 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=0503 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=0504 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=06 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=08 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=09 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=0a multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=11 multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55c63955b0 match=7f multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0xb0 (WLAN_FC_STYPE_AUTH) nl_handle=0x55c63955b0 match= multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: kernel reports: Registration to specific type not supported
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame command failed (type=176): ret=-22 (Invalid argument)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame match - hexdump(len=0): [NULL]
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Failed to subscribe to handle Authentication frames - SAE offload may not work
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Enable Probe Request reporting nl_preq=0x55c638fa10
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x55c638fa10 match= multicast=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: Add own interface ifindex 6 (ifidx_reason -1)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: nl80211: if_indices[16]: 6(-1)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: phy: phy0
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: uap0: interface state UNINITIALIZED->COUNTRY_UPDATE
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: Previous country code 00, new country code US
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: Continue interface setup after channel list update
Aug 04 13:51:46 verdin-imx8mp-15230201 hostapd[730]: ctrl_iface not configured!
Aug 04 13:51:46 verdin-imx8mp-15230201 systemd[1]: Started Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator.
Aug 04 13:51:46 verdin-imx8mp-15230201 systemd[1]: aktina-hostapd.service: Deactivated successfully.
torizon@verdin-imx8mp-15230201:~$ 

Note, it looks almost exactly the same as when it does work right:

torizon@verdin-imx8mp-15230201:~$ systemctl status aktina-hostapd
● aktina-hostapd.service - Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
     Loaded: loaded (/etc/systemd/system/aktina-hostapd.service; enabled; preset: disabled)
     Active: active (running) since Mon 2025-08-04 13:49:29 UTC; 1min 24s ago
    Process: 737 ExecStart=/usr/sbin/hostapd /etc/hostapd.conf -P /run/hostapd.pid -B -dd (code=exited, status=0/SUCCESS)
   Main PID: 739 (hostapd)
      Tasks: 1 (limit: 4057)
     Memory: 2.2M (peak: 2.5M)
        CPU: 86ms
     CGroup: /system.slice/aktina-hostapd.service
             └─739 /usr/sbin/hostapd /etc/hostapd.conf -P /run/hostapd.pid -B -dd

Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: uap0: interface state UNINITIALIZED->COUNTRY_UPDATE
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: Previous country code 00, new country code US
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: Continue interface setup after channel list update
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: ctrl_iface not configured!
Aug 04 13:49:29 verdin-imx8mp-15230201 systemd[1]: Started Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator.
Aug 04 13:49:32 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 IEEE 802.11: associated
Aug 04 13:49:36 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 IEEE 802.11: disassociated
Aug 04 13:50:02 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 IEEE 802.11: associated
Aug 04 13:50:04 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 RADIUS: starting accounting session 95586AD4678320CD
Aug 04 13:50:04 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 WPA: pairwise key handshake completed (RSN)
torizon@verdin-imx8mp-15230201:~$ journalctl -u aktina-hostapd
Aug 04 13:49:29 verdin-imx8mp-15230201 systemd[1]: Starting Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator...
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: random: Trying to read entropy from /dev/random
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: Configuration file: /etc/hostapd.conf
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: TDLS supported
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: TDLS external setup
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supported cipher 00-0f-ac:1
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supported cipher 00-0f-ac:5
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supported cipher 00-0f-ac:2
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supported cipher 00-0f-ac:4
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supported cipher 00-14-72:1
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supported cipher 00-0f-ac:6
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Supports Probe Response offload in AP mode
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: TDLS channel switch
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Use separate P2P group interface (driver advertised support)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x894f97ac0 rrm_flags=0x0 probe_resp_offloads=0x7 max_stations=8 max_remain_on_chan=5000 max_scan_ssids=10
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: interface uap0 in phy phy0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Set mode ifindex 6 iftype 3 (AP)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Setup AP(uap0) - device_ap_sme=1 use_monitor=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Subscribe to mgmt frames with AP handle 0x55929125b0 (device SME)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=04 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=0501 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=0503 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=0504 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=06 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=08 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=09 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=0a multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=11 multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55929125b0 match=7f multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0xb0 (WLAN_FC_STYPE_AUTH) nl_handle=0x55929125b0 match= multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: kernel reports: Registration to specific type not supported
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame command failed (type=176): ret=-22 (Invalid argument)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame match - hexdump(len=0): [NULL]
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Failed to subscribe to handle Authentication frames - SAE offload may not work
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Enable Probe Request reporting nl_preq=0x559290ca10
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x559290ca10 match= multicast=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: Add own interface ifindex 6 (ifidx_reason -1)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: nl80211: if_indices[16]: 6(-1)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: phy: phy0
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: uap0: interface state UNINITIALIZED->COUNTRY_UPDATE
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: Previous country code 00, new country code US
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: Continue interface setup after channel list update
Aug 04 13:49:29 verdin-imx8mp-15230201 hostapd[737]: ctrl_iface not configured!
Aug 04 13:49:29 verdin-imx8mp-15230201 systemd[1]: Started Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator.
Aug 04 13:49:32 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 IEEE 802.11: associated
Aug 04 13:49:36 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 IEEE 802.11: disassociated
Aug 04 13:50:02 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 IEEE 802.11: associated
Aug 04 13:50:04 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 RADIUS: starting accounting session 95586AD4678320CD
Aug 04 13:50:04 verdin-imx8mp-15230201 hostapd[739]: uap0: STA 10:68:38:50:47:57 WPA: pairwise key handshake completed (RSN)
torizon@verdin-imx8mp-15230201:~$

and the service file:

torizon@verdin-imx8mp-15230201:~$ cat /etc/systemd/system/aktina-hostapd.service 
[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
BindsTo=sys-subsystem-net-devices-uap0.device
After=sys-subsystem-net-devices-uap0.device

[Service]
Type=forking
PIDFile=/run/hostapd.pid
ExecStart=/usr/sbin/hostapd /etc/hostapd.conf -P /run/hostapd.pid -B -dd

[Install]
WantedBy=multi-user.target
torizon@verdin-imx8mp-15230201:~$ 

Is a Yocto build the only path for getting some debugging tools like strace loaded on to a stock Torizon build?

Was able to use Yocto to get strace into the OS and then was able to recreate this. I don’t know why journalctl isn’t capturing this output but it’s reporting this to stderr:

PSK (from passphrase) - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=0
GMK - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=0
Key Counter - hexdump(len=32): [REMOVED]
WPA: Delay group state machine start until Beacon frames have been configured
nl80211: Set beacon (beacon_set=0)
nl80211: Beacon head - hexdump(len=61): 80 00 00 00 ff ff ff ff ff ff 10 68 38 50 41 3d 10 68 38 50 41 3d 00 00 00 00 00"..., 223) = 223
nl80211: Beacon tail - hexdump(len=132): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 cc 00 3b 02 73 00 2"..., 437) = 437
nl80211: ifindex=6
nl80211: beacon_int=100
nl80211: beacon_rate=0
nl80211: rate_type=0
nl80211: dtim_period=2
nl80211: ssid=ABC-123456
  * beacon_int=100
  * dtim_period=2
nl80211: proberesp (offload) - hexdump(len=193): 50 00 00 00 00 00 00 00 00 00 10 68 38 50 41 3d 10 68 38 50 41 3d 00 00"..., 628) = 628
nl80211: hidden SSID not in use
nl80211: privacy=2
nl80211: auth_algs=0x1
nl80211: wpa_version=0x2
nl80211: key_mgmt_suites=0x2
nl80211: pairwise_ciphers=0x10
nl80211: group_cipher=0x10
nl80211: beacon_ies - hexdump(len=3): 7f 01 04
nl80211: proberesp_ies - hexdump(len=3): 7f 01 04
nl80211: assocresp_ies - hexdump(len=3): 7f 01 04
nl80211: ap_max_inactivity=300
uap0: Deauthenticate all stations at BSS start
nl80211: sta_remove -> DEL_STATION uap0 ff:ff:ff:ff:ff:ff --> 0 (Success)
WPA: Start group state machine to set initial keys
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): [REMOVED]
Get randomness: len=16 entropy=0
IGTK - hexdump(len=16): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=6 (uap0) alg=3 addr=0x5564bb0ec0 key_idx=1 set_tx=1 seq_len=0 key_len=16 key_flag=0x"..., 123) = 123
nl80211: NEW_KEY
nl80211: KEY_DATA - hexdump(len=16): [REMOVED]
   broadcast key
nl80211: NL80211_CMD_SET_KEY - default key
wpa_driver_nl80211_set_key: ifindex=6 (uap0) alg=4 addr=0x5564bb0ec0 key_idx=4 set_tx=1 seq_len=0 key_len=16 key_flag=0x"..., 123) = 123
nl80211: NEW_KEY
nl80211: KEY_DATA - hexdump(len=16): [REMOVED]
   broadcast key
nl80211: NL80211_CMD_SET_KEY - default key
nl80211: set_key default failed; err=-1 Operation not permitted
WPA: group state machine entering state FATAL_FAILURE
uap0: Flushing old station entries
nl80211: flush -> DEL_STATION uap0 (all)
uap0: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION uap0 ff:ff:ff:ff:ff:ff --> 0 (Success)
hostapd_free_hapd_data(uap0)
Interface initialization failed
uap0: interface state HT_SCAN->DISABLED
uap0: AP-DISABLED 
hostapd_interface_deinit_free(0x55755c5a70)
hostapd_interface_deinit_free: num_bss=1 conf->num_bss=1
hostapd_interface_deinit(0x55755c5a70)
uap0: interface state DISABLED->DISABLED
hostapd_bss_deinit: deinit bss uap0
uap0: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION uap0 ff:ff:ff:ff:ff:ff --> 0 (Success)
uap0: AP-DISABLED 
hostapd_cleanup(hapd=0x55755c6df0 (uap0))
uap0: CTRL-EVENT-TERMINATING 
hostapd_free_hapd_data: Interface uap0 wasn't started
hostapd_interface_deinit_free: driver=0x5564c0eb58 drv_priv=0x55755c8450 -> hapd_deinit
nl80211: deinit ifname=uap0 disabled_11b_rates=0
nl80211: Disable Probe Request reporting nl_preq=0x888888ddfdd4f299
nl80211: Remove monitor interface: refcount=0
nl80211: Remove beacon (ifindex=6)
netlink: Operstate: ifindex=6 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)
nl80211: Unsubscribe mgmt frames handle 0x888888ddfdd45d39 (deinit)
hostapd_interface_free(0x55755c5a70)
hostapd_interface_free: free hapd 0x55755c6df0
hostapd_cleanup_iface(0x55755c5a70)
hostapd_cleanup_iface_partial(0x55755c5a70)
hostapd_cleanup_iface: free iface=0x55755c5a70

It appears that nl80211: set_key default failed; err=-1 Operation not permitted is the problem.

Anybody know why that might be happening occasionally?

Decided to review and simplify the hostapd.conf file we are using and see if that could affect this.

It was glommed together from various bits of Toradex documentation – and removing some of the more complex and esoteric settings caused the problem to stop occurring. Unfortunately, it seems you can spec settings that are valid to hostapd but potentially cause the driver and/or chip itself to behave non-deterministically.

So, if you run into something like this, I recommend first tweaking the hostapd.conf file and ruling it out as the source of trouble before going further.

Hi @davidkhess

Glad to hear you got this sorted on your. Apologies for the delay in responding. Please do reach out if you have any further feedback on this.
Drew