Fixing the Broadcom BCM4331 wireless drivers on Ubuntu 13.10

How to restore stable WiFi on the Broadcom Corporation BCM4331 wireless chip after upgrading from Ubuntu 13.04 (Raring) to 13.10 (Saucy Salamander).


I have a Macbook Pro 9.2 at work, though the first thing I did upon receiving it was to install (Ubuntu) Linux on it. Surprisingly, after figuring out the nuances of the EFI booting, everything worked surprisingly well. This included wireless, bluetooth and backlight control, all working out of the box.

Now, this all changed when I upgraded to 13.10 however. Suddenly, I no longer found my wireless to be particularly stable. At home, this manifested itself in particularly unstable SSH sessions, though oddly, it was usually fine besides that. At work however, the experience was much worse, giving frequent disconnects, packet loss and overall high latency. The kernel log was also full of ERROR @wl_cfg80211_get_station : Wrong Mac address, though I was seeing this on my home network as well.

Some searching around quickly revealed there are lots of people with similar issues, the general concensus being Broadcom’s proprietary drivers are just, well, crap. (There’s also an opensource driver which does work with the chip in this Macbook, but after trying it out, I can safely say that experience was even worse.)

Fed up with the situation at last, I decided to try and downgrade back to the drivers shipped with 13.04 in an effort to get back to that previous level of stability. To make a long story short, after some research and experimentation, I have successfully downgraded and am now enjoying a stable wireless experience again. The rest of this post will be a guide on how to perform these steps yourself as well, in case you find yourself in the same boat I was in.

Downgrading to

First, grab the version of bcmwl-kernel-source and then install it. It will fail to build the kernel module once dkms kicks in, but that’s okay. It won’t prevent the package itself from installing.

# Find a mirror close to you at:
# (i386)
# or:
# (amd64, like this macbook)

# And then install it
dpkg -i bcmwl-kernel-source_6.20.155.1+bdcom-0ubuntu6_amd64.deb

To make it build on the 3.11 kernel currently shipped with Ubuntu 13.10, two extra patches are needed. I managed to find these in the version of bcmwl-kernel-source that we just replaced, but for your convenience I’ve mirrorred them here as well:

The first patch needs to be patched (har har) however to apply cleanly. If you downloaded my version above, I’ve already done this for you.

--- 0008-add-support-for-linux-3.9.0.patch
+++ 0008-add-support-for-linux-3.9.0.patch
@@ -4,8 +4,8 @@
 Subject: [PATCH 1/1] Add support for Linux 3.9
---- a/src/wl/sys/wl_cfg80211_hybrid.c
-+++ a/src/wl/sys/wl_cfg80211_hybrid.c
+--- a/src/wl/sys/wl_cfg80211.c
++++ a/src/wl/sys/wl_cfg80211.c
 @@ -2048,7 +2048,11 @@
				ie_len = (size_t)(ies->len);

Place these into /usr/src/bcmwl-, then adjust /usr/src/bcmwl- to use them:

--- /usr/src/bcmwl-
+++ /usr/src/bcmwl-
@@ -12,6 +12,8 @@

At this point, it should build and install successfully:

dkms build -m bcmwl -v && dkms install -m bcmwl -v

Assuming that went off without a hitch, you can reload the wl module to use this version now (note: this will of course disconnect you):

rmmod wl && modprobe wl

To verify you really are running the version of the driver, you can check the last few lines of dmesg output. It should show Broadcom BCM4331 802.11 Hybrid Wireless Controller (r326264) (note the version number there).

Making sure it stays put

Finally, you’ll also want to ensure that an update doesn’t pull the newer version back in, which would undo all the hard work you’ve just done. This can be done by pinning the version of bcmwl-kernel-source. Create /etc/apt/preferences.d/bcmwl-kernel-source with the following contents, and you should be all set.

Package: bcmwl-kernel-source
Pin: version*
Pin-Priority: 1001

Closing notes

None of this is officially supported by Ubuntu of course, so don’t blame me if it doesn’t work or stops working on a kernel update some day in the future :) That said, the procedure is safe, and if you ever want to return back to the original state, you only have to remove the /etc/apt/preferences.d/bcmwl-kernel-source file to undo the pinning, then issue an apt-get upgrade or aptitude upgrade to install the latest version again.