(resolved) calling CRDA many times and failing on boot.

Having issues with your DietPi installation, or, found a bug? Post it here.
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Fourdee »

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):

Code: Select all

echo -e "blacklist cfg80211" > /etc/modprobe.d/blacklist-cfg80211.conf
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.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

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.

Gordon

[ 2.144996] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 2.159052] Indeed it is in host mode hprt0 = 00001101
[ 2.375593] usb 1-1: New USB device found, idVendor=0424, idProduct=9512
[ 2.389649] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 2.405395] hub 1-1:1.0: USB hub found
[ 2.417668] hub 1-1:1.0: 3 ports detected
[ 2.705066] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ 2.815654] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[ 2.840869] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 2.878388] smsc95xx v1.0.4
[ 2.953582] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-20980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:a5:0d:22
[ 3.075155] usb 1-1.3: new high-speed USB device number 4 using dwc_otg
[ 4.061526] udevd[159]: starting version 175
[ 5.469086] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[ 8.206229] usb 1-1.3: New USB device found, idVendor=0cf3, idProduct=9271
[ 8.220185] usb 1-1.3: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[ 8.234649] usb 1-1.3: Product: USB2.0 WLAN
[ 8.245560] usb 1-1.3: Manufacturer: ATHEROS
[ 8.256349] usb 1-1.3: SerialNumber: 12345
[ 8.517410] cfg80211: Calling CRDA to update world regulatory domain
[ 8.805672] usb 1-1.3: ath9k_htc: Firmware htc_9271.fw requested
[ 8.822353] usbcore: registered new interface driver ath9k_htc
[ 8.921567] cfg80211: World regulatory domain updated:
[ 8.934219] cfg80211: DFS Master region: unset
[ 8.938859] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[ 8.962590] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[ 8.977490] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[ 8.992707] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
[ 9.007753] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[ 9.024552] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[ 9.041143] cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
[ 9.057784] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
[ 9.073152] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
[ 9.185816] usb 1-1.3: ath9k_htc: Transferred FW: htc_9271.fw, size: 51272
[ 9.374355] random: nonblocking pool is initialized
[ 9.431763] ath9k_htc 1-1.3:1.0: ath9k_htc: HTC initialized with 33 credits
[ 11.874176] ath9k_htc 1-1.3:1.0: ath9k_htc: FW Version: 1.3
[ 11.887891] ath9k_htc 1-1.3:1.0: FW RMW support: Off
[ 11.909684] ath: EEPROM regdomain: 0x809c
[ 11.909764] ath: EEPROM indicates we should expect a country code
[ 11.909784] ath: doing EEPROM country->regdmn map search
[ 11.909797] ath: country maps to regdmn code: 0x52
[ 11.909813] ath: Country alpha2 being used: CN
[ 11.909825] ath: Regpair used: 0x52
[ 12.057159] ieee80211 phy0: Atheros AR9271 Rev:1
[ 12.092366] cfg80211: Calling CRDA for country: CN
[ 12.424255] cfg80211: Calling CRDA for country: CN
[ 12.531118] cfg80211: Current regulatory domain intersected:
[ 12.568106] cfg80211: DFS Master region: unset
[ 12.587937] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[ 12.705300] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[ 12.767037] cfg80211: (2457000 KHz - 2482000 KHz @ 25000 KHz), (N/A, 2000 mBm), (N/A)
[ 12.837836] cfg80211: (2474000 KHz - 2482000 KHz @ 8000 KHz), (N/A, 2000 mBm), (N/A)
[ 12.959318] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[ 13.115852] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[ 13.165315] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
[ 13.238277] cfg80211: (57240000 KHz - 59400000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
[ 13.343290] cfg80211: (59400000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
[ 14.633954] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 15.594790] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 32.522476] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[ 36.275830] wlan0: authenticate with 64:66:b3:f4:35:f8
[ 37.293761] wlan0: send auth to 64:66:b3:f4:35:f8 (try 1/3)
[ 37.305613] wlan0: authenticated
[ 37.305918] ath9k_htc 1-1.3:1.0 wlan0: disabling HT/VHT due to WEP/TKIP use
[ 37.315291] wlan0: associate with 64:66:b3:f4:35:f8 (try 1/3)
[ 37.318988] wlan0: RX AssocResp from 64:66:b3:f4:35:f8 (capab=0x411 status=12 aid=1)
[ 37.319090] wlan0: 64:66:b3:f4:35:f8 denied association (code=12)
[ 40.202031] wlan0: authenticate with 64:66:b3:f4:35:f8
[ 41.206304] wlan0: send auth to 64:66:b3:f4:35:f8 (try 1/3)
[ 41.208623] wlan0: authenticated
[ 41.215076] wlan0: associate with 64:66:b3:f4:35:f8 (try 1/3)
[ 41.219395] wlan0: RX AssocResp from 64:66:b3:f4:35:f8 (capab=0x411 status=0 aid=1)
[ 41.243935] wlan0: associated
[ 41.247616] cfg80211: Calling CRDA for country: US
[ 41.326814] cfg80211: Regulatory domain changed to country: US
[ 41.326959] cfg80211: DFS Master region: unset
[ 41.327279] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[ 41.327309] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 3000 mBm), (N/A)
[ 41.327375] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 1700 mBm), (N/A)
[ 41.327404] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2300 mBm), (0 s)
[ 41.327424] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 3000 mBm), (N/A)
[ 41.327440] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 4000 mBm), (N/A)
[ 53.053825] Adding 102396k swap on /var/swap. Priority:-1 extents:1 across:102396k SSFS
root@dietpi:~#
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

Hi,

Where can I find the wpa_supplicant.conf file? In it there should be a line:

# Country code
# The ISO/IEC alpha2 country code for the country in which this device is
# currently operating.
#country=US

My wireless AP router was set to US. If I set that to CA then on boot it goes World,CN,CA. I guess it picks up the country from the router.

Gordon Williams
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

Some more info:

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.

If I go:
root@dietpi:~# iw reg get
country CA:
(2402 - 2472 @ 40), (N/A, 30)
(5170 - 5250 @ 80), (N/A, 17)
(5250 - 5330 @ 80), (N/A, 24), DFS
(5490 - 5730 @ 160), (N/A, 24), DFS
(5735 - 5835 @ 80), (N/A, 30)

now if I set it to JP for instance:
root@dietpi:~# iw reg set JP

root@dietpi:~# iw reg get
country 98:
(2402 - 2472 @ 40), (N/A, 20)
(5170 - 5250 @ 80), (N/A, 17)
(5250 - 5330 @ 80), (N/A, 20), DFS
(5490 - 5710 @ 160), (N/A, 23), DFS

If I try and set it back to CA it stays at "country 98" which an intersection of the valid regulations for both CA and JP
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Fourdee »

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.

Code: Select all

echo -e "blacklist cfg80211" > /etc/modprobe.d/blacklist-cfg80211.conf
Option 2:
Use the DietPi Wheezy image which has none of this crda stuff. We still support Wheezy (i prefer it personally).

Option 3:
Add the following command to a boot script:

Code: Select all

iw reg set CA
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.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

Hi,

Whether or not I have the blacklist, I get the same lsmod shown below:

root@dietpi:~# lsmod
Module Size Used by
ctr 4001 1
ccm 8278 1
snd_bcm2835 22317 0
snd_pcm 92581 1 snd_bcm2835
snd_timer 23454 1 snd_pcm
snd 68161 3 snd_bcm2835,snd_timer,snd_pcm
arc4 1972 2
ath9k_htc 62678 0
ath9k_common 26119 1 ath9k_htc
ath9k_hw 469847 2 ath9k_common,ath9k_htc
ath 22870 3 ath9k_common,ath9k_htc,ath9k_hw
mac80211 622304 1 ath9k_htc
cfg80211 499834 4 ath,ath9k_common,mac80211,ath9k_htc
rfkill 22491 2 cfg80211
bcm2835_gpiomem 3703 0
uio_pdrv_genirq 3690 0
uio 10002 1 uio_pdrv_genirq

Does this match yours?

Maybe I haven't got the black list correctly set?
in file:
/etc/modprobe.d/blacklist-cfg80211.conf
I have on the first line:
blacklist cfg80211

Gordon Williams
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Fourdee »

Hi Gordon,

Code: Select all

cfg80211 499834 4 ath,ath9k_common,mac80211,ath9k_htc
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:

Code: Select all

root@DietPi:~# cat /etc/modprobe.d/blacklist-cfg80211.conf
blacklist cfg80211
Before Blacklist:

Code: Select all

root@DietPi:~# lsmod
Module                  Size  Used by
ecb                     2035  0
md4                     3386  0
nls_utf8                1173  1
cifs                  383469  2
cfg80211              420690  0
rfkill                 16659  2 cfg80211
8192cu                528485  0
sg                     18159  0
bcm2835_gpiomem         2995  0
uio_pdrv_genirq         2966  0
uio                     8235  1 uio_pdrv_genirq
snd_bcm2835            19769  0
snd_pcm                74825  1 snd_bcm2835
snd_timer              18157  1 snd_pcm
snd                    52116  3 snd_bcm2835,snd_timer,snd_pcm
fuse                   81710  1
root@DietPi:~# echo -e "blacklist cfg80211" > /etc/modprobe.d/blacklist-cfg80211.conf
After Blacklist:

Code: Select all

root@DietPi:~# lsmod
Module                  Size  Used by
ecb                     2035  0
md4                     3386  0
nls_utf8                1173  1
cifs                  383469  2
8192cu                528485  0
sg                     18159  0
bcm2835_gpiomem         2995  0
uio_pdrv_genirq         2966  0
uio                     8235  1 uio_pdrv_genirq
snd_bcm2835            19769  0
snd_pcm                74825  1 snd_bcm2835
snd_timer              18157  1 snd_pcm
snd                    52116  3 snd_bcm2835,snd_timer,snd_pcm
fuse                   81710  1
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.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

My blacklist was exactly the same as your for cfg80211.

I have added:
root@dietpi:~# cat /etc/modprobe.d/blacklist-mac80211.conf
blacklist mac80211

I get the same sequence in dmesg.

and

root@dietpi:~# lsmod
Module Size Used by
ctr 4001 1
ccm 8278 1
snd_bcm2835 22317 0
snd_pcm 92581 1 snd_bcm2835
snd_timer 23454 1 snd_pcm
snd 68161 3 snd_bcm2835,snd_timer,snd_pcm
arc4 1972 2
ath9k_htc 62678 0
ath9k_common 26119 1 ath9k_htc
ath9k_hw 469847 2 ath9k_common,ath9k_htc
ath 22870 3 ath9k_common,ath9k_htc,ath9k_hw
mac80211 622304 1 ath9k_htc
cfg80211 499834 4 ath,ath9k_common,mac80211,ath9k_htc
rfkill 22491 2 cfg80211
bcm2835_gpiomem 3703 0
uio_pdrv_genirq 3690 0
uio 10002 1 uio_pdrv_genirq

so the blacklist is not doing it's work.

I had made a post about some other ideas, but something glitched when I submitted it and everything was lost. Will try again.
Gordon
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

Fourdee wrote:[
Option 2:
Use the DietPi Wheezy image which has none of this crda stuff. We still support Wheezy (i prefer it personally).

Option 3:
Add the following command to a boot script:

Code: Select all

iw reg set CA
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.

Gordon
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: (resolved) calling CRDA many times and failing on boot.

Post by Gord_W »

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 ):

KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform",
RUN+="/sbin/crda"

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.

SEE ALSO
iw(8) regulatory.bin(5)

http://wireless.kernel.org/en/developers/Regulatory/

---

in the crda.c file they look for a country code

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)

Gordon
Post Reply