Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, October 29, 2014

Broadcom brcmsmac without channel 12 & 13 - they did it again...

Just updated my EeePC to Ubuntu 14.10 and - bam: no wireless network connection anymore. Channels 12 & 13 are gone again.

This time we take the module parameter approach as in The missing Atheros channels to override the regulatory domain setting read from SPROM (which is US in my case where only 11 channels are allowed), because setting the regulatory domain with

iw reg set <regdom>
 
does not work.

diff -ru brcm80211.orig/brcmsmac/channel.c brcm80211/brcmsmac/channel.c
--- brcm80211.orig/brcmsmac/channel.c    2014-10-15 12:05:43.000000000 +0200
+++ brcm80211/brcmsmac/channel.c    2014-10-25 14:26:51.667082058 +0200
@@ -323,6 +323,8 @@
     return;
 }

+extern const char * get_param_regdom(void);
+
 struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc)
 {
     struct brcms_cm_info *wlc_cm;
@@ -330,6 +332,20 @@
     struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom;
     const char *ccode = sprom->alpha2;
     int ccode_len = sizeof(sprom->alpha2);
+    const char *regdom = get_param_regdom();
+    char regdom_sprom[3];
+    char regdom_param[3];
+
+    strncpy((char *)&regdom_sprom, ccode, 2);
+    regdom_sprom[2] = '\0';
+    brcms_info(wlc->hw->d11core, "Regulatory domain from SPROM: %s\n", regdom_sprom);
+
+    if (strlen(regdom) > 0) {
+        strncpy((char *)&regdom_param, regdom, 2);
+        regdom_param[2] = '\0';
+        brcms_info(wlc->hw->d11core, "Overriding regulatory domain from %s to %s\n" , regdom_sprom, regdom_param);
+        ccode = regdom;
+    }

     wlc_cm = kzalloc(sizeof(struct brcms_cm_info), GFP_ATOMIC);
     if (wlc_cm == NULL)
diff -ru brcm80211.orig/brcmsmac/mac80211_if.c brcm80211/brcmsmac/mac80211_if.c
--- brcm80211.orig/brcmsmac/mac80211_if.c    2014-10-15 12:05:43.000000000 +0200
+++ brcm80211/brcmsmac/mac80211_if.c    2014-10-25 14:20:46.158547508 +0200
@@ -112,6 +112,15 @@
 module_param_named(debug, brcm_msg_level, uint, S_IRUGO | S_IWUSR);
 #endif

+static char *regdom = "";
+module_param(regdom, charp, S_IRUGO);
+MODULE_PARM_DESC(regdom, "Override the regulatory domain from SPROM");
+
+const char * get_param_regdom(void)
+{
+    return regdom;
+}
+
 static struct ieee80211_channel brcms_2ghz_chantable[] = {
     CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS),
     CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS),


This adds the module parameter regdom to brcmsmac. To set this parameter persistently create /etc/modprobe.d/brcmsmac.conf with 

options brcmsmac regdom=<insert your regdom here>

Also it's a good idea to create /etc/modprobe.d/cfg80211.conf with

options cfg80211 ieee80211_regdom=<insert your regdom here>

Have fun!

Saturday, December 31, 2011

The missing channels - this time: Broadcom brcmsmac

In my article The missing Atheros channels I described how to hack the ath5k driver to support the wifi channels 12 and 13. This time I'll show you how to enable the two channels for the Linux Broadcom brcmsmac driver.

The brcmsmac driver sets up the available 2.4 GHz (802.11 b/g) channels with flag

LOCALE_RESTRICTED_SET_2G_SHORT

All you have to do is to change it to

LOCALE_RESTRICTED_NONE

in brcmsmac/channel.c and recompile the driver.

--- brcm80211/brcmsmac/channel.c.orig   2011-12-31 17:25:12.081733667 +0100
+++ brcm80211/brcmsmac/channel.c        2011-12-31 17:25:26.549801913 +0100
@@ -418,7 +418,7 @@
 static const struct locale_info locale_i = {   /* locale i. channel 1 - 13 */
        LOCALE_CHAN_01_11 | LOCALE_CHAN_12_13,
        LOCALE_RADAR_SET_NONE,
-       LOCALE_RESTRICTED_SET_2G_SHORT,
+       LOCALE_RESTRICTED_NONE,
        {QDB(19), QDB(19), QDB(19),
         QDB(19), QDB(19), QDB(19)},
        {20, 20, 20, 0},


After loading the new kernel modules brcmutil & brcmsmac you have to set the regulatory domain with

iw reg set <regdomain>


In dmesg instead of

[...]
cfg80211: Updating information on frequency 2462 MHz for a 20 MHz width channel with regulatory rule:
cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (300 mBi, 2700 mBm)
cfg80211: Disabling freq 2467 MHz
cfg80211: Disabling freq 2472 MHz
cfg80211: Disabling freq 2484 MHz
cfg80211: Regulatory domain changed to country: US
[...]
cfg80211: Found new beacon on frequency: 2472 MHz (Ch 13) on phy3
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 1)
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 2)
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 3)
wlan0: authentication with xx:xx:xx:xx:xx:xx timed out
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 1)
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 2)
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 3)
wlan0: authentication with xx:xx:xx:xx:xx:xx timed out
[...]


you should now see something like

[...]
cfg80211: Updating information on frequency 2467 MHz for a 20 MHz width channel with regulatory rule:
cfg80211: 2400000 KHz - 2483500 KHz @ KHz), (N/A mBi, 2000 mBm)
cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
cfg80211: 2400000 KHz - 2483500 KHz @ KHz), (N/A mBi, 2000 mBm)
cfg80211: Disabling freq 2484 MHz
cfg80211: Regulatory domain changed to country: DE
[...]
cfg80211: Found new beacon on frequency: 2472 MHz (Ch 13) on phy4
wlan0: authenticate with xx:xx:xx:xx:xx:xx (try 1)
wlan0: authenticated
wlan0: associate with xx:xx:xx:xx:xx:xx (try 1)
wlan0: RX AssocResp from xx:xx:xx:xx:xx:xx (capab=0x431 status=0 aid=1)
wlan0: associated
[...]


2467 MHz = channel 12
2472 MHz = channel 13
2484 MHz = channel 14



Update May 12th, 2012:

The following linux kernel commit for 3.0.31, 3.3.4 & 3.2.17 is supposed to fix the
problems with channel 12 & 13:

brcm80211: smac: resume transmit fifo upon receiving frames

commit badc4f07622f0f7093a201638f45e85765f1b5e4 upstream.

There have been reports about not being able to use access-points on channel 12 and 13 or having connectivity issues when these channels were part of the selected regulatory domain. Upon switching to these channels the brcmsmac driver suspends the transmit dma fifos. This patch resumes them upon handing over the first received beacon to mac80211.

Tried this patch, but I still get
wlan0: authentication with xx:xx:xx:xx:xx:xx timed out 

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!