Sunday, September 19, 2010

The missing Atheros channels

Yesterday I've tried to setup my Atheros based wireless PCMCIA card D-Link DWL-G650 to communicate with my WLAN router Netgear WGR614v9. The WLAN is configured to use channel 13 - but no luck to connect to the router, because there are only 11 channels present:

ath0     11 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz

The problem seems to be common as a search with Google shows.

When the driver for the wireless card is loaded, it reads the regdomain from the EEPROM of the wireless card and sets the allowed channels for the region. Unfortunately this does not seem to work, at least for me with the madwifi driver.

So I looked for a way to change the regdomain in EEPROM of the card:

  • It seems to be possible with a tool called RCU (Tamos) on another OS. Tried it, but it was a mess to setup the tool and changing the regdomain didn't work.
  • There is a tool called ath_info that allows to change the regdomain. Didn't work (at least when the madwifi driver is used?!).

Now I tried the ath5k driver which now finally works (hooray!) with my DWL-G650 (Kernel 2.6.35.4) - your experience may vary. Earlier versions did not like my DWL-G650.

ath5k is a full open source driver (compared to madwifi that uses a hardware abstraction layer (HAL) that's only available as binaries) and there's a patch to override the regdomain that the driver will use. The patch can be found here. It introduces a new module parameter override_eeprom_regdomain for ath5k.

You can provide
  • either a country code. This is indicated by setting the highest bit of the 16 bit integer (COUNTRY_ERD_FLAG) or short: you have to provide 32768 + country code, or in hex: 0x8000 + country code
  • or a world regulatory domain

Setting a country code currently does not work (Debian Squeeze), as ist requires a user space tool that's supposed to be packaged as wireless-regdb. The package provides an agent called CRDA with a database that tells the driver the channels that are permitted for different countries.

So the only way to get access to the lost channels is to provide a world regulatory domain. The world regulatory domains currently have values that range from 0x60 to 0x6b. Choose the one that suits your needs according to kernel source file drivers/net/wireless/ath/regd.c. I've chosen 0x68 (EU1_WORLD) that allows channels 1 to 13 for 801.11b/g and all channels for 802.11a:

/* Can be used by 0x67, 0x6A and 0x68 */
static const struct ieee80211_regdomain ath_world_regdom_67_68_6A = {
 .n_reg_rules = 4,
 .alpha2 =  "99",
 .reg_rules = {
  ATH9K_2GHZ_CH01_11,
  ATH9K_2GHZ_CH12_13,
  ATH9K_5GHZ_ALL,
 }
;

I've put a file called ath5k.conf with
options ath5k override_eeprom_regdomain=0x68
in /etc/modprobe.d that sets regdomain 0x68 and now I'm able to use my WLAN on channel 13!