Cannot use channels 12 and 13 on Raspberry Pi 3 in AP config

Hi!
I'm trying to set up channel 12/13 on Raspberry Pi 3 in Wifi AP configuration. I get error "brcmfmac: brcmf_cfg80211_start_ap: Set Channel failed: chspec=4109, -20".
Tested on 17.01.1 and latest snapshot (r4117-deef713).
Raspbian works properly on 13 channel as AP.

Logs:

root@LEDE:~# uci show wireless
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.hwmode='11g'
wireless.radio0.path='platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
wireless.radio0.htmode='HT20'
wireless.radio0.disabled='0'
wireless.radio0.country='PL'
wireless.radio0.channel='11'
wireless.default_radio0=wifi-iface
wireless.default_radio0.device='radio0'
wireless.default_radio0.network='lan'
wireless.default_radio0.mode='ap'
wireless.default_radio0.ssid='Dantooine'
wireless.default_radio0.encryption='psk2'
wireless.default_radio0.key='secret'

root@LEDE:~# wifi
[  828.291269] device wlan0 left promiscuous mode
[  828.301579] br-lan: port 2(wlan0) entered disabled state
[  830.594037] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  830.608333] br-lan: port 2(wlan0) entered blocking state
[  830.619697] br-lan: port 2(wlan0) entered disabled state
[  830.631336] device wlan0 entered promiscuous mode
[  830.911507] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[  830.924197] br-lan: port 2(wlan0) entered blocking state
[  830.935606] br-lan: port 2(wlan0) entered forwarding state

root@LEDE:~# uci set wireless.radio0.channel=13
root@LEDE:~# uci commit wireless
root@LEDE:~# wifi
[  913.551274] device wlan0 left promiscuous mode
[  913.561751] br-lan: port 2(wlan0) entered disabled state
[  915.854693] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  915.869110] br-lan: port 2(wlan0) entered blocking state
[  915.880481] br-lan: port 2(wlan0) entered disabled state
[  915.892046] device wlan0 entered promiscuous mode
[  916.080443] brcmfmac: brcmf_cfg80211_start_ap: Set Channel failed: chspec=4109, -20
[  916.131249] device wlan0 left promiscuous mode
[  916.142014] br-lan: port 2(wlan0) entered disabled state
[  927.997654] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  928.012458] br-lan: port 2(wlan0) entered blocking state
[  928.024440] br-lan: port 2(wlan0) entered disabled state
[  928.036703] device wlan0 entered promiscuous mode
[  928.222287] brcmfmac: brcmf_cfg80211_start_ap: Set Channel failed: chspec=4109, -20
[  928.301237] device wlan0 left promiscuous mode
[  928.312608] br-lan: port 2(wlan0) entered disabled state

root@LEDE:~# uci set wireless.radio0.channel=11
root@LEDE:~# uci commit wireless
root@LEDE:~# wifi
[  990.032785] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  990.048153] br-lan: port 2(wlan0) entered blocking state
[  990.060246] br-lan: port 2(wlan0) entered disabled state
[  990.072619] device wlan0 entered promiscuous mode
[  990.351670] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[  990.365070] br-lan: port 2(wlan0) entered blocking state
[  990.377132] br-lan: port 2(wlan0) entered forwarding state
[ 1000.491313] device wlan0 left promiscuous mode
[ 1000.502769] br-lan: port 2(wlan0) entered disabled state
[ 1002.676007] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 1002.691453] br-lan: port 2(wlan0) entered blocking state
[ 1002.703651] br-lan: port 2(wlan0) entered disabled state
[ 1002.716135] device wlan0 entered promiscuous mode
[ 1003.093512] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 1003.107183] br-lan: port 2(wlan0) entered blocking state
[ 1003.119522] br-lan: port 2(wlan0) entered forwarding state

root@LEDE:~# iw list
Wiphy phy0
	max # scan SSIDs: 10
	max scan IEs length: 2048 bytes
	max # sched scan SSIDs: 16
	max # match sets: 16
	max # scan plans: 1
	max scan plan interval: 508
	max scan plan iterations: 0
	Retry short limit: 7
	Retry long limit: 4
	Coverage class: 0 (up to 0m)
	Device supports T-DLS.
	Available Antennas: TX 0 RX 0
	Supported interface modes:
		 * IBSS
		 * managed
		 * AP
		 * P2P-client
		 * P2P-GO
		 * P2P-device
	Band 1:
		Capabilities: 0x1020
			HT20
			Static SM Power Save
			RX HT20 SGI
			No RX STBC
			Max AMSDU length: 3839 bytes
			DSSS/CCK HT40
		Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
		Minimum RX AMPDU time spacing: 16 usec (0x07)
		HT TX/RX MCS rate indexes supported: 0-7
		Frequencies:
			* 2412 MHz [1] (20.0 dBm)
			* 2417 MHz [2] (20.0 dBm)
			* 2422 MHz [3] (20.0 dBm)
			* 2427 MHz [4] (20.0 dBm)
			* 2432 MHz [5] (20.0 dBm)
			* 2437 MHz [6] (20.0 dBm)
			* 2442 MHz [7] (20.0 dBm)
			* 2447 MHz [8] (20.0 dBm)
			* 2452 MHz [9] (20.0 dBm)
			* 2457 MHz [10] (20.0 dBm)
			* 2462 MHz [11] (20.0 dBm)
			* 2467 MHz [12] (20.0 dBm)
			* 2472 MHz [13] (20.0 dBm)
			* 2484 MHz [14] (disabled)
	valid interface combinations:
		 * #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
		   total <= 3, #channels <= 1
		 * #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
		   total <= 4, #channels <= 1

It's LEDE bug or my config is wrong?

regards,
Waldek.

(Update): Thank you for @honza_kl pointing out the mistake of my answer, and I'll re-test changing the country code in OpenWRT on RPi 3.

(Previous answer):
I've finally discovered the issue. The country code setting under OpenWRT Does Not Work!
You need to download the latest Raspbian, set the Wifi country code (to the country that you're currently live in, some countries forbid the use of channel 12 and 13) on Pi under Raspbian, and go back to OpenWRT, select the same country code there.

2 Likes

I reported a bug: link. Can you describe it this bug?

1 Like

Done reporting.

1 Like

I do not understand the way of solution. In my opinion changing the country code using Raspbian will be set in /etc/wpa_supplicant/wpa_supplicant.conf file of your Raspbian system. So if you boot OpenWRT again, the settings have no consequences. Except something is stored in a flash, eprom or OTP. I am not sure, so I hope somebody could explain me, where the country code is saved?

1 Like

The solution from 127.0.0.1 does not work.

After some research, I found that the only solution to get latest version of OpenWRT working on a Raspberry Pi was to install OpenWRT 18.06.1 and then to upgrade to the lastest version (18.06.4 at the time of this writing) from within OpenWRT.

Sytem - Flash New Firmware image (example : openwrt-18.06.4-brcm2708-bcm2710-rpi-3-ext4-sysupgrade.img.gz)

Tested on a Raspberry Pi 3 Model B Rev 1.2

Hope this helps ...

for rpi3b+
guys, do not bother with trying to set country code, the issue is with the brcmfmac driver.
I solved the issue with getting the firmware files from the latest snapshot, copied over to running latest stable version (18.06.5 - kernel 4.9.198) and restarted wifi, all is working now and using mode '11a' with no other issues.
here is the list of steps:
download snapshot (mine is the latest frm Nov 26 - r11595-5d2a900163)
mount it via loop device
fdisk -l <img_file>, shows the 2 partitions
get the start block number for the 2nd partition
calculate the offset, multiply number by 512
in my case it was 75497472
mount -o loop,offset=75497472 <img_file> /mnt
scp lib/firmware/brcm dir to the running system
remove /etc/config/wireless, if there is any in your running system
reboot (or use uci commit wireless and wifi)
phy0 and wlan0 will be created just fine
check dmesg and wireless/network etc files
and continue setting up your system
happy 'wrt-ing'!

Country code doesn't matter right if I'd be only using the pi 3 for routing and a separate AP?

if wifi is entirely disabled on your Pi, the country code doesn't matter. This would mean that you'd be routing via ethernet (built in and/or a USB ethernet adapter).

I really do not understand what you mean by 'go back to OpenWRT'... To my knowledge, rpi 3b+ does not have an EEPROM that would store any information like this on the board, so your instruction may mean either replacing the SD cards in a running system (totally crazy) or debootstrapping from raspbian to openwrt (which is equally crazy). Can you kindly explain what you mean?

1 Like

Thank you for pointing out possible mistake on my original answer post. I've just edited the original post, and will provide more information once I've re-tested changing country code in OpenWRT of my RPi machine.

1 Like

I've downloads 2021-2-21's Snapshot squashfs build for RPi3 B+. Now there's something weird

When I try to set Channel 13, it actually sets to Channel 34?

When I set to channel 1, it seems fine (although I need to select Legacy mode, as N mode would not work)


Sorry to dig up an old post, but according to this, WiFi country code is still an issue.

From reading what @127.0.0.1 says, I understand this to mean one has to do the following:

  1. Install Rasbian on an SD card.
  2. Configure one's country code.
  3. Install OpenWRT on an SD card.

My questions are:

  1. Is this still an issue in 23.05.0? I can see the RPi/OpenWRT configured SSID from my phone.
  2. Where is the country code configured in Raspbian? hostapd.conf?
  3. Is OpenWRT built on top of Raspbian? I cannot see anything in the file system that resembles Raspbian configuration. raspi-config command is not found.
  4. As others have mentioned AFAIK, RPi has no memory outside the SD card, so how will the setting persist when the SD card is flashed with OpenWRT or another SD card with OpenWRT is inserted?

Please forgive me if I've missed something key, but I have an issue and I am scraping the barrel for a solution and as @honza_kl says, I too don't understand @127.0.0.1's, solution.

Thanks.

Sorry, I no longer own Raspberry Pi 3 anymore. Thanks for reaching me out.

It's not related to OpenWrt, but rather the Pi itself (physical device). So yes.

So this means the wifi is generally working for you already. Unless you need (and can't set) channels 12-13. I'd argue that this isn't really needed, per se.

IIRC, the country code in a special (very small) memory area on the Pi when when you run the Raspberry Pi OS and select the country. Raspberry Pi OS will write the information into a non-volitile space, which then applies to any other OS you may run on the device.

No, OpenWrt is not built on-top of, and doesn't run currently with the Raspberry Pi OS. It's entirely independent. That is running the Pi OS first is how you set the country code.

I don't recall exactly where it is written, but the persistent storage exists either in the wifi chip itself (an OTP or other non-volitile memory), or, another very small memory device thath andles the lowest level operations such as the bootloader firmware or similar.

@psherman, Thank you for your detailed reply.

@127.0.0.1's solution makes sense now that I know there is a small memory area and that I had already installed Raspbian and set the country code.

For me, my issue was misconfiguration of the RPi in different areas which you solved in a different post :slight_smile: