CRDA - cannot set the proper country code

Hey guys!

I bought wifi card which uses Mediatek chip and the following driver: mt76x2u (ALFA AWUS036ACM).

It doesn’t work correctly, connection drops every once in a while and connection is unstable. When I checked the country code with iw reg get I saw it is configured for the US (I’m from the Croatia btw, country code I need is HR).

But I cannot manage to set this code so it actually work and use frequencies which are use here in Croatia. I tried to change it in wireless-regdb but it’s just not pulling the values from that file.
I tried to change the country code while I was using wifi card from tplink because it was also configured for US but also didn’t work. I tried that in Ubuntu half year ago, and it worked properly.

Can someone pleeease help me with this?

Did you follow the instructions here? Network configuration/Wireless - ArchWiki

This may apply in your situation:

Note:

  • Your device may be set to country “00”, which is the “world regulatory domain” and contains generic settings. If this cannot be unset, CRDA may be misconfigured.

However, setting the regdomain may not alter your settings. Some devices have a regdomain set in firmware/EEPROM, which dictates the limits of the device, meaning that setting regdomain in software can only increase restrictions, not decrease them.

4 Likes

How can I check this?

I followed the instructions and only thing I didn’t try is configuring cfg80211 directly because I never did that and I don’t know how to do that.

I get this:

$ iw reg get
global
country US: DFS-FCC
        (2400 - 2472 @ 40), (N/A, 30), (N/A)
        (5150 - 5250 @ 80), (N/A, 23), (N/A), AUTO-BW
        (5250 - 5350 @ 80), (N/A, 23), (0 ms), DFS, AUTO-BW
        (5470 - 5730 @ 160), (N/A, 23), (0 ms), DFS
        (5730 - 5850 @ 80), (N/A, 30), (N/A), AUTO-BW
        (5850 - 5895 @ 40), (N/A, 27), (N/A), NO-OUTDOOR, AUTO-BW, PASSIVE-SCAN
        (57240 - 71000 @ 2160), (N/A, 40), (N/A)

So what should be a solution is this but in this case it simply doesn’t work and I cannot find out why:

 -   Install crda
 -   Uncomment the correct Country Code in /etc/conf.d/wireless-regdom
 -   Reboot the system, because the setting is only read on boot

powerposting or bumping threads is frowned upon. :frowning:

1 Like

Hey guys!

I bought wifi card which uses Mediatek chip and the following driver: mt76x2u (ALFA AWUS036ACM).

It doesn’t work correctly, connection drops every once in a while and connection is unstable. When I checked the country code with iw reg get I saw it is configured for the US (I’m from the Croatia btw, country code I need is HR).

But I cannot manage to set this code so it actually work and use frequencies which are use here in Croatia. I tried to change it in wireless-regdb but it’s just not pulling the values from that file.
I tried to change the country code while I was using wifi card from tplink because it was also configured for US but also didn’t work. I tried that in Ubuntu half year ago, and it worked properly.

Can someone pleeease help me with this?

EDIT: I found that it can be something related to the kernel and that it maybe should be configured with
CONFIG_CFG80211=m. I want to apologize because I asked if someone can help so my other topic related to this got locked, I didn’t know that’s forbidden.

All configs for using wireless-regdb is present

I don’t know what’s the issue and in the meantime, I tried 4.19, 5.15 while I’m actively using 5.10. I don’t want to compare Manjaro with other distros but on my work machine which has *buntu, I configured this without much issues by setting in crda REGDOMAIN=HR. If someone could point me in the right direction I would appreciate it a lot. I don’t know much about kernel compilation and similar stuff but it seems like something is off with the wifi settings

I believe this is an issue local to your system - please review your configs.

Try removing crda then reboot and recheck.

You mean uninstall crda completely?

EDIT: I did that and now I will reboot my machine

# dmesg | grep cfg80211
[37291.802699] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[37291.804463] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'

Even if you get below then you wifi works as it should

$ iw reg get
global
country 00: DFS-UNSET
	(2402 - 2472 @ 40), (N/A, 20), (N/A)
	(2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
	(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, PASSIVE-SCAN
	(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
	(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
	(5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, PASSIVE-SCAN
	(5735 - 5835 @ 80), (N/A, 20), (N/A), PASSIVE-SCAN
	(57240 - 63720 @ 2160), (N/A, 0), (N/A)

phy#0
country 99: DFS-UNSET
	(2402 - 2472 @ 40), (N/A, 20), (N/A)
	(5140 - 5360 @ 80), (N/A, 30), (N/A), PASSIVE-SCAN
	(5715 - 5860 @ 80), (N/A, 30), (N/A), PASSIVE-SCAN

With the crda and wireless-regdb I got this:

$ iw reg get                           
global
country US: DFS-FCC
        (2400 - 2472 @ 40), (N/A, 30), (N/A)
        (5150 - 5250 @ 80), (N/A, 23), (N/A), AUTO-BW
        (5250 - 5350 @ 80), (N/A, 23), (0 ms), DFS, AUTO-BW
        (5470 - 5730 @ 160), (N/A, 23), (0 ms), DFS
        (5730 - 5850 @ 80), (N/A, 30), (N/A), AUTO-BW
        (5850 - 5895 @ 40), (N/A, 27), (N/A), NO-OUTDOOR, AUTO-BW, PASSIVE-SCAN
        (57240 - 71000 @ 2160), (N/A, 40), (N/A)

$ sudo dmesg | grep cfg80211
[    7.917592] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    7.922283] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'

$ sudo iw reg set HR 

$ iw reg get                
global
country 98: DFS-UNSET
        (2400 - 2472 @ 40), (N/A, 20), (N/A)
        (5150 - 5250 @ 100), (N/A, 23), (N/A), AUTO-BW
        (5250 - 5350 @ 100), (N/A, 23), (0 ms), DFS, AUTO-BW
        (5470 - 5725 @ 160), (N/A, 23), (0 ms), DFS
        (5725 - 5730 @ 5), (N/A, 13), (0 ms), DFS
        (5730 - 5850 @ 80), (N/A, 13), (N/A)
        (5850 - 5875 @ 25), (N/A, 13), (N/A), NO-OUTDOOR, PASSIVE-SCAN
        (57240 - 66000 @ 2160), (N/A, 40), (N/A)

and now I will execute these same commands when there is no crda installed and edit this post

EDIT (without crda):

$ iw reg get
global
country 00: DFS-UNSET
        (2402 - 2472 @ 40), (6, 20), (N/A)
        (2457 - 2482 @ 20), (6, 20), (N/A), AUTO-BW, PASSIVE-SCAN
        (2474 - 2494 @ 20), (6, 20), (N/A), NO-OFDM, PASSIVE-SCAN
        (5170 - 5250 @ 80), (6, 20), (N/A), AUTO-BW, PASSIVE-SCAN
        (5250 - 5330 @ 80), (6, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
        (5490 - 5730 @ 160), (6, 20), (0 ms), DFS, PASSIVE-SCAN
        (5735 - 5835 @ 80), (6, 20), (N/A), PASSIVE-SCAN
        (57240 - 63720 @ 2160), (N/A, 0), (N/A)

$ sudo dmesg | grep cfg80211
[sudo] password for igor: 
[    7.978699] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    7.981363] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    7.981495] cfg80211: failed to load regulatory.db

For the reg domain to actually change you need to connect to your ap or take the device down then up

# iw reg get
global
country DK: DFS-ETSI
	(2400 - 2483 @ 40), (N/A, 20), (N/A)
	(5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
	(5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
	(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
	(5725 - 5875 @ 80), (N/A, 13), (N/A)
	(57000 - 66000 @ 2160), (N/A, 40), (N/A)

phy#1
country CN: DFS-FCC
	(2402 - 2482 @ 40), (N/A, 20), (N/A)
	(5170 - 5250 @ 80), (N/A, 23), (N/A), AUTO-BW
	(5250 - 5330 @ 80), (N/A, 23), (0 ms), DFS, AUTO-BW
	(5735 - 5835 @ 80), (N/A, 30), (N/A)
	(57240 - 59400 @ 2160), (N/A, 28), (N/A)
	(59400 - 63720 @ 2160), (N/A, 44), (N/A)
	(63720 - 65880 @ 2160), (N/A, 28), (N/A)

The country is not entirely correct but will suffice is it is Europe reg.domain

# iw dev wlp0s20f0u8 scan | grep Country:
	Country: DE	Environment: Indoor/Outdoor

When I execute iw dev wlp2s0f0u3 scan | grep Country: I get this:

$ sudo iw dev wlp2s0f0u3 scan | grep Country:
        Country: US     Environment: Indoor/Outdoor
        Country: DE     Environment: Indoor/Outdoor
        Country: DE     Environment: Indoor/Outdoor
        Country: HR     Environment: Indoor/Outdoor
        Country: DE     Environment: Indoor/Outdoor
        Country: US     Environment: Indoor/Outdoor

For the reg domain to actually change you need to connect to your ap or take the device down then up

Can you please explain to me the first part of your previous post? I think that could be a solution…

The scan result reflects the response from the scanned networks.

ip link set wlan0 down
iw reg set HR
ip link set wlan0 up

Some useful commands for iw

	phy <phyname> channels
		Show available channels.

	reg reload
		Reload the kernel's regulatory database.

	phy <phyname> reg get
		Print out the devices' current regulatory domain information.

	reg get
		Print out the kernel's current regulatory domain information.

	reg set <ISO/IEC 3166-1 alpha2>
		Notify the kernel about the current regulatory domain.

So is this an issue with my router or my wifi card? I’m little bit confused…

After these 3 commands, nothing changed :frowning_face:

$ sudo ip link set wlp2s0f0u3 down
$ sudo iw reg set HR
$ sudo ip link set wlp2s0f0u3 up
$ iw reg get                                 
global
country US: DFS-FCC
        (2400 - 2472 @ 40), (N/A, 30), (N/A)
        (5150 - 5250 @ 80), (N/A, 23), (N/A), AUTO-BW
        (5250 - 5350 @ 80), (N/A, 23), (0 ms), DFS, AUTO-BW
        (5470 - 5730 @ 160), (N/A, 23), (0 ms), DFS
        (5730 - 5850 @ 80), (N/A, 30), (N/A), AUTO-BW
        (5850 - 5895 @ 40), (N/A, 27), (N/A), NO-OUTDOOR, AUTO-BW, PASSIVE-SCAN
        (57240 - 71000 @ 2160), (N/A, 40), (N/A)

:worried: I don’t know what to do :sweat:

And thank you very much for your effort to help me with this @linux-aarhus I really appreciate it

Well - my device is a TP-LINK WL-722 with v1.x (Atheros)

The kernel takes a short while in recognizing the change - plug/unplug the adapter - to force the change.
If the physical device is phy#0 then this will get the reg domain for the device (again it may not be entirely correct - but it doesn’t really matter much - as long as you are inside the correct region.

iw phy#0 reg get

I also have this one (I used it till now and now would like to use the new one alfa awus036acm) but I also couldn’t configure this with TP-LINK WL-722 - it was always set up to US

Result of the iw phy command:

$ iw phy
Wiphy phy0
        wiphy index: 0
        max # scan SSIDs: 4
        max scan IEs length: 2243 bytes
        max # sched scan SSIDs: 0
        max # match sets: 0
        Retry short limit: 7
        Retry long limit: 4
        Coverage class: 0 (up to 0m)
        Device supports RSN-IBSS.
        Device supports AP-side u-APSD.
        Device supports T-DLS.
        Supported Ciphers:
                * WEP40 (00-0f-ac:1)
                * WEP104 (00-0f-ac:5)
                * TKIP (00-0f-ac:2)
                * CCMP-128 (00-0f-ac:4)
                * CCMP-256 (00-0f-ac:10)
                * GCMP-128 (00-0f-ac:8)
                * GCMP-256 (00-0f-ac:9)
                * CMAC (00-0f-ac:6)
                * CMAC-256 (00-0f-ac:13)
                * GMAC-128 (00-0f-ac:11)
                * GMAC-256 (00-0f-ac:12)
        Available Antennas: TX 0x3 RX 0x3
        Configured Antennas: TX 0x3 RX 0x3
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
        Band 1:
                Capabilities: 0x1ff
                        RX LDPC
                        HT20/HT40
                        SM Power Save disabled
                        RX Greenfield
                        RX HT20 SGI
                        RX HT40 SGI
                        TX STBC
                        RX STBC 1-stream
                        Max AMSDU length: 3839 bytes
                        No DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: No restriction (0x00)
                HT TX/RX MCS rate indexes supported: 0-15
                Bitrates (non-HT):
                        * 1.0 Mbps (short preamble supported)
                        * 2.0 Mbps (short preamble supported)
                        * 5.5 Mbps (short preamble supported)
                        * 11.0 Mbps (short preamble supported)
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                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] (disabled)
                        * 2472 MHz [13] (disabled)
                        * 2484 MHz [14] (disabled)
        Band 2:
                Capabilities: 0x1ff
                        RX LDPC
                        HT20/HT40
                        SM Power Save disabled
                        RX Greenfield
                        RX HT20 SGI
                        RX HT40 SGI
                        TX STBC
                        RX STBC 1-stream
                        Max AMSDU length: 3839 bytes
                        No DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: No restriction (0x00)
                HT TX/RX MCS rate indexes supported: 0-15
                VHT Capabilities (0x318001b0):
                        Max MPDU length: 3895
                        Supported Channel Width: neither 160 nor 80+80
                        RX LDPC
                        short GI (80 MHz)
                        TX STBC
                        RX antenna pattern consistency
                        TX antenna pattern consistency
                VHT RX MCS set:
                        1 streams: MCS 0-9
                        2 streams: MCS 0-9
                        3 streams: not supported
                        4 streams: not supported
                        5 streams: not supported
                        6 streams: not supported
                        7 streams: not supported
                        8 streams: not supported
                VHT RX highest supported: 0 Mbps
                VHT TX MCS set:
                        1 streams: MCS 0-9
                        2 streams: MCS 0-9
                        3 streams: not supported
                        4 streams: not supported
                        5 streams: not supported
                        6 streams: not supported
                        7 streams: not supported
                        8 streams: not supported
                VHT TX highest supported: 0 Mbps
                Bitrates (non-HT):
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                Frequencies:
                        * 5180 MHz [36] (20.0 dBm)
                        * 5200 MHz [40] (20.0 dBm)
                        * 5220 MHz [44] (20.0 dBm)
                        * 5240 MHz [48] (20.0 dBm)
                        * 5260 MHz [52] (20.0 dBm) (radar detection)
                        * 5280 MHz [56] (20.0 dBm) (radar detection)
                        * 5300 MHz [60] (20.0 dBm) (radar detection)
                        * 5320 MHz [64] (20.0 dBm) (radar detection)
                        * 5500 MHz [100] (20.0 dBm) (radar detection)
                        * 5520 MHz [104] (20.0 dBm) (radar detection)
                        * 5540 MHz [108] (20.0 dBm) (radar detection)
                        * 5560 MHz [112] (20.0 dBm) (radar detection)
                        * 5580 MHz [116] (20.0 dBm) (radar detection)
                        * 5600 MHz [120] (20.0 dBm) (radar detection)
                        * 5620 MHz [124] (20.0 dBm) (radar detection)
                        * 5640 MHz [128] (20.0 dBm) (radar detection)
                        * 5660 MHz [132] (20.0 dBm) (radar detection)
                        * 5680 MHz [136] (20.0 dBm) (radar detection)
                        * 5700 MHz [140] (20.0 dBm) (radar detection)
                        * 5720 MHz [144] (disabled)
                        * 5745 MHz [149] (13.0 dBm)
                        * 5765 MHz [153] (13.0 dBm)
                        * 5785 MHz [157] (13.0 dBm)
                        * 5805 MHz [161] (13.0 dBm)
                        * 5825 MHz [165] (13.0 dBm)
                        * 5845 MHz [169] (13.0 dBm) (no IR)
                        * 5865 MHz [173] (13.0 dBm) (no IR)
        Supported commands:
                 * new_interface
                 * set_interface
                 * new_key
                 * start_ap
                 * new_station
                 * new_mpath
                 * set_mesh_config
                 * set_bss
                 * authenticate
                 * associate
                 * deauthenticate
                 * disassociate
                 * join_ibss
                 * join_mesh
                 * remain_on_channel
                 * set_tx_bitrate_mask
                 * frame
                 * frame_wait_cancel
                 * set_wiphy_netns
                 * set_channel
                 * set_wds_peer
                 * tdls_mgmt
                 * tdls_oper
                 * probe_client
                 * set_noack_map
                 * register_beacons
                 * start_p2p_device
                 * set_mcast_rate
                 * connect
                 * disconnect
                 * channel_switch
                 * set_qos_map
                 * set_multicast_to_unicast
        software interface modes (can always be added):
                 * AP/VLAN
                 * monitor
        valid interface combinations:
                 * #{ IBSS } <= 1, #{ managed, AP, mesh point, P2P-client, P2P-GO } <= 2,
                   total <= 2, #channels <= 1, STA/AP BI must match
        HT Capability overrides:
                 * MCS: ff ff ff ff ff ff ff ff ff ff
                 * maximum A-MSDU length
                 * supported channel width
                 * short GI for 40 MHz
                 * max A-MPDU length exponent
                 * min MPDU start spacing
        Device supports TX status socket option.
        Device supports HT-IBSS.
        Device supports SAE with AUTHENTICATE command
        Device supports low priority scan.
        Device supports scan flush.
        Device supports AP scan.
        Device supports per-vif TX power setting
        Driver supports full state transitions for AP/GO clients
        Driver supports a userspace MPM
        Device supports active monitor (which will ACK incoming frames)
        Device supports configuring vdev MAC-addr on create.
        max # scan plans: 1
        max scan plan interval: -1
        max scan plan iterations: 0
        Supported TX frame types:
                 * IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
        Supported RX frame types:
                 * IBSS: 0x40 0xb0 0xc0 0xd0
                 * managed: 0x40 0xb0 0xd0
                 * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * mesh point: 0xb0 0xc0 0xd0
                 * P2P-client: 0x40 0xd0
                 * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * P2P-device: 0x40 0xd0
        Supported extended features:
                * [ VHT_IBSS ]: VHT-IBSS
                * [ RRM ]: RRM
                * [ FILS_STA ]: STA FILS (Fast Initial Link Setup)
                * [ CQM_RSSI_LIST ]: multiple CQM_RSSI_THOLD records
                * [ CONTROL_PORT_OVER_NL80211 ]: control port over nl80211
                * [ TXQS ]: FQ-CoDel-enabled intermediate TXQs
                * [ AIRTIME_FAIRNESS ]: airtime fairness scheduling
                * [ AQL ]: Airtime Queue Limits (AQL)
                * [ SCAN_RANDOM_SN ]: use random sequence numbers in scans
                * [ SCAN_MIN_PREQ_CONTENT ]: use probe request with only rate IEs in scans
                * [ CONTROL_PORT_NO_PREAUTH ]: disable pre-auth over nl80211 control port support
                * [ DEL_IBSS_STA ]: deletion of IBSS station support
                * [ SCAN_FREQ_KHZ ]: scan on kHz frequency support
                * [ CONTROL_PORT_OVER_NL80211_TX_STATUS ]: tx status for nl80211 control port support

Is your system locale set to US or to HR?

Since the reg.domain is connected to the kernel - this may have effect on the domain

It’s combined - because I like to have everything on English…

if you need output from some command, just say and I’ll do that

$ iw phy0 reg get
phy#0
country DE: DFS-UNSET
....
# iw reg set DK
$ iw reg get
global
country DK: DFS-ETSI
	(2400 - 2483 @ 40), (N/A, 20), (N/A)
	(5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
	(5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
	(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
	(5725 - 5875 @ 80), (N/A, 13), (N/A)
	(57000 - 66000 @ 2160), (N/A, 40), (N/A)

phy#0 (self-managed)
country DE: DFS-UNSET
....