Skip to content

Provide regulatory.db info via /lib/firmware when supported #57053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dtzWill opened this issue Mar 7, 2019 · 9 comments · Fixed by #121530
Closed

Provide regulatory.db info via /lib/firmware when supported #57053

dtzWill opened this issue Mar 7, 2019 · 9 comments · Fixed by #121530

Comments

@dtzWill
Copy link
Member

dtzWill commented Mar 7, 2019

Issue description

Newer kernels (4.15+) can look for wireless regulatory info from /lib/firmware (for us this is /run/current-system/firmware I think?),
replacing the need for user-space helper like crda.
(at least in the common case, I believe)

Links to resources/related info

@teto
Copy link
Member

teto commented May 8, 2019

I don't want to hijack the thread but my problem may be related.
Recently, not sure why, I can't connect to an AP I previously could connect to so I suspect it's my machne (my phone can still access it), thus I've been looking at wifi information.
I used to have a plain error then I added udev.packages = [ pkgs.crda ]; while now it at least attempt to connect:

[    5.428896] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    5.428898] cfg80211: failed to load regulatory.db

so I wonder if it's expected on nixos ?

NB: it's annoying all these errors when building kernels. do others have it too (I should probably look at hydras rather...

modinfo: ERROR: Module alias enable_fbc=1 not found.
modinfo: ERROR: Module alias enable_psr=2 not found.
depmod: WARNING: could not open modules.order at /nix/store/2bavdfzx904lyxzyj79avw111sgd1k78-linux-4.19.40-modules-shrunk/lib/modules/4.19.40: No such file or directory
depmod: WARNING: could not open modules.builtin at /nix/store/2bavdfzx904lyxzyj79avw111sgd1k78-linux-4.19.40-modules-shrunk/lib/modules/4.19.40: No such file or directory
building '/nix/store/hrqmhqypk383229adsv79h07g3cv4gdh-stage-1-init.sh.drv'...

@samdoshi
Copy link
Contributor

To get the regulatory.db file loaded, you need to add wireless-regdb to hardware.firmware.

hardware.firmware = with pkgs; [ wireless-regdb ];

ls -l $(nix path-info nixpkgs.wireless-regdb)/lib/firmware to see the files.

Then you should see the following in dmesg:

[    2.532137] cfg80211: Loading compiled-in X.509 certificates for regulatory database

I haven't quite figured out what the best way to set the correct regulatory domain is however... short of just using iw.

@teto
Copy link
Member

teto commented May 15, 2019

oh great thanks ! that was not obvious. I was looking for a setting to set on boot as a kernel parameter but haven't found it yet. Some interesting read https://wireless.wiki.kernel.org/en/developers/regulatory#kernel_integration suggests one can embed the kernel in the db as well ?!

https://wiki.archlinux.org/index.php/Wireless_network_configuration

@edolstra
Copy link
Member

@samdoshi Something like this should work:

  boot.extraModprobeConfig = ''
    options cfg80211 ieee80211_regdom="NL"
  '';

Admittedly not ideal since it only works at module load time though.

@samdoshi
Copy link
Contributor

Thanks @edolstra

Setting the following gives me the correct wifi config (check with iw reg get):

hardware.firmware = with pkgs; [ wireless-regdb ];
boot.extraModprobeConfig = ''
  options cfg80211 ieee80211_regdom="GB"
'';

Looking through the documents on:

https://wireless.wiki.kernel.org/en/developers/regulatory
https://wireless.wiki.kernel.org/en/developers/regulatory/crda

It seems to be a bit of a mess.... ieee80211_regdom is an 'old' option, but NetworkManager has no support for setting the reg domain.

I think having a module (hardware.wirelessRegulatoryDomain?) might be a very good idea, and such an option should be added tonixos-generate-config.

ArchLinux deals with it by using a custom udev rule to run iw when cfg80211 is loaded (source).

Another idea would be to added a networking.wireless.networks.<name>.country option, though that doesn't fix NetworkManager.

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@kloenk
Copy link
Member

kloenk commented Oct 21, 2020

This should not be stale I think.

Should NixOS just add wireless-regdb to hardware.firmware as default?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 21, 2020
@symphorien
Copy link
Member

cc #121530

symphorien added a commit to symphorien/nixpkgs that referenced this issue May 23, 2021
use it when networkmanager or wpa_supplicant is enabled.

fixes NixOS#57053
fixes "Direct firmware load for regulatory.db failed with error -2"
in dmesg

Note that all kernels on unstable are newer that 4.15, which is required
for this to work.
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/direct-firmware-load-for-regulatory-db-failed/16317/1

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 a pull request may close this issue.

7 participants