# [ath9k] how to change country code via crda?

## Bialy

I using Atheros AR9280 card (in AP mode):

```
ieee80211 phy0: Atheros AR9280 Rev:2 mem=0xffffc90010ea0000, irq=16 

 Network controller: Atheros Communications Inc. AR928X Wireless Network Adapter (PCI-Express) (rev 01)
```

With kernel driver:

```
linux-3.8.6-hardened 

 CONFIG_WLAN=y 

 CONFIG_ATH9K_HW=y 

 CONFIG_ATH9K_COMMON=y 

 # CONFIG_ATH9K_BTCOEX_SUPPORT is not set 

 CONFIG_ATH9K=y 

 CONFIG_ATH9K_PCI=y 

 CONFIG_ATH9K_AHB=y 

 # CONFIG_ATH9K_DEBUGFS is not set 

 CONFIG_ATH9K_RATE_CONTROL=y 

 # CONFIG_ATH9K_HTC is not set 

 CONFIG_FIB_RULES=y 

 CONFIG_WIRELESS=y 

 CONFIG_WEXT_CORE=y 

 CONFIG_WEXT_PROC=y 

 CONFIG_CFG80211=y 

 # CONFIG_NL80211_TESTMODE is not set 

 # CONFIG_CFG80211_DEVELOPER_WARNINGS is not set 

 # CONFIG_CFG80211_REG_DEBUG is not set 

 CONFIG_CFG80211_DEFAULT_PS=y 

 # CONFIG_CFG80211_DEBUGFS is not set 

 # CONFIG_CFG80211_INTERNAL_REGDB is not set 

 CONFIG_CFG80211_WEXT=y 

 # CONFIG_LIB80211 is not set 

 CONFIG_MAC80211=y 

 CONFIG_MAC80211_HAS_RC=y 

 CONFIG_MAC80211_RC_MINSTREL=y 

 CONFIG_MAC80211_RC_MINSTREL_HT=y 

 CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y 

 CONFIG_MAC80211_RC_DEFAULT="minstrel_ht" 

 # CONFIG_MAC80211_MESH is not set 

 CONFIG_MAC80211_LEDS=y
```

And I can't change country code:

```
country 00:

        (2402 - 2472 @ 40), (6, 20)

        (2457 - 2482 @ 40), (6, 20), PASSIVE-SCAN, NO-IBSS

        (2474 - 2494 @ 20), (6, 20), NO-OFDM, PASSIVE-SCAN, NO-IBSS

        (5170 - 5250 @ 40), (6, 20), PASSIVE-SCAN, NO-IBSS

        (5735 - 5835 @ 40), (6, 20), PASSIVE-SCAN, NO-IBSS

        (57240 - 63720 @ 2160), (N/A, 0)
```

I have installed all requirements:

```
net-wireless/crda-1.1.2-r3

net-wireless/wireless-regdb-20130213

virtual/libc-0

dev-libs/libnl-3.2.14:3  USE="-doc -static-libs -utils"

sys-fs/udev-200  USE="acl firmware-loader kmod openrc -doc -gudev -hwdb -introspection -keymap (-selinux) -static-libs"

regulatory.bin file
```

regulatory.bin have entry about PL:

```
country PL:

<------>(2402.000 - 2482.000 @ 40.000), (N/A, 20.00)

<------>(5170.000 - 5250.000 @ 40.000), (N/A, 20.00)

<------>(5250.000 - 5330.000 @ 40.000), (N/A, 20.00), DFS

<------>(5490.000 - 5710.000 @ 40.000), (N/A, 27.00), DFS

<------>(57240.000 - 65880.000 @ 2160.000), (N/A, 40.00), NO-OUTDOOR

```

When I trying change country code via crda, I got:

```
COUNTRY="PL" crda

Failed to set regulatory domain: -7
```

Using "iw reg set PL" I don't get any error (country code doesn't change).

Driver also have information about PL:

```
cat /usr/src/linux/drivers/net/wireless/ath/regd.h | grep 616

        CTRY_POLAND = 616,
```

I thing this is error between crda <--> udev, because monitoring don't give me any messages:

```
udevadm monitor --environment kernel
```

----------

## micmac

Hello,

here it works fine when wpa_supplicant sets the country. In wpa_supplicant.conf I got:

```
country=DE
```

----------

## turtles

[too much coffee rant] Now if you for any reason get a hosed udev networking quits working.

The regulatory compliance stuff is unneeded nanny cruft that broke ath9k.[/end too much coffee rant]

I never got ath9k to work correctly with mismatched wireless gear after the crda thing came out.

Roll back to pre regulatory 2.35 kernels with old live usb and it works fine.

I had a old post here that might be of help.

I ended up patching the kernel commenting out all the regulatory domain stuff.

See this discussion here:

http://www.mail-archive.com/ath9k-devel@lists.ath9k.org/msg08880.html

----------

## Bialy

 *micmac wrote:*   

> Hello,
> 
> here it works fine when wpa_supplicant sets the country. In wpa_supplicant.conf I got:
> 
> ```
> ...

 wpa_supplicant and AP mode?

Never heard. I using hostapd to create AP.

```
cat /etc/hostapd/hostapd.conf | grep PL

country_code=PL

```

 *turtles wrote:*   

> [too much coffee rant] Now if you for any reason get a hosed udev networking quits working.
> 
> The regulatory compliance stuff is unneeded nanny cruft that broke ath9k.[/end too much coffee rant]

 This is fault ath9k or crda?

 *turtles wrote:*   

> I never got ath9k to work correctly with mismatched wireless gear after the crda thing came out.
> 
> Roll back to pre regulatory 2.35 kernels with old live usb and it works fine.

  Eeee... NO!  :Wink: 

 *turtles wrote:*   

> I had a old post here that might be of help.
> 
> I ended up patching the kernel commenting out all the regulatory domain stuff.
> 
> See this discussion here:
> ...

 I saw manually way, but it is so dirty!  :Evil or Very Mad: 

I thought that exist some better way...

----------

## turtles

 *Bialy wrote:*   

> 
> 
>  *turtles wrote:*   [too much coffee rant] Now if you for any reason get a hosed udev networking quits working.
> 
> The regulatory compliance stuff is unneeded nanny cruft that broke ath9k.[/end too much coffee rant] This is fault ath9k or crda?
> ...

 

cdra I believe.

----------

