How to enable ACS (automatic channel selection) on start

Hi Morse,

Trying to enable ACS at every reboot.

Setup: MM6108 module over SDIO, version 0-rel_1_11_2_2024_Feb_26, hostapd_s1g v2.11-devel, kernel 5.15.71 , country US. enable_survey module param is Y.

Do i need morse_cli to do this or is there another way?

Many thanks!

@halow_darkness setting channel=0 in your hostapd.conf file should enable ACS on start of hostapd.

Thanks very much for getting back to me.

Here is the result of setting channel = 0. :frowning:

pi@raspberrypi:~$ sudo cp /home/pi/wifi-halow-ap.conf /home/pi/wifi-halow-ap.conf.bak
sudo sed -i 's/^CHANNEL=.*/CHANNEL=0/' /home/pi/wifi-halow-ap.conf
sudo systemctl restart wifi-halow-ap.service
journalctl -u wifi-halow-ap.service -n 30 --no-pager
cat /etc/morsemicro-mm610x/conf/ap_halow.conf | grep channel
Job for wifi-halow-ap.service failed because the control process exited with error code.
See "systemctl status wifi-halow-ap.service" and "journalctl -xeu wifi-halow-ap.service" for details.
Jul 20 13:10:10 hostapd_s1g[359213]: wlan1: STA associated (aid 1)
Jul 20 13:10:10 hostapd_s1g[359213]: wlan1: STA RADIUS: starting accounting session
Jul 20 13:10:10 hostapd_s1g[359213]: wlan1: STA WPA: pairwise key handshake completed (RSN)
Jul 20 13:10:19 hostapd_s1g[359213]: wlan1: STA associated (aid 2)
Jul 20 13:10:19 hostapd_s1g[359213]: wlan1: STA RADIUS: starting accounting session
Jul 20 13:10:19 hostapd_s1g[359213]: wlan1: STA WPA: pairwise key handshake completed (RSN)
Jul 20 22:44:40 systemd[1]: Stopping wifi-halow-ap.service - WiFi HaLow Access Point...
Jul 20 22:44:41 systemd[1]: wifi-halow-ap.service: Deactivated successfully.
Jul 20 22:44:41 systemd[1]: Stopped wifi-halow-ap.service - WiFi HaLow Access Point.
Jul 20 22:44:41 systemd[1]: Starting wifi-halow-ap.service - WiFi HaLow Access Point...
Jul 20 22:44:41 wifi-halow-ap-start.sh[504851]: [wifi-halow-ap] Starting WiFi HaLow AP configuration...
Jul 20 22:44:41 wifi-halow-ap[504852]: Starting WiFi HaLow AP configuration...
Jul 20 22:44:41 wifi-halow-ap-start.sh[504851]: [wifi-halow-ap] Waiting for wlan1 interface...
Jul 20 22:44:41 wifi-halow-ap-start.sh[504851]: [wifi-halow-ap] Interface wlan1 is available
Jul 20 22:44:41 wifi-halow-ap[504855]: Interface wlan1 is available
Jul 20 22:44:41 wifi-halow-ap-start.sh[504851]: [wifi-halow-ap] Stopping any existing AP processes...
Jul 20 22:44:41 wifi-halow-ap[504856]: Stopping any existing AP processes...
Jul 20 22:44:42 wifi-halow-ap-start.sh[504851]: [wifi-halow-ap] Starting HaLow AP: SSID=MorseMicro, Channel=0, BW=16 MHz
Jul 20 22:44:42 wifi-halow-ap[504864]: Starting HaLow AP: SSID=MorseMicro, Channel=0, BW=16 MHz
Jul 20 22:44:42 wifi-halow-ap-start.sh[504869]: Unknown S1G operating class 0
Jul 20 22:44:42 wifi-halow-ap-start.sh[504869]: invalid 802.11ah S1G configuration of operating class, country code and channel
Jul 20 22:44:42 wifi-halow-ap-start.sh[504869]: s1g mapped ht channel 58
Jul 20 22:44:42 wifi-halow-ap-start.sh[504869]: 2 errors found in configuration file '/etc/morsemicro-mm610x/conf/ap_halow.conf'
Jul 20 22:44:42 wifi-halow-ap-start.sh[504869]: Failed to set up interface with /etc/morsemicro-mm610x/conf/ap_halow.conf
Jul 20 22:44:42 wifi-halow-ap-start.sh[504869]: Failed to initialize interface
Jul 20 22:44:42 wifi-halow-ap-start.sh[504851]: [wifi-halow-ap] Error: wifi-halow.sh failed with exit code 1
Jul 20 22:44:42 wifi-halow-ap[504870]: Error: wifi-halow.sh failed with exit code 1
Jul 20 22:44:42 systemd[1]: wifi-halow-ap.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jul 20 22:44:42 systemd[1]: wifi-halow-ap.service: Failed with result 'exit-code'.
Jul 20 22:44:42 systemd[1]: Failed to start wifi-halow-ap.service - WiFi HaLow Access Point.
channel=16
pi@raspberrypi:~$

Errors appear to show a configuration problem. Can you share
/etc/morsemicro-mm610x/conf/ap_halow.conf?

Also, 1.11 is quite an old version. Are you able to update?

Thanks for the quick response.

Config below pasted directly from the gateway, both the source we template from and the generated file hostapd actually runs on:

/home/pi/wifi-halow-ap.conf (source):

# /home/pi/wifi-halow-ap.conf
SSID="MorseMicro"
CHANNEL=70
BANDWIDTH=16
SECURITY="wpa3-sae"
PASSWORD="<redacted>"
INTERFACE="wlan1"
IP_ADDRESS="192.168.200.1/24"

/etc/morsemicro-mm610x/conf/ap_halow.conf (generated, what hostapd_s1g actually loads):

# /etc/morsemicro-mm610x/conf/ap_halow.conf (generated)
ctrl_interface=/var/run/hostapd_s1g
interface=wlan1
driver=nl80211
hw_mode=a
ieee80211ah=1
channel=16
op_class=70
country_code=US
ssid=MorseMicro
dtim_period=40
s1g_prim_chwidth=0
s1g_prim_1mhz_chan_index=0
ap_max_inactivity=65536
wpa=2
wpa_key_mgmt=SAE
sae_password=<redacted>
rsn_pairwise=CCMP
ieee80211w=2
sae_pwe=2

One more data point that might be relevant to whether this is config or version-related: separately from the ACS issue, morse_cli -i wlan1 version and morse_cli -i wlan1 hw_version both fail identically with NL80211, code -28: Failed to rcvmsgs, reproducible whether the AP is running or fully stopped. Wanted to flag that pattern in case it points at the same root cause as the ACS issue rather than a separate one.

Unfortunately it is not possible for me to update at this time.

Thanks again for the fast turnaround.

So from what you’ve shown, the CHANNEL field in the config you template from maps to the op_class of the hostap config?

BANDWIDTH appears to be mapping to the hostap channel config instead.

A bit confusing.

Can you confirm what the generated hostap config looked like when you set CHANNEL=0 in your template config? I suspect it will have made op_class=0 which is an invalid configuration.

For ACS, try CHANNEL=70 and BANDWIDTH=0 :woozy_face: . Though it might make sense to modify the script doing the mapping if you are able to.

Thanks for getting back to me so quickly.

As you noted and we did too…when I set CHANNEL=0 in our template, the generated ap_halow.conf came out with op_class=0, and hostapd_s1g failed exactly as you’d expect:

Unknown S1G operating class 0
invalid 802.11ah S1G configuration of operating class, country code and channel
2 errors found in configuration file '/etc/morsemicro-mm610x/conf/ap_halow.conf'
Failed to set up interface with /etc/morsemicro-mm610x/conf/ap_halow.conf

Also when we tried your suggested fix (CHANNEL=70, BANDWIDTH=0 → generates op_class=70, channel=0) before your reply, since we’d worked out the same mapping. That one gets past the op_class validation, but fails differently with no ACS survey appearing to start (no ACS-STARTED or related log lines at all), and instead it fails immediately at the driver level:

Starting HaLow AP: SSID=..., Channel=70, BW=0 MHz
Failed to set channel: error(-1)
morse: Failed to execute morse_cli to set channel parameters on ifname wlan1 (2)
Failed to set the channel (2)

It looks like channel=0 is being handed straight to morse_cli’s literal channel-set call rather than being recognized as the ACS trigger. We also tried the string form (channel=acs_survey) in place of 0 , same identical failure.

For reference, software versions here: morse_cli/morse.ko both report rel_1_11_2_2024_Feb_26, hostapd_s1g v2.11-devel. Separately (may or may not be related) — morse_cli -i wlan1 version and hw_version both fail with NL80211, code -28: Failed to rcvmsgs, reproducible with the AP both running and stopped, while every channel-set call works fine. Wasn’t sure if that’s expected on 1.11 or points at the same underlying gap.

Hi @halow_darkness

Sorry for the delay here, I wanted to dig up some old hardware running close to the same version (1.11.3) to validate ACS for myself. The following hostap config worked for me,which isn’t too dissimilar from what you have..

ctrl_interface=/var/run/hostapd_s1g
interface=wlan0
driver=nl80211
hw_mode=a
ieee80211ah=1
channel=0
op_class=70
country_code=AU
ssid=MorseMicro
dtim_period=40
s1g_capab=[SHORT-GI-ALL]
s1g_prim_chwidth=0
s1g_prim_1mhz_chan_index=0
ap_max_inactivity=65536
wpa=2
wpa_key_mgmt=SAE
sae_require_mfp=1
wpa_passphrase=12345678
wpa_pairwise=CCMP
ieee80211w=2
sae_pwe=1

what does strings /sbin/hostapd_s1g | grep ACS show on your system?

Thanks a lot for your help, below is the output from the grep:

pi@:~$ strings /usr/bin/hostapd_s1g | grep ACS
Interface initialization will be completed in a callback (ACS)
NO_IR: Could not start ACS
setup interface in ACS mode
ACS: Channel was already set to %d
ACS: Could not determine primary channel number from pri_freq %u
ACS: Possibly channel configuration is invalid
ACS/CSA: Cannot decide mode
ACS-COMPLETED freq=%d channel=%d
ACS error - reported complete, but no result available
ACS-FAILED
ACS picked unusable channels
Using offloaded hw_mode=any ACS
Using internal ACS for hw_mode=any
ACS_CHANNEL_SELECTED
ACS_OFFLOAD
ACS: Survey for freq %d is missing noise floor
ACS: Survey for freq %d is missing channel time
ACS: Survey for freq %d is missing RX and busy time (at least one is required)
ACS: Channel %d has insufficient survey data
ACS: No available channels found
ACS: Scanning %d / %d
ACS: Failed to request initial scan
ACS: Using survey based algorithm (acs_num_scans=%d)
ACS: Failed to get survey data
ACS: Failed to request scan
ACS: Trying survey-based ACS
ACS: Unable to collect survey data
ACS: Surveys have insufficient data
ACS: Survey analysis for channel %d (%d MHz)
ACS: %d: insufficient data
ACS: Survey data missing
ACS: %d: min_nf=%d interference_factor=%Lg nf=%d time=%lu busy=%lu rx=%lu
ACS: * interference factor average: %Lg
ACS: All study options have failed
ACS: Survey analysis for selected S1G bandwidth %d MHz
ACS: selected channel %d (%d MHz) S1G ch %d (%d kHz)
ACS: HT40- is not supported yet. Please try HT40+
ACS: Survey analysis for selected bandwidth %d MHz
ACS: Channel %d: BW %u is not supported
ACS: PRI Channel %d: secondary channel %d BW %u is not supported
ACS: Channel %d: not enough bandwidth
ACS: promoting channel %d over %d (less interference %Lg/%Lg)
ACS: * channel %d: total interference = %Lg (%f bias)
ACS: * channel %d: total interference = %Lg
ACS: Ideal channel is %d (%d MHz) with total interference factor of %Lg
ACS: Failed to compute ideal channel
ACS: Adjusting VHT center frequency
ACS: Adjusting HT/VHT/HE secondary frequency
ACS: Only VHT20/40/80/160 is supported now
ACS: Could not (err: %d) select hw_mode for freq=%d channel=%d
ACS: Possibly channel configuration is invalid, please report this along with your config file.
ACS: Failed to start
ACS: Channel %d: not allowed as primary channel for 80 MHz bandwidth
ACS: Channel %d: not allowed as primary channel for 160 MHz bandwidth
ACS: Channel %d: not allowed as primary channel for 40 MHz bandwidth
ACS: Automatic channel selection started, this may take a bit
ACS: Offloading to driver
ACS-STARTED
pi@:~$

I hope this is helpful, let me know if you need anything else.

That’s good. Confirms hostapd_s1g was compiled with ACS enabled.

What is the hostapd_s1g configuration that is generated with bandwidth=0 and channel=70? Does it match closely with the configuration I have shared?

Thanks for your help. It does turn out that “BANDWIDTH” needed to be set to “0” to turn ACS on - so the mapping was a little askew.

pi@xxxx:~$ cat /etc/morsemicro-mm610x/conf/ap_halow.conf
ctrl_interface=/var/run/hostapd_s1g
interface=wlan1
driver=nl80211
hw_mode=a
ieee80211ah=1
channel=0
op_class=70
country_code=US
ssid=MorseMicro
dtim_period=40
s1g_prim_chwidth=0
s1g_prim_1mhz_chan_index=0
ap_max_inactivity=65536
wpa=2
wpa_key_mgmt=SAE
sae_password=<redacted>
rsn_pairwise=CCMP
ieee80211w=2
sae_pwe=2

pi@xxxx:~$ sudo morse_cli -i wlan1 channel -a
NL80211, code -100: Error callback called
NL80211, code -1: Failed to rcvmsgs
Failed to get channel frequency: error(-1)
pi@xxxx:~$ 

It seems ACS only selects 1 MHz Channels and i have been encountering the driver crashing quite often with ACS enabled:
Is there a hostapd_s1g configuration parameter to restrict ACS to 4MHz BW channels only?