Friday, December 26, 2008

It works! Broadcom Official Wireless driver (wl) with hidden networks!

If you are using the official Broadcom hybrid wireless driver, either manually compiled or downloaded the one available for openSUSE from Packman, here is a quick fix you can try if you are experiencing problems connecting to hidden wireless networks.

I have a Broadcom Corporation BCM4312 802.11b/g.
You can find which one you have using
/sbin/lspci | grep Broadcom

My wireless network uses WPA2 (WPA-PSK) with hidden SSID. My kernel is 2.6.27 and Network Manager 0.7. A description of the bug (or what I think is the bug) follows:

Description of the bug:

After spending long hours going through the source code for Network Manager, wpa_supplicant and the Broadcom driver itself, I have narrowed down the buggy part to the driver. The problem seems to lie in Broadcom's driver. It does not support 'scan_capa'. So to add this support, you can recompile the driver from the source RPM from Packman along with this additional patch.

diff -uNr hybrid-portsrc-x86-32_5_10_27_11/src/wl/sys/wl_iw.c hybrid-portsrc-x86-32_5_10_27_11_new/src/wl/sys/wl_iw.c
--- hybrid-portsrc-x86-32_5_10_27_11/src/wl/sys/wl_iw.c 2008-12-05 14:41:46.000000000 -0500
+++ hybrid-portsrc-x86-32_5_10_27_11_new/src/wl/sys/wl_iw.c 2008-12-26 11:34:11.000000000 -0500
@@ -580,6 +580,7 @@
range->enc_capa |= IW_ENC_CAPA_CIPHER_TKIP;
range->enc_capa |= IW_ENC_CAPA_CIPHER_CCMP;
range->enc_capa |= IW_ENC_CAPA_WPA2;
+ range->scan_capa = IW_SCAN_CAPA_ESSID;
#endif

return 0;

If you are manually compiling, just make the changes specified by the patch i.e. add this line 'range->scan_capa = IW_SCAN_CAPA_ESSID;' to 'src/wl/sys/wl_iw.c' at the specified place.

Network Manager now uses AP_SCAN 1 for the wl driver, as the driver now reports that it supports SSID scans (scan_capa 0x01). This seems to work for me and Network manager now connects easily to my hidden network without failing 10 times before connecting, like it used to do before. In fact, using AP_SCAN 2, the original wl driver should not even have connected but association is successful even though the connection fails. Network manager caches the SSID of the network and recognizes it next time for which then it uses AP_SCAN 1. Hence the driver sometimes connects successfully after a lot of unsuccessful attempts.

Please let me know if this patch works for you. If something is wrong with this patch or if you want to suggest changes or have anything to say, please feel free to leave a comment.

21 comments:

Anonymous said...

Thank you very much! Finally I can connect to hidden networks using Fedora 10 on my new IdeaPad S10e.

Xor said...

My pleasure! Glad to know this patch works for you too! I was getting the impression that the patch works for me alone.

Anonymous said...

Thanks for this. I'm going to include it in the Fedora RPM and am trying to get Broadcom to include it upstream too.

Anonymous said...

thanks for the patch (i maintain wl package in packman), maybe next time you may what to send other patches to packager too ;)

Anonymous said...

Thanks for working on this. Seeing that it's possible to add features to the released source code makes me wonder if it's possible to add additional mode functionality. I'd like to be able to use "master" (or "access points") mode, but it's currently not supported. Do you think it's possible?

:~$ sudo iwconfig wlan0 mode master
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Invalid argument.

Xor said...

I am sorry but I do not have any idea about "master" or "access points" mode. I can't help you much there.

The above patch, I think, does not add new features. It only makes the driver advertise it's SSID scan capability. The feature itself still needs to be supported by the driver, which we can only guess, because of the binary blob.

Anonymous said...

I don't think i quite understand the methood of patching...

I'm using an Intel Wireless 4965 AGN adapter.

The drivers are the ones installed with SUSE by default.

If you could make a tutorial explaining step by step what you did would be great, cause a lot of people have this problem, and not just in SUSE... Ubuntu and Fedora also, and all the distros that use Network Manager ...

Xor said...

The above patch is for Broadcom devices only and it's not applicable for Intel adapters.

SUSE users who use the packman repository for getting the official broadcom-wl driver package already have this patch included (thanks to the packager Andrea Florio).

For others, you just have to add the line:

range->scan_capa = IW_SCAN_CAPA_ESSID;

to the file "wl_iw.c" in the driver source after these three lines:

range->enc_capa|=IW_ENC_CAPA_CIPHER_TKIP;
range->enc_capa|=IW_ENC_CAPA_CIPHER_CCMP;
range->enc_capa|=IW_ENC_CAPA_WPA2;

and compile the driver. Hope this clears everything...

Anonymous said...

So i just have to add that line in the file. That i can do fine...

But i have no idea on how to compile the drivers... Can you give a heads up, please?

Xor said...

I would not recommend manually compiling since it can be very difficult time consuming process especially if you haven't done it before. But if you still want to compile the driver manually, here are some links I found on openSUSE forums that may help you with this:
openSUSE forums post 1
openSUSE forums post 2
Broadcom instructions

Anonymous said...

I guess that there is no way to compile automaticly, so...
Also, i understand a lot about computers, i'm just new to Linux...
I think i might be able to do it with those links you provided...

Thanks

Anonymous said...

Thanks so much, it works great for me now. I've been looking for a solution for days now.
I'm using Broadcom 4312 on xubuntu 8.10, with NetworkManager.

Dom

Anonymous said...

Great! It worked for me too!
Good Job!

Anonymous said...

Followed your step to alter wl_iw.c and then build the driver.
Nope ,doesn't work for me. Still can't connect to hidden ssid. Only connect to unhidden ssid. I use zenwalk 6.

Live said...

Hi, can this work for Ubuntu 9.04?

I'm using the same Broadcom Wifi.

Also, can you pls. provide a more newbie approach, as I can't understand anything you've just said.

Thanks a lot good guy. =)

Xor said...

@Live,

I had used my patch successfully on Ubuntu 9.04 too. But right now, I am too busy to write a detailed newbie approach. Sorry. You might want to read about rebuilding a deb from source and adding patches if you want to try this patch.

Or you could just wait for a few months till Ubuntu 9.10 comes out. I am currently using Karmic alpha and the Ubuntu-provided broadcom driver works flawlessly for me without any need for patches.

Akhil S Behl said...

hey.. i have updated from jaunty to karmic.. and the repos driver still can't connect me to a hidden wpa-psk network.. i wonder if your patch would help?

Xor said...

Hi Akhil. Thanks for your interest in my patch. As far as I know, this patch seems to have been merged upstream, and so it should not be required anymore. The Broadcom STA driver provided in Karmic works for me. The driver compiled from source also works. Can you connect to your network if it's not hidden? Are you using gnome/kde?

In opensuse 11.2, I had a problem connecting to hidden networks with the latest driver, but as it turns out, it was the kde4 NetworkManager applet to blame. I don't know where the bug is, but the workaround is to unhide the network for the first connection attempt, get a successful connection and then hide the network. For the next attempts/restarts, the kde4 applet connects successfully even if the network is hidden.

So in your case, my guess would be that the problem may not related to the driver itself but may be something else. But then again, I could be wrong..

Try ubuntu forums for help. I am certain they will be able to provide you with more guidance. Sorry I can't be of much more help.

Akhil S Behl said...

hey!!!
i would just like to tell you that i compiled the broadcom driver (and as you said the patch was already there in the source file) and it worked.. i read a couple of linux gurus like yourself and now my net is working.. and this is just swell.. thanks a lot for the patch!!! :)

Akhil S Behl said...

i believe that the problem might have been in the ndiswrapper driver file that i had been using earlier which was installed by default.. may be you could get the developers to change that too..

Xor said...

Glad to know you got your net working again Akhil! :)