Tuesday, 3 June 2014

Broadcom BCM43227 wl module on Kali Linux 1.0.7 + (kernel 3.x +)

This post will describe the methods used to get most "wl" based Broadcom devices to work with Kali Linux. My specific device is the BCM43227 found in the Acer Aspire 5560. I have installed Kali 1.0.5 through 1.0.7 before but was unable to get the wireless adapter to work until now.

FOR KERNEL VERSIONS 3.17+


UPDATE (05/02/2015): The previous patch (featured at the bottom of this post) will no longer working as of kernel 3.18. I receive these errors:
wl_linux.c: In function ‘wl_alloc_linux_if’:
wl_linux.c:1353:64: error: macro "alloc_netdev" requires 4 arguments, but only 3 given
wl_linux.c:1353:8: error: ‘alloc_netdev’ undeclared (first use in this function)
wl_linux.c:1353:8: note: each undeclared identifier is reported only once for each function it appears in

To fix this error I did some digging and found that several users have created a patch for this. If you are using a Debian based system you can easily download and install the updated bcmwl package from here or more specifically, here. YOU NEED A PACKAGE OR SOURCE WITH PATCHES FROM BRIAN NORRIS AND KRZYSZTOF KOLASA. See patch notes pasted below:
patches/0014-add-support-for-Linux-3.17.patch,
debian/patches/0015-add-support-for-Linux-3.18.patch:
- Add support for Linux 3.17 (LP: #1358966).
Credit for the patch goes to Brian Norris.
- Add support for Linux 3.18 (LP: #1358966).
Credit for the patch goes to Krzysztof Kolasa.


If you download a deb package, all you have to do is run sudo dpkg -i name_of_package_you_got_from_links_above.deb
If you are not using a Debian based system, I'm afraid I cannot help you very much; building from source should get you on the right track.

FOR KERNEL VERSIONS LOWER THAN 3.17


My instructions will follow and extrapolate on the ones described in this post by biits. I will provide additional links to the software posted in that forum message to encourage redundancy of these crucial patches.

After installing the Linux headers and build-essentials (apt-get install linux-headers-$(uname -r) broadcom-sta-dkms build-essentials) you will find that the broadcom-sta-dkms fails to build the kernel module.

As most of you with this problem know, compiling the Broadcom STA driver found here fails on Kali Linux with kernel versions 3.x. Mine failed during "make" with the following messages:
KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
make[1]: Entering directory `/usr/src/linux-headers-3.14-kali1-amd64'
CFG80211 API is prefered for this kernel version
Using CFG80211 API
  CC [M]  /root/src/wl/sys/wl_linux.o
/root/src/wl/sys/wl_linux.c: In function ‘wl_tkip_printstats’:
/root/src/wl/sys/wl_linux.c:3246:7: warning: passing argument 1 of ‘wl->tkipmodops->print_stats’ from incompatible pointer type [enabled by default]
/root/src/wl/sys/wl_linux.c:3246:7: note: expected ‘struct seq_file *’ but argument is of type ‘char *’
/root/src/wl/sys/wl_linux.c:3249:4: warning: passing argument 1 of ‘wl->tkipmodops->print_stats’ from incompatible pointer type [enabled by default]
/root/src/wl/sys/wl_linux.c:3249:4: note: expected ‘struct seq_file *’ but argument is of type ‘char *’
/root/src/wl/sys/wl_linux.c: In function ‘wl_reg_proc_entry’:
/root/src/wl/sys/wl_linux.c:3470:2: error: implicit declaration of function ‘create_proc_entry’ [-Werror=implicit-function-declaration]
/root/src/wl/sys/wl_linux.c:3470:22: warning: assignment makes pointer from integer without a cast [enabled by default]
/root/src/wl/sys/wl_linux.c:3475:16: error: dereferencing pointer to incomplete type
/root/src/wl/sys/wl_linux.c:3476:16: error: dereferencing pointer to incomplete type
/root/src/wl/sys/wl_linux.c:3477:16: error: dereferencing pointer to incomplete type
cc1: some warnings being treated as errors
make[4]: *** [/root/src/wl/sys/wl_linux.o] Error 1
make[3]: *** [_module_/root] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.14-kali1-amd64'
make: *** [all] Error 2
These messages should be identical to the ones encountered while attempting to install through apt.

To begin patching, make a directory to store the github you are about to clone. Huge shout-out to akrasic for the patch he has provided.

Using the command git clone https://github.com/akrasic/broadcom-wl.git pull akrasic's patch into your new directory. This clone also comes with the STA driver from Broadcom linked above. If you wish to download the entire clone from me (if akrasic's is down for whatever reason) you can do so here.

Run the commands which are listed in the README file in the unzipped tar.gz/cloned git repository.
They should be as follows:
tar xvfz hybrid-v35_64-nodebug-pcoem-6_30_223_141.tar.gz
patch -p1 <linux-recent.patch
patch -p1 <makefile.patch
For the makefile patch, some users have reported errors with the -p1 option and used -p0 or removed the -p option. I simply chose to say yes to patching the Makefile as opposed to the Makefile.new.
patch -p1 <wlan.patch
patch -p1 <license.patch
make
make install
modprobe -r bcma
The b43, b44, b43legacy, brcm80211, ssb, brcmsmac modules may need to be removed and blacklisted as well. In my broadcom-sta-dkms.conf file, these were already blacklisted.
echo "blacklist bcma" > /etc/modprobe.d/broadcom-sta-dkms.conf
echo "cfg80211" > /etc/modules
echo "lib80211" > /etc/modules
The previous two echoes are most likely unnecessary as wl will load them as dependencies.
echo "wl" > /etc/modules
depmod -a
depmod is crucial as it will rebuild the module tree and dependencies with the newly installed wl.ko found in /lib/modules. Without this command, you will have to forcefully insert the module at boot using insmod ./wl.ko
modprobe wl
If all is good, your new module should activate and turn on your wireless LAN device.
Entering modinfo wl should yield a result.

Cheers!

12 comments :

  1. Man, I don't know how to thank you! Worked flawlessly!
    The least I can do is to spread your blog a little bit.

    Thanks for this guide once again!
    ~1llusion

    ReplyDelete
    Replies
    1. Glad it worked for you! The real thanks goes to akrasic though for his great patch!

      Delete
  2. I follow the steps and when I type the make command I become that error:

    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make: *** /lib/modules/3.14-kali1-amd64/build: Directory or File not found. Finish.
    make: *** [all] Error 2

    Can anybody help me?

    ReplyDelete
    Replies
    1. Sorry for the late response. Well, check if that folder does exist!
      I can tell you that your problem is almost certainly that you have not installed the appropriate linux-headers package (as mentioned in the guide, reading, thinking, testing, and being thorough is very important [especially in penetration testing]).

      Run this command and then try the build again.
      sudo apt-get install linux-headers-$(uname -r)

      That should get you going again. Cheers! :]

      Delete
  3. hi bro i have probelm like

    =========
    make
    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make[1]: Entering directory `/usr/src/linux-headers-3.14-kali1-686-pae'
    CFG80211 API is prefered for this kernel version
    Using CFG80211 API
    LD /root/broadcom-wl/built-in.o
    CC [M] /root/broadcom-wl/src/shared/linux_osl.o
    CC [M] /root/broadcom-wl/src/wl/sys/wl_linux.o
    CC [M] /root/broadcom-wl/src/wl/sys/wl_iw.o
    CC [M] /root/broadcom-wl/src/wl/sys/wl_cfg80211_hybrid.o
    LD [M] /root/broadcom-wl/wl.o
    ld: Relocatable linking with relocations from format elf64-x86-64 (/root/broadcom-wl/lib/wlc_hybrid.o_shipped) to format elf32-i386 (/root/broadcom-wl/wl.o) is not supported
    make[4]: *** [/root/broadcom-wl/wl.o] Error 1
    make[3]: *** [_module_/root/broadcom-wl] Error 2
    make[2]: *** [sub-make] Error 2
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.14-kali1-686-pae'
    make: *** [all] Error 2
    ========
    please tell me how can i solve it?

    ReplyDelete
    Replies
    1. Hey, looks like the makefile/compiler is building for a 64 bit system and you are running an elf32 32 bit system. It looks like it is trying to reformat the output file to elf32 32 bit but it is not supported/not programmed in.

      Check out this link - http://www.linuxquestions.org/questions/linux-software-2/relocatable-linking-on-x86-64-for-i386-872812/
      It might help you to edit the files and get it to build for your system.

      Good luck!

      Delete
  4. when i wrote make this error happened

    root@fefty-kali:~/Desktop/wirless attempt/broadcom-wl# make
    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make[1]: Entering directory `/usr/src/linux-headers-3.14-kali1-amd64'
    make[3]: *** No rule to make target `attempt/broadcom-wl'. Stop.
    make[2]: *** [sub-make] Error 2
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.14-kali1-amd64'
    make: *** [all] Error 2

    ReplyDelete
    Replies
    1. Try renaming your directory from "wireless attempt" to "wireless_attempt". It is always good practise to name files and directories in lower case with underscores replacing spaces. Since many commands take a whitespace as a break in the command/a new option, whitespaces cause odd breakages such as the one you are experiencing.

      Delete
  5. I am looking for a few days and I finally found the solution! thank you very much

    ReplyDelete
  6. KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make[1]: Entering directory `/usr/src/linux-headers-3.18.0-kali3-amd64'
    CFG80211 API is prefered for this kernel version
    Using CFG80211 API
    CC [M] /root/broadcom/broadcom-wl/src/wl/sys/wl_linux.o
    /root/broadcom/broadcom-wl/src/wl/sys/wl_linux.c: In function 'wl_alloc_linux_if':
    /root/broadcom/broadcom-wl/src/wl/sys/wl_linux.c:1353:64: error: macro "alloc_netdev" requires 4 arguments, but only 3 given
    /root/broadcom/broadcom-wl/src/wl/sys/wl_linux.c:1353:8: error: 'alloc_netdev' undeclared (first use in this function)
    /root/broadcom/broadcom-wl/src/wl/sys/wl_linux.c:1353:8: note: each undeclared identifier is reported only once for each function it appears in
    make[4]: *** [/root/broadcom/broadcom-wl/src/wl/sys/wl_linux.o] Error 1
    make[3]: *** [_module_/root/broadcom/broadcom-wl] Error 2
    make[2]: *** [sub-make] Error 2
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.18.0-kali3-amd64'
    make: *** [all] Error 2

    ReplyDelete
  7. Can u be more detailed not able to understand

    ReplyDelete