Skip to content

feat: support wireless regulatory regions#5

Draft
tomasff wants to merge 3 commits into
gokrazy:mainfrom
tomasff:main
Draft

feat: support wireless regulatory regions#5
tomasff wants to merge 3 commits into
gokrazy:mainfrom
tomasff:main

Conversation

@tomasff

@tomasff tomasff commented Apr 5, 2026

Copy link
Copy Markdown

Currently it's not possible to connect to APs on channel 13 (or other channels that are not widely available) due to the regulatory constraints imposed by cfg80211, unless the region is configured.
Unfortunately my ISP's router does not let me change which channels are used 😢

Given cfg80211 is loaded before the root fs is ready, it's not able to read the regulatory.db + signature (required before we can configure the regulatory region) if we included it as ExtraFilePaths:

[    2.435598] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    2.440347] Loaded X.509 cert 'benh@debian.org: 577e021cb980e0e820821ba7b54b4961b8b4fadf'
[    2.443260] Loaded X.509 cert 'romain.perier@gmail.com: 3abbc6ec146e09d1b6016ab9d6cf71dd233f0328'
[    2.446235] Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    2.448225] Loaded X.509 cert 'wens: 61c038651aabdcf94bd0ac7ff06c7248db18c600'
[    2.449428] clk: Disabling unused clocks
[    2.450616] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    2.452731] cfg80211: failed to load regulatory.db
[    2.453924] PM: genpd: Disabling unused power domains
[    2.455014] ALSA device list:
[    2.455987]   No soundcards found.
[    2.509996] sdhost-bcm2835 3f202000.mmc: loaded - DMA enabled (>1)
[    2.511230] Waiting for root device PARTUUID=60c24cc1-f3f9-427a-8199-5b4011de0001/PARTNROFF=1...
[    2.555505] mmc1: new high speed SDIO card at address 0001
[    2.600176] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.604934] mmc0: new high speed SDHC card at address 59b4
[    2.606697] mmcblk0: mmc0:59b4 USD   15.0 GiB
[    2.616205]  mmcblk0: p1 p2 p3 p4
[    2.617940] mmcblk0: mmc0:59b4 USD   15.0 GiB
[    2.636995] VFS: Mounted root (squashfs filesystem) readonly on device 179:2.
[    2.640714] devtmpfs: mounted

Note the Direct firmware load for regulatory.db failed with error -2 (not found).

To support regulatory regions, I've added ReloadRegulatoryDatabase and SetRegulatoryRegion upstream in mdlayher/wifi#162.

The final piece is this PR which,

Opted for this approach as it maintains backwards compatibility without broader kernel changes, while supporting the use case.

The regulatory database does not to seem to change often and bundling it with this package seems in-line with the gokrazy philosophy. The license seems compatible, but please let me know if you have any concerns.

ExtraFiles

tomas@kamino:~/code/wifi/_gokrazy$ tar tvf extrafiles.tar 
drwxr-xr-x michael/michael   0 2022-03-03 20:35 lib/
drwxr-xr-x michael/michael   0 2022-03-19 18:22 lib/firmware/
drwxr-xr-x michael/michael   0 2024-06-03 20:35 lib/firmware/brcm/
-rw-r--r-- michael/michael 416101 2022-04-11 17:16 lib/firmware/brcm/brcmfmac43430b0-sdio.raspberrypi,model-zero-2-w.bin
lrwxrwxrwx michael/michael      0 2024-06-03 20:30 lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,5-model-b.txt -> brcmfmac43455-sdio.txt
-rw-r--r-- michael/michael 419798 2022-02-28 16:48 lib/firmware/brcm/brcmfmac43430-sdio.bin
-rw-r--r-- michael/michael   1613 2022-03-20 11:03 lib/firmware/brcm/brcmfmac43430b0-sdio.raspberrypi,model-zero-2-w.txt
-rw-r--r-- michael/michael   4733 2022-02-28 16:48 lib/firmware/brcm/brcmfmac43430-sdio.clm_blob
-rw-r--r-- michael/michael   2074 2024-06-03 20:29 lib/firmware/brcm/brcmfmac43455-sdio.txt
lrwxrwxrwx michael/michael      0 2024-06-03 20:34 lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt -> brcmfmac43455-sdio.txt
lrwxrwxrwx michael/michael      0 2024-06-03 20:33 lib/firmware/brcm/brcmfmac43455-sdio.bin -> cyfmac43455-sdio-standard.bin
-rw-r--r-- michael/michael 643651 2024-06-03 20:33 lib/firmware/brcm/cyfmac43455-sdio-standard.bin
lrwxrwxrwx michael/michael      0 2024-06-03 20:35 lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt -> brcmfmac43455-sdio.txt
-rw-r--r-- michael/michael   2676 2024-06-03 20:33 lib/firmware/brcm/cyfmac43455-sdio.clm_blob
lrwxrwxrwx michael/michael      0 2024-06-03 20:34 lib/firmware/brcm/brcmfmac43455-sdio.clm_blob -> cyfmac43455-sdio.clm_blob
-rw-r--r-- michael/michael    874 2022-02-28 16:48 lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,3-model-b.txt
lrwxrwxrwx michael/michael      0 2024-06-03 20:35 lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,3-model-a-plus.txt -> brcmfmac43455-sdio.txt
-rw-r--r-- michael/michael  11209 2022-03-20 11:03 lib/firmware/brcm/brcmfmac43430b0-sdio.clm_blob
-rw-r--r-- michael/michael    874 2022-03-23 07:42 lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,model-zero-2-w.txt
-rw-r--r-- michael/michael   1121 2022-09-07 07:34 lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.txt
-rw-r--r-- tomas/tomas       6308 2026-02-04 07:44 lib/firmware/regulatory.db
-rw-r--r-- tomas/tomas       1085 2026-02-04 07:44 lib/firmware/regulatory.db.p7s

Testing

Tested successfully on a Pi Zero 2W with an AP on channel 13 (2.4 Ghz).

1970/01/01 01:00:03 gokrazy: attempt 0, starting ["/user/wifi"]
2026/04/05 16:26:31 no interfaces found
2026/04/05 16:26:31 gokrazy: exit status 1
2026/04/05 16:26:32 gokrazy: attempt 1, starting ["/user/wifi"]
2026/04/05 16:26:32 requested wireless regulatory region GB
2026/04/05 16:26:32 wlan0 MAC address is xx:xx:xx:xx:xx:xx
2026/04/05 16:26:32 connecting to SSID "myAP"...
2026/04/05 16:26:47 connected to yy:yy:yy:yy:yy:yy for 16s, signal -29
2026/04/05 16:26:47 starting [/gokrazy/dhcp -interface=wlan0]
2026/04/05 16:26:47 dhcp.go:299: waiting indefinitely for wlan0 to appear
2026/04/05 16:26:48 dhcp.go:160: DHCPACK: IP 192.168.1.130/24, router 192.168.1.1, DNS [192.168.1.1], broadcast 192.168.1.255
2026/04/05 16:26:48 dhcp.go:255: adjusting route [dst=192.168.1.0/24 src=192.168.1.130 gw=<nil>] priority to 5

with

{
    "ssid": "myAP",
    "psk": "...",
    "region": "GB"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant