OpenWrt Forum Archive

Topic: how to set country (regulatory domain) with ath9k ???

The content of this topic has been archived on 2 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

system: Ubiquity RouterStation with Mikrotik R52n dual band PCI, OpenWRT Trunk r17720
problem: during boot as default the US is set by cfg80211;
neither the country setting in //etc/config/wireless, nor the command "iw reg set XX" (XX is two alphanumeric capitals) manage to change the regulatory domain.

What is the procedure to change the regulatory domain ?

can give the answer now myself after some reading at linuxwireless.org about the ath9k drivers.
Essential is to install the crda package, or when compiling OpenWRT to select in menuconfig 'crda' in the ' Network' section.
It installs among other things the regulatory database that must be present for consultation when the 'iw reg set XX' command is issued.
Unfortunately there is no error message that hints at crda when the database is absent and the iw reg set command is issued; the command is
accepted but nothing done.

So your not getting a kernel panic and lockup after bringing up the R52N Card? I've tested the latest trunk and 2/3 older versions and all is the same. As soon as I wifi up the card it crashes the kernel. Can you provide any insight on how you have your's working?

am not seeing kernel panic but do still have some problems when using it as an Access Point (AP) with psk authentication because there seems to be a problem with hostapd giving out wrong commands.
In sta mode it does work with psk. In AP mode only without psk/wpa, having uninstalled hostapd.
So perhaps your problem lies there also. Perhaps another difference, I am not using bridging, only routing.

network:
config 'interface' 'loopback'
    option 'ifname' 'lo'
    option 'proto' 'static'
    option 'ipaddr' '127.0.0.1'
    option 'netmask' '255.0.0.0'

config 'interface' 'lan'
    option 'ifname' 'eth0'
#    option 'type' 'bridge'
    option 'proto' 'static'
    option 'netmask' '255.255.255.0'
    option 'dns' '192.168.111.1'
    option 'gateway' '192.168.111.1'
    option 'ipaddr' '192.168.111.20'

config 'interface' 'wan'
    option 'ifname' 'eth1'
#    option 'type' 'bridge'
    option 'proto' 'static'
    option 'netmask' '255.255.255.0'
    option 'ipaddr' '192.168.112.20'

config 'interface' 'wifi0'
    option 'ifname' 'wlan0'
#    option 'type' 'bridge'
    option 'proto' 'static'
    option 'netmask' '255.255.255.0'
    option 'ipaddr' '192.168.20.30'

wireless:
config wifi-device    wlan0
      option type    mac80211    # broadcom, atheros, mac80211
      option country    PT        # us, uk, fr, de, etc.
      option channel    100        # 1-14
      option distance    7000        # 1-n
      option hwmode    11a        # 11b, 11g, 11a, 11bg (atheros, mac80211)
      option rxantenna    1        # 0,1,2 (atheros, broadcom)
      option txantenna    1        # 0,1,2 (atheros, broadcom)
      option txpower    21        #  transmission power in dBm
 
  config wifi-iface
      option network    wifi0        # wifi0-wifin, name given in network definition
      option device    wlan0        # wlan0 - wlann
      option mode    sta        # ap, sta, adhoc, monitor, or wds
      option ssid    SSID_test    # ssid name
      option encryption    psk        # none, psk, psk2, wpa, wpa2
      option key    <????>    # encryption key
      option hidden    0        # 0,1
      option isolate    0        # 0,1

installed packages:
base-files - 31-r17779 -
busybox - 1.13.4-1 -
crda - 1.1.0-1 -
dnsmasq - 2.50-1 -
firewall - 1-8 -
hostapd - 0.6.9-1 -
hostapd-utils - 0.6.9-1 -
hotplug2 - 1.0-beta-1 -
ip - 2.6.29-1-1 -
iptables - 1.4.4-2 -
iptables-mod-conntrack - 1.4.4-2 -
iptables-mod-conntrack-extra - 1.4.4-2 -
iptables-mod-extra - 1.4.4-2 -
iptables-mod-nat - 1.4.4-2 -
iptables-mod-nat-extra - 1.4.4-2 -
iptables-utils - 1.4.4-2 -
iw - 0.9.17-1 -
kernel - 2.6.30.7-1 -
kmod-ath - 2.6.30.7+2009-08-20-2 -
kmod-ath9k - 2.6.30.7+2009-08-20-2 -
kmod-button-hotplug - 2.6.30.7-1 -
kmod-crc-ccitt - 2.6.30.7-1 -
kmod-crypto-aes - 2.6.30.7-1 -
kmod-crypto-arc4 - 2.6.30.7-1 -
kmod-crypto-core - 2.6.30.7-1 -
kmod-input-core - 2.6.30.7-1 -
kmod-input-gpio-buttons - 2.6.30.7-1 -
kmod-input-polldev - 2.6.30.7-1 -
kmod-ipt-conntrack - 2.6.30.7-1 -
kmod-ipt-conntrack-extra - 2.6.30.7-1 -
kmod-ipt-core - 2.6.30.7-1 -
kmod-ipt-extra - 2.6.30.7-1 -
kmod-ipt-nat - 2.6.30.7-1 -
kmod-ipt-nat-extra - 2.6.30.7-1 -
kmod-leds-gpio - 2.6.30.7-1 -
kmod-mac80211 - 2.6.30.7+2009-08-20-2 -
kmod-ppp - 2.6.30.7-1 -
kmod-pppoe - 2.6.30.7-1 -
kmod-scsi-core - 2.6.30.7-1 -
kmod-usb-core - 2.6.30.7-1 -
kmod-usb-ohci - 2.6.30.7-1 -
kmod-usb-storage - 2.6.30.7-1 -
kmod-usb-uhci - 2.6.30.7-1 -
kmod-usb2 - 2.6.30.7-1 -
libc - 0.9.30.1-31 -
libgcc - 4.1.2-31 -
libiptc - 1.4.4-2 -
liblua - 5.1.4-5 -
libnl-tiny - 0.1-1 -
libopenssl - 0.9.8k-2 -
librt - 0.9.30.1-31 -
libuci - 0.7.5-1 -
libuci-lua - 0.7.5-1 -
libusb - 0.1.12-2 -
libxtables - 1.4.4-2 -
lua - 5.1.4-5 -
mtd - 10 -
openssh-client - 5.2p1-1 -
openssh-client-utils - 5.2p1-1 -
openssh-server - 5.2p1-1 -
openssh-sftp-client - 5.2p1-1 -
openssh-sftp-server - 5.2p1-1 -
opkg - 215-2 -
pciutils - 3.1.4-1 -
ppp - 2.4.4-3 -
ppp-mod-pppoe - 2.4.4-3 -
tc - 2.6.29-1-1 -
uci - 0.7.5-1 -
ucitrigger - 0.7.5-1 -
udev - 142-1 -
udevtrigger - 106-1 -
usbutils - 0.86-1 -
wget - 1.11.4-1 -
wireless-tools - 29-4 -
wpa-cli - 0.6.9-2 -
wpa-supplicant - 0.6.9-2 -
zlib - 1.2.3-5 -
zoneinfo-europe - 2009c-2 -

(Last edited by doddel on 30 Sep 2009, 17:03)

I'll try and play with settings, but this is what happens the moment the card starts to come online in the RouterStation,


PCI error 1 at PCI addr 0x10007820
Data bus error, epc == 83b890b8, ra == 83b890b0
Oops[#1]:
Cpu 0
$ 0   : 00000000 00000000 deadc0de ffffffc7
$ 4   : b0009944 00009944 00000009 83b68000
$ 8   : 00007890 00020000 00040100 00040000
$12   : 83b68000 00000000 000000c0 0000a3b4
$16   : ffffff00 83b68000 83b685a8 83b685aa
$20   : 00001000 83b684c0 00000020 83b685b0
$24   : 00000000 2ab194a0
$28   : 8386e000 8386fcb8 7fa9a128 83b890b0
Hi    : 0000000a
Lo    : 17980000
epc   : 83b890b8 0x83b890b8
    Not tainted
ra    : 83b890b0 0x83b890b0
Status: 1000f403    KERNEL EXL IE
Cause : 1080001c
PrId  : 00019374 (MIPS 24Kc)
Modules linked in: nf_nat_tftp nf_conntrack_tftp nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_conntrack_ftp ipt_MASQUERADE iptable_nat nf_nat xt_NOTRACK iptable_raw xt_state nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack pppoe pppox ipt_REJECT xt_TCPMSS ipt_LOG xt_multiport xt_mac xt_limit iptable_mangle iptable_filter ip_tables xt_tcpudp x_tables ppp_async ppp_generic slhc ath9k ath mac80211 cfg80211 crc_ccitt arc4 aes_generic deflate ecb cbc button_hotplug input_polldev input_core
Process ifconfig (pid: 549, threadinfo=8386e000, task=838c1b00, tls=00000000)
Stack : 00000000 00000000 00000000 00000000 00000000 00000000 00000017 83b68104
        00000001 20000000 83b68000 83a94914 83b68104 00000000 00000000 8386fd70
        7fa9a128 83b85f04 00000000 00000001 00000000 800d824c 00000107 8386fe30
        83b68104 83a94914 83bbbc5c 83a941c0 83a949cc 8386fd72 8386fd74 83b9862c
        800ab9cc 00000000 802be290 802be290 83a941c0 ffffff82 8383fb00 8383f800
        ...
Call Trace:[<83b85f04>] 0x83b85f04
[<800d824c>] 0x800d824c
[<83b9862c>] 0x83b9862c
[<800ab9cc>] 0x800ab9cc
[<83b4c5b0>] 0x83b4c5b0
[<800acd40>] 0x800acd40
[<800a989c>] 0x800a989c
[<801d54b0>] 0x801d54b0
[<801d095c>] 0x801d095c
[<801d30d4>] 0x801d30d4
[<801d30a4>] 0x801d30a4
[<801d3990>] 0x801d3990
[<80220d0c>] 0x80220d0c
[<80220adc>] 0x80220adc
[<801d45c8>] 0x801d45c8
[<801d45bc>] 0x801d45bc
[<801c3f84>] 0x801c3f84
[<800da988>] 0x800da988
[<800daf50>] 0x800daf50
[<801c27a4>] 0x801c27a4
[<800cf124>] 0x800cf124
[<801c26b0>] 0x801c26b0
[<801c2830>] 0x801c2830
[<800db010>] 0x800db010
[<80062504>] 0x80062504
[<80062504>] 0x80062504


Code: 34059944  92460047  2403ffc7 <00431024> 00063040  30c60038  00463025  02202021  0cee0397
Disabling lock debugging due to kernel taint
Kernel panic - not syncing: Fatal exception in interrupt

you cannot exclude a hardware error in the card or board. What I see in dmesg: (messages relevant for pci)

Linux version 2.6.30.7 (xxx@yyy) (gcc version 4.1.2) #6 Mon Sep 28 11:03:35 WEST 2009
prom: fw_arg0=00000002, fw_arg1=80050028, fw_arg2=80050000, fw_arg3=00000001
MyLoader: sysp=00000000, boardp=00000000, parts=ace50014
console [early0] enabled
CPU revision is: 00019374 (MIPS 24Kc)
Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz
...
pci 0000:00:00.0: reg 10 32bit mmio: [0x000000-0xfffffff]
pci 0000:00:00.0: reg 14 io port: [0x00-0xff]
pci 0000:00:00.0: supports D1 D2
pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot
pci 0000:00:00.0: PME# disabled
pci 0000:00:11.0: reg 10 32bit mmio: [0x000000-0x00ffff]
pci 0000:00:11.0: PME# supported from D0 D3hot
pci 0000:00:11.0: PME# disabled
PCI: mapping irq 48 to pin1@0000:00:11.0
...
cfg80211: Using static regulatory domain info
cfg80211: Regulatory domain: US
    (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
    (2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2700 mBm)
    (5170000 KHz - 5190000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
    (5190000 KHz - 5210000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
    (5210000 KHz - 5230000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
    (5230000 KHz - 5330000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
    (5735000 KHz - 5835000 KHz @ 40000 KHz), (600 mBi, 3000 mBm)
cfg80211: Calling CRDA for country: US
cfg80211: Regulatory domain changed to country: US
    (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
    (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm)
    (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm)
    (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
    (5490000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
    (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm)
...
PCI: Enabling device 0000:00:11.0 (0000 -> 0002)
ath: EEPROM regdomain: 0x0
ath: EEPROM indicates default country code should be used
ath: doing EEPROM country->regdmn map search
ath: country maps to regdmn code: 0x3a
ath: Country alpha2 being used: US
ath: Regpair used: 0x3a
phy0: Selected rate control algorithm 'ath9k_rate_control'
Registered led device: ath9k-phy0::radio
Registered led device: ath9k-phy0::assoc
Registered led device: ath9k-phy0::tx
Registered led device: ath9k-phy0::rx
phy0: Atheros AR9280 MAC/BB Rev:2 AR5133 RF Rev:d0: mem=0xb0000000, irq=48
...
I then need to give the command 'wifi' to establish the radio link (station mode / psk )

_____________
would try some other miniPCI to check the RouterStation c.q. try the R52n in another system just to eliminate possible causes besides firmware.

(Last edited by doddel on 1 Oct 2009, 19:23)

That's what I was thinking, however I tried yesterday's build right from OpenWRT. I even have two RouterStation's I just got and even two R52n cards. I copied your wireless and network config just for the heck of it and made sure I had all the packages you do. As soon as I reboot or type wifi up it does the above error. Driving me crazy. My boot looks very similar to yours, but when it get's past some info on the wirelss and looks like it's going to bring up the card it just kills the Router. Atleast I have hope in the fact it's working for you. Just have no idea why it's not working out for me like it is for you.

Thanks for your help.

hi,
I've put the image I compiled, and that works here, on a server. You can give it a try to see if that stabilizes your system:

http://www.dorpstraat.com/OpenWrt/ubnt.bin

(for Router-Station ar71xx and R54n mini-PCI ar92xx)

If it works the question remains what is causing the panics in your build !

After firstboot it will take a while for the rsa keys to be calculated by openssh.
But you can telnet in, until you have given the system a password. Only define the password after sshd has come up and all the firstboot things are over.
Use top or ps -A to see progress via telnet.
Then afterwords you need to use ssh. With FileZilla (linux) or winscp (windows)  you can easily edit and manage the OpenWrt system files on the board.

Success !

(Last edited by doddel on 3 Oct 2009, 09:47)

Thank you for taking the time to help me with this. I downloaded and flashed that .bin file. I have a serial connection to the RouterStation so I thought all was going good. I went into thet /etc/config/wireless file and commented out the disable line. I then did /etc/init.d/networking restart and boom, same error as above. Now I'm really thinking I've got two bad cards or two bad RouterStation's, that's crazy. I do have a third older RouterStation so I will try it later on it. I couldn't possibly have 3 bad RS and at that point it must be the cards or something.

Sorry to read that it does not work for you. One thought that came up is that perhaps the problem is in one of your R52n cards and that by using it on different RS it has also done damage there.

doddel wrote:

I do nor use dropbear, but the openssh packages instead. After firstboot it will take a while for the rsa keys to be calculated by openssh.
But you can telnet in, until you have given the system a password. Only define the password after sshd has come up and all the firstboot things are over.
Use top or ps -A to see progress via telnet.
Then afterwords you need to use ssh. I find it handy this way because of the sftp server. With FileZilla (linux) or winscp (windows)  you can easily edit and manage the OpenWrt system files on the board.

Success !

Dropbear can also do SFTP. No need to install OpenSSH.

(Last edited by Dogge on 3 Oct 2009, 09:27)

@Dogge
Thanks for pointing that out ! Have removed my earlier comment about dropbear and will give it a try again in a next compilation.
Tried it in the early days of OpenWrt, some years ago now, and then it did not work for me as sftp server.

@foxtroop11:
Another idea came up as a possible source of the problem, the power supply.
From your description it seems that everything is ok until you activate wireless in the configuration. One thing that than happens is that the Atheros radio circuit on the R54n board starts to draw current.
If the input voltage circuit cannot deliver instantaniously the needed additional power and brings the switrched mode power supply on the RS out of its input voltage working range, the supply of the CPU would see a disruption, seen as crash.
Just an hypothesis but worth checking ! Test the system from a 'hard' voltage source, preferably not a switched mode or at least one with an electrolytich capacitor put in parallel at the output to be able to supply brief current peaks.  If you have an oscilloscope, monitor the input voltage and the 3.3 V made by the RS when you activate wireless. Just for the test you may feed it from a 12 V battery.

You may get less feedback to your problem because this has nothing to do with the original topic of setting a country code.

(Last edited by doddel on 4 Oct 2009, 08:19)

Ok, sorry for the long time on the response.

It's very possible that I actually have 2 bad cards. I now have 2 other types of N cards, both based on AR5416 I think it is. One is a TP-Link and the other is a no name A/B/G/N card and they both work perfect with no issues. My power supply is a 24V POE, don't think that's the issue. As soon as the RouterStation boots and before the wireless even comes up, it appears it's right at the moment the card starts to kick in gear it locks up the system. I'm waiting for another card to try and since your's is working it must be the card.

The discussion might have continued from here.