Broadcom 4313 on Fedora 16 (Linux kernel 3.1.0)

Update: since kernel 3.1.1-1, brcmsmac module is already built in the kernel package. There’s no need to recompile.

So, the people at Fedora decided the new Open Source driver for the Broadcom 4313 wireless card (idientified as: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller [14e4:4727] (rev 01)) wasn’t stable enough to be built with the default kernel for Fedora 16 (beta, at the moment). Since RPMfusion repositories for F16 aren’t out already, so you can’t install wl driver, the alternative is to build the module.

This tutorial is based on both the Custom Kernel Guide from the Fedora wiki and this article about building the driver for Fedora 15.

First, we need to install some tools needed for kernel development (and the card firmware if we don’t already have it):

root[~]% yum install linux-firmware rpmdevtools yum-utils ncurses-devel
root[~]% yum-builddep kernel

Then we can download the kernel source and prepare the build environment:

user[~]% yumdownloader --source kernel
user[~]% rpmdev-setuptree
user[~]% rpm -Uvh kernel-3.1.0-0.rc9.git0.0.fc16.src.rpm 
user[~]% cd rpmbuild/SPECS/
user[~/.../SPECS/]% rpmbuild -bp --target=$(uname -m) kernel.spec

Now we must enter the source tree and make sure that the extraversion is correctly configured. For example, for kernel 3.1.0-0.rc9.git0.0.fc16.x86_64, the extraversion will be -0.rc9.git0.0.fc16.x86_64. Edit the Makefile accordingly:

user[~/rpmbuild/SPECS/]% cd ../BUILD/kernel-3.0.fc16/linux-3.0.x86_64/
user[~/.../linux-3.0.x86_64/]% vim Makefile
user[~/.../linux-3.0.x86_64/]% make menuconfig

In menuconfig we must find the module (press / then search for brcm). In my current version, it was under Device Drivers / Staging Drivers. Set both Broadcom IEEE802.11n PCIe SoftMAC WLAN driver and Broadcom IEEE802.11n embedded FullMAC WLAN driver as modules.

Then, we compile the staging area (it could be necessary to skip this step):

user[~/.../linux-3.0.x86_64/]% make -j5 staging/drivers/

Then we make and install the drivers:

user[~/.../linux-3.0.x86_64/]% make -j5 M=drivers/staging/brcm80211
user[~/.../]% su -c 'make modules_install M=drivers/staging/brcm80211'
  INSTALL drivers/staging/brcm80211/brcmfmac/brcmfmac.ko
  INSTALL drivers/staging/brcm80211/brcmsmac/brcmsmac.ko
  INSTALL drivers/staging/brcm80211/brcmutil/brcmutil.ko
  DEPMOD  3.1.0-0.rc9.git0.0.fc16.x86_64

Make sure that the module is in the right directory:

user[~/.../linux-3.0.x86_64/]% find /lib/modules -name 'brcm*'

I had to run depmod again as root, then I loaded the driver:

root[~]% depmod -a
root[~]% modprobe -a brcmsmac

At this point, Network Manager got back to life and allowed me to connect to my wifi network.

If you made a mistake during the procedure, you can get a clean build tree running:

user[~/.../linux-3.0.x86_64/]% cp .config ~/config-3.1.0-rc ; cp Makefile ~/
user[~/.../linux-3.0.x86_64/]% make mrproper clean
user[~/.../linux-3.0.x86_64/]% cp ~/config-3.1.0-rc .config ; cp ~/Makefile .
user[~/.../linux-3.0.x86_64/]% make oldconfig && make prepare