Setup WiFi access point on iMX6 running stock Linux

Hello, I know this question has been asked but I have followed the postings on this forum as well other stuff found online to no avail… I will try to be detailed.

I’m trying to figure out why the hostapd service is failing to start… Thanks in advance.

First off the basics: (I believe the dongle is working properly…)

root@colibri-imx6:~# uname -a
Linux colibri-imx6 3.14.52-v2.6.1b1+g3894f6d #1 SMP Thu Sep 29 22:12:25 CEST 2016 armv7l GNU/Linux
root@colibri-imx6:~# dmesg | grep rt2
[  8.084663] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 3070, rev 0201 detected
[  8.207934] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 0005 detected
[  8.245950] usbcore: registered new interface driver rt2800usb
[  9.860269] ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'
[  9.876558] ieee80211 phy0: rt2x00lib_request_firmware: Info - Firmware detected - version: 0.29
root@colibri-imx6:~# iw wlan0 info
Interface wlan0
    ifindex 4
    wdev 0x1
    addr 00:10:7a:4f:81:e1
    type managed
    wiphy 0
root@colibri-imx6:~# iw wlan0 scan | grep SSID
    SSID: Fear God!!!
root@colibri-imx6:~#

Now for the Services…:
(networkd)

root@colibri-imx6:~# systemctl -l status systemd-networkd
? systemd-networkd.service - Network Service
  Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
  Active: active (running) since Sat 2016-12-10 18:13:17 UTC; 17min ago
  Docs: man:systemd-networkd.service(8)
Process: 551 ExecStartPre=/sbin/ip link set wlan0 up (code=exited, status=0/SUCCESS)
Main PID: 560 (systemd-network)
Status: "Processing requests..."
CGroup: /system.slice/systemd-networkd.service
       mq560 /lib/systemd/systemd-networkd

Dec 10 18:13:16 colibri-imx6 systemd[1]: Starting Network Service...
Dec 10 18:13:17 colibri-imx6 systemd-networkd[560]: Enumeration completed
Dec 10 18:13:17 colibri-imx6 systemd[1]: Started Network Service.
Dec 10 18:13:17 colibri-imx6 systemd-networkd[560]: usb0: usb0            : could not bring up interface: Invalid argument
Dec 10 18:13:17 colibri-imx6 systemd-networkd[560]: usb0: Configured
Dec 10 18:13:17 colibri-imx6 systemd-networkd[560]: wlan0: Configured
Dec 10 18:13:20 colibri-imx6 systemd-networkd[560]: eth0: Gained carrier
root@colibri-imx6:~#

(hostapd)

root@colibri-imx6:~# systemctl start hostapd
[ 1099.394803] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 1099.955473] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Job for hostapd.service failed because the control process exited with error code. See "systemctl status hostapd.service" and "journalctl -xe" for details.
root@colibri-imx6:~#
root@colibri-imx6:~# systemctl -l status hostapd
? hostapd.service - Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authentication
  Loaded: loaded (/lib/systemd/system/hostapd.service; disabled; vendor preset: enabled)
  Active: failed (Result: exit-code) since Sat 2016-12-10 18:31:26 UTC; 7s ago
Process: 717 ExecStart=/usr/sbin/hostapd /etc/hostapd.conf -P /run/hostapd.pid -B (code=exited, status=1/FAILURE)

Dec 10 18:31:26 colibri-imx6 hostapd[717]: nl80211: Could not configure driver mode
Dec 10 18:31:26 colibri-imx6 hostapd[717]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Dec 10 18:31:26 colibri-imx6 systemd[1]: hostapd.service: Control process exited, code=exited status=1
Dec 10 18:31:26 colibri-imx6 systemd[1]: Failed to start Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authentication.
Dec 10 18:31:26 colibri-imx6 systemd[1]: hostapd.service: Unit entered failed state.
Dec 10 18:31:26 colibri-imx6 systemd[1]: hostapd.service: Failed with result 'exit-code'.
Dec 10 18:31:26 colibri-imx6 hostapd[717]: nl80211 driver initialization failed.
Dec 10 18:31:26 colibri-imx6 hostapd[717]: wlan0: interface state UNINITIALIZED->DISABLED
Dec 10 18:31:26 colibri-imx6 hostapd[717]: wlan0: AP-DISABLED
Dec 10 18:31:26 colibri-imx6 hostapd[717]: hostapd_free_hapd_data: Interface wlan0 wasn't started
root@colibri-imx6:~#

Now for the config files…:

root@colibri-imx6:~#
root@colibri-imx6:~# cat /lib/systemd/system/systemd-networkd.service
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Network Service
Documentation=man:systemd-networkd.service(8)
ConditionCapability=CAP_NET_ADMIN
DefaultDependencies=no
# dbus.service can be dropped once on kdbus, and systemd-udevd.service can be
# dropped once tuntap is moved to netlink
After=systemd-udevd.service dbus.service network-pre.target systemd-sysusers.service systemd-sysctl.service
Before=network.target multi-user.target shutdown.target
Conflicts=shutdown.target
Wants=network.target

# On kdbus systems we pull in the busname explicitly, because it
# carries policy that allows the daemon to acquire its name.
Wants=org.freedesktop.network1.busname
After=org.freedesktop.network1.busname

[Service]
Type=notify
Restart=on-failure
RestartSec=0
ExecStart=/lib/systemd/systemd-networkd
ExecStartPre=/sbin/ip link set wlan0 up
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_CHOWN CAP_DAC_OVERRIDE CAP_FOWNER
ProtectSystem=full
ProtectHome=yes
WatchdogSec=1min

[Install]
WantedBy=multi-user.target
Also=systemd-networkd.socket
root@colibri-imx6:~#
root@colibri-imx6:~#
root@colibri-imx6:~# cat /etc/systemd/network/hostapd.network
[Match]
 Name=wlan0

[Network]
 Address=192.168.12.1/24
 DHCPServer=yes
root@colibri-imx6:~#
root@colibri-imx6:~# cat /lib/systemd/system/hostapd.service
[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authentication
BindsTo=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-wlan0.device

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

[Install]
WantedBy=multi-user.target
root@colibri-imx6:~#

hostapd.conf is attached.

root@colibri-imx6:~#
root@colibri-imx6:~# systemctl stop wpa_supplicant
root@colibri-imx6:~#
root@colibri-imx6:~# hostapd -ddB /etc/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd.conf
ctrl_interface_group=0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Using driver-based off-channel TX
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 4 iftype 3 (AP)
nl80211: Failed to set interface 4 to mode 3: -16 (Device or resource busy)
nl80211: Try mode change after setting interface down
nl80211: Set mode ifindex 4 iftype 3 (AP)
nl80211: Mode change succeeded while interface is down
[  353.137129] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
nl80211: Setup AP(wlan0) - device_ap_sme=0 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x3f99c0
nl80211: Register frame type=0xb0 (WLAN_FC_STYPE_AUTH) nl_handle=0x3f99c0 match=
nl80211: Register frame type=0x0 (WLAN_FC_STYPE_ASSOC_REQ) nl_handle=0x3f99c0 match=
nl80211: Register frame type=0x20 (WLAN_FC_STYPE_REASSOC_REQ) nl_handle=0x3f99c0 match=
nl80211: Register frame type=0xa0 (WLAN_FC_STYPE_DISASSOC) nl_handle=0x3f99c0 match=
nl80211: Register frame type=0xc0 (WLAN_FC_STYPE_DEAUTH) nl_handle=0x3f99c0 match=
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x3f99c0 match=
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x3f99c0 match=
nl80211: Add own interface ifindex 4
nl80211: if_indices[16]: 4
phy: phy0
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 40 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
nl80211: 57240-63720 @ 2160 MHz 0 mBm
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
Completing interface initialization
Mode: IEEE 802.11g  Channel: 1  Frequency: 2412 MHz
DFS 0 channels required radar detection
nl80211: Set freq 2412 (ht_enabled=0, vht_enabled=0, bandwidth=20 MHz, cf1=2412 MHz, cf2=0 MHz)
  * freq=2412
  * vht_enabled=0
  * ht_enabled=0
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
hostapd_setup_bss(hapd=0x3f8f80 (wlan0), first=1)
wlan0: Flushing old station entries
nl80211: flush -> DEL_STATION wlan0 (all)
wlan0: Deauthenticate all stations
nl80211: send_mlme - da= ff:ff:ff:ff:ff:ff noack=0 freq=0 no_cck=0 offchanok=0 wait_time=0 fc=0xc0 (WLAN_FC_STYPE_DEAUTH) nlmode=3
nl80211: send_mlme -> send_frame
nl80211: send_frame - Use bss->freq=2412
nl80211: send_frame -> send_frame_cmd
nl80211: CMD_FRAME freq=2412 wait=0 no_cck=0 no_ack=0 offchanok=0
CMD_FRAME - hexdump(len=26): c0 00 00 00 ff ff ff ff ff ff 00 10 7a 4f 81 e1 00 10 7a 4f 81 e1 00 00 02 00
nl80211: Frame command failed: re[  353.488713] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
t=-16 (Device or resource busy) (freq=2412 wait=0)
wpa_driver_nl80211_set_key: ifindex=4 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
Using interface wlan0 with hwaddr 00:10:7a:4f:81:e1 and ssid "test"
nl80211: Set beacon (beacon_set=0)
nl80211: Beacon head - hexdump(len=55): 80 00 00 00 ff ff ff ff ff ff 00 10 7a 4f 81 e1 00 10 7a 4f 81 e1 00 00 00 00 00 00 00 00 00 00 64 00 01 04 00 04 74 65 73 74 01 08 82 84 8b 96 0c 12 18 24 03 01 01
nl80211: Beacon tail - hexdump(len=45): 2a 01 04 32 04 30 48 60 6c 7f 08 00 00 00 00 00 00 00 40 dd 18 00 50 f2 02 01 01 00 00 03 a4 00 00 27 a4 00 00 42 43 5e 00 62 32 2f 00
nl80211: ifindex=4
nl80211: beacon_int=100
nl80211: dtim_period=2
nl80211: ssid - hexdump_ascii(len=4):
     74 65 73 74                                       test
  * beacon_int=100
nl80211: hidden SSID not in use
nl80211: privacy=0
nl80211: auth_algs=0x3
nl80211: wpa_version=0x0
nl80211: key_mgmt_suites=0x4
nl80211: pairwise_ciphers=0x1
nl80211: group_cipher=0x1
nl80211: SMPS mode - off
nl80211: beacon_ies - hexdump(len=10): 7f 08 00 00 00 00 00 00 00 40
nl80211: proberesp_ies - hexdump(len=10): 7f 08 00 00 00 00 00 00 00 40
nl80211: assocresp_ies - hexdump(len=10): 7f 08 00 00 00 00 00 00 00 40
nl80211: Set wlan0 operstate 0->1 (UP)
netlink: Operstate: ifindex=4 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
wlan0: Setup of interface done.
ctrl_iface not configured!
root@colibri-imx6:~#

Thanks for you help, I can now connect to the AP.

You’ll need to make sure that wpa_supplicant is not running

systemctl stop wpa_supplicant

Please share hostapd.conf file and try running hostapd directly in console with -dd and no -B options and share the output.