Gord_W wrote:It looks like it is still going World,CN,US.
I have in /etc/default/crda
REGDOMAIN=CA
Hi Gordon,
Yep, looks like its ignoring the /etc/default/crda file completely.
I came accross this for Atheros based wifi devices: https://bbs.archlinux.org/viewtopic.php?id=179738. Although this is for Arch, it appears you can set the regulatory domain (country) by writing to the EEPROM on your wifi device.
I would attempt this at my end, unfortunately, I dont own a Atheros based wifi device.
As for disabling crda, you could try blacklisting the crda module (cfg80211):
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
I've done the following:
echo -e "blacklist cfg80211" > /etc/modprobe.d/blacklist-cfg80211.conf
and rebooted and I don't think that there is any change. Still going world,CN,US
cfg80211 is still being used. So I don't see any effect of the blacklist.
I also tried uninstalling crda and the two dependencies (iw and db) no longer required and that just brought me back to the beginning of the thread with many more calls to CRDA.
The ath9k driver (and all other softmac drivers?) sets its own regulatory restrictions based on its EEPROM, i.e. the ART (Atheros Radio Test) partition on flash. Setting the domain from userland can only further restrict the regulatory settings. So if EEPROM says Japan, you can use all 14 channels, if you then set it to US, you can use merely the 12. It does not work the other way around, i.e. if EEPROM says US, you only can use the allowed 12 channels, no matter what you set in userspace! The value 98 represents a synthesized regulatory domain, based on the intersection of the available source of regulatory information (which can include the EEPROM, the userland setting, and a country IE from your AP).
It looks like when it goes World,CN,CA it takes an intersection of all these domains to find the regulatory environment that fits them all.
Gord_W wrote:It looks like when it goes World,CN,CA it takes an intersection of all these domains to find the regulatory environment that fits them all.
Hi Gordon,
Thanks for the updates, and interesting find.
What we know:
- /etc/default/crda has no effect on crda or setting country code.
- CRDA seems to revert to a failsafe. No country code set = Country 00 (failsafe)
- We can run iw reg set to manually set country code.
Option 1:
The blacklist works for me. Disables the cfg80211 module:
run lsmod to see if the module is loaded, before and after. Make sure you reboot after running the below code.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
This is strange. As the cfg80211 module states it being used by the ath devices, it appears your Atheros card is overriding the blacklisted module in some way?
Maybe try blacklisting the mac80211 module aswell?
Try running the following to see if yours returns the same value:
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
If I don't have crda then I will get a dmesg like the first post with multiple calls to update CRDA that go unanswered until it times out.
As a newbee, you will have to tell me what boot script I should try adding the iw command.
A couple of other thoughts:
1) looking at the dmesg a few things are unclear. It connects to the wireless at around 41 seconds, but before that time
[ 8.538025] cfg80211: Calling CRDA to update world regulatory domain
...
[ 8.952880] cfg80211: World regulatory domain updated:
...
[ 12.171573] cfg80211: Calling CRDA for country: CN
[ 12.386345] cfg80211: Calling CRDA for country: CN
[ 12.559086] cfg80211: Current regulatory domain intersected:
---
Then wireless router association and authentication followed by
[ 41.232623] cfg80211: Calling CRDA for country: CA
[ 41.309597] cfg80211: Regulatory domain changed to country: CA
For the world and CN, with no internet connection, I'm not sure what they are calling and who is answering!
The regulatory domain change to CA comes from the the wireless router regulatory domain setting. That info get transmitted to the rPi.
2) If I run crda
root@dietpi:~# crda
COUNTRY environment variable not set.
if I add a country environment variable:
root@dietpi:~# export COUNTRY=CA
root@dietpi:~# echo $COUNTRY
CA
root@dietpi:~# crda
Failed to set regulatory domain: -7
You are not supposed to run crda from the command line according to the docs. But this does show that the new COUNTRY variable is being read and then rejected as the kernel is not supposed to make changes for unexpected requests.
How can one set an environment variable early during the boot process (newbee here)? As we have seen, crda is not reading the config file in /etc/default.
From the CRDA man pages:
NAME
crda - send to the kernel a wireless regulatory domain for a given ISO
/ IEC 3166 alpha2
SYNOPSIS
crda
Description
crda is the Linux wireless central regulatory domain agent. crda is
intended to be used by udev scripts and should not be run manually
unless debugging udev scripts. crda is triggered to run by the kernel
by sending a udev event upon a new regulatory domain change. Regulatory
domain changes are triggered by the wireless kernel subsystem (upon
initialization and on reception of country IEs), wireless drivers, or
userspace (see iw ). Upon a regulatory domain change the kernel sends a
udev change event for the regulatory platform. The kernel ignores regu‐
latory domains sent to it if it does not expect them. The regulatory
domain is read by crda from the regulatory.bin file.
RSA Digital Signature
If built with openssl or gcrypt support crda will have embedded into it
an RSA digital signature which will prevent it from reading corrupted
or non-authored regulatory.bin files. Authorship is respected by the
RSA public key packed into crda. This specific crda package has been
built with an RSA public key from John Linville (the Linux wireless
kernel maintainer) and as such will only read regulatory.bin files
signed by him. For further information see the regulatory.bin man page.
UDEV RULE
A udev regulatory rule must be put in place in order to receive and
parse udev events from the kernel in order to get udev to call crda
with the passed ISO / IEC 3166 alpha2 country code. An example udev
rule which can be used (usually in /lib/udev/rules.d/85-regula‐
tory.rules ):
Environment variable
Set the COUNTRY environment variable with a specific ISO / IEC 3166
alpha2 country code and then run crda without arguments. This will send
a regulatory domain for that alpha2 to the kernel.
env_country = getenv("COUNTRY");
if (!env_country) {
fprintf(stderr, "COUNTRY environment variable not set.\n");
return -EINVAL;
}
if (!reglib_is_valid_regdom(env_country)) {
fprintf(stderr, "COUNTRY environment variable must be an "
"ISO ISO 3166-1-alpha-2 (uppercase) or 00\n");
return -EINVAL;
}
but dietpi does not have one set so an invalid argument is returned. (BTW, I don't know C so I'm guessing somewhat)