gongdear

gongdear的技术博客

欢迎大家参观我的博客
  menu
89 文章
89355 浏览
0 当前访客
ღゝ◡╹)ノ❤️

Centos编译安装博通无线网卡BCM43XX驱动

https://wiki.centos.org/HowTos/Laptops/Wireless/Broadcom

前言

CentOS 7本身可以支持很多常见的无线网卡,但如果你不幸使用了博通公司的BCM4311, BCM4312, BCM4313, BCM4321, BCM4322, BCM43224, BCM43225, BCM43227 and BCM43228这些型号的无线网卡,就需要进行一些配置了。

注:本文所记录的方法主要针对EL6 and EL7

目录

  • 步骤一:确定无线网卡型号,并安装依赖包
  • 步骤二:下载、解压博通无线网卡驱动压缩包
  • 步骤三:编译博通芯片驱动模块
  • 步骤四:将驱动载入内核
  • 步骤五:将驱动载入程序加入开机启动

步骤一:确定无线网卡型号,并安装依赖包

**

[user@host ~]$ /sbin/lspci | grep Broadcom  
0b:00.0 Network controller: Broadcom Corporation BCM4312 802.11a/b/g (rev 01)

注:博主自己电脑网卡的型号是BCM43142,虽然原帖中没有列出来,也是没有关系的,方法完全适用

另外确定你在之后编译阶段没有缺失必要的宏包

**

[root@host ~]# yum install kernel-headers kernel-devel gcc

当然啦,如果你用的是服务器,要编译 Xen kernel (i.e. kernel-xen),那你需要下载 kernel-xen-devel 而不是 kernel-devel

步骤二:下载、解压博通无线网卡驱动压缩包

博通官网下载BCM43xx linux驱动包,并且解压到 /usr/local/src/hybrid-wl

64位:

https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz

32位:

https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_271.tar.gz

更新:这里直接将所有需要下载的文件都打包上传上来:

bcm4352src.zip

列了这么多,其实只需要根据情况下载第一个或者第二个就可以了。

**

[root@host ~]# mkdir -p /usr/local/src/hybrid-wl  
[root@host hybrid-wl]# cd /usr/local/src/hybrid-wl  
[root@host hybrid-wl]# tar xvfz /path/to/the/tarball/hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz  
[root@host hybrid-wl]# chown -R someuser.somegroup /usr/local/src/hybrid-wl

步骤三:编译博通芯片驱动模块

**

[user@host hybrid-wl]$ make -C /lib/modules/`uname -r`/build/ M=`pwd`

根据目前这个版本的驱动,几乎可以肯定所有人都会编译出错,在CentOS 6上你会看到如下的情况:

**

make: Entering directory `/usr/src/kernels/2.6.32-573.7.1.el6.x86_64'  
CFG80211 API is prefered for this kernel version  
Using CFG80211 API   
LD /usr/local/src/hybrid-wl/built-in.o   
CC [M] /usr/local/src/hybrid-wl/src/shared/linux_osl.o   
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_linux.o   
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_iw.o   
CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.o  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:83: warning: ‘enum tx_power_setting’ declared inside parameter list  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:83: warning: its scope is only this definition or declaration, <snip>  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_cfg80211_join_ibss’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:730: error: ‘struct cfg80211_ibss_params’ has no member named ‘channel’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: At top level:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1096: warning: ‘enum tx_power_setting’ declared inside parameter list  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1096: error: parameter 2 (‘type’) has incomplete type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_cfg80211_set_tx_power’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1107: error: ‘TX_POWER_AUTOMATIC’ undeclared (first use in this <snip>  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1107: error: (Each undeclared identifier is reported only once  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1107: error: for each function it appears in.)  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1109: error: ‘TX_POWER_LIMITED’ undeclared (first use in this function)  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1115: error: ‘TX_POWER_FIXED’ undeclared (first use in this function)  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: At top level:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1774: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1779: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1780: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1781: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1782: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1783: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1784: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1789: warning: initialization from incompatible pointer type  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_inform_single_bss’:/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1984: error: too few arguments to function <snip>  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2023: warning: passing argument 1 of ‘cfg80211_put_bss’ from <snip> include/net/cfg80211.h:3380: note: expected ‘struct wiphy *’ but argument is of type ‘struct cfg80211_bss *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2023: error: too few arguments to function ‘cfg80211_put_bss’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_update_bss_info’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2276: error: ‘struct cfg80211_bss’ has no member named <snip>  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2277: error: ‘struct cfg80211_bss’ has no member named <snip>  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2283: warning: passing argument 1 of ‘cfg80211_put_bss’ from <snip>include/net/cfg80211.h:3380: note: expected ‘struct wiphy *’ but argument is of type ‘struct cfg80211_bss *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2283: error: too few arguments to function ‘cfg80211_put_bss’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_bss_roaming_done’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 2 of ‘cfg80211_roamed’ from <snip>include/net/cfg80211.h:3726: note: expected ‘struct ieee80211_channel *’ but argument is of type ‘u8 *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 4 of ‘cfg80211_roamed’ makes <snip>include/net/cfg80211.h:3726: note: expected ‘const u8 *’ but argument is of type ‘s32’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 5 of ‘cfg80211_roamed’ makes <snip>include/net/cfg80211.h:3726: note: expected ‘size_t’ but argument is of type ‘u8 *’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: warning: passing argument 6 of ‘cfg80211_roamed’ makes <snip>include/net/cfg80211.h:3726: note: expected ‘const u8 *’ but argument is of type ‘s32’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2322: error: too few arguments to function ‘cfg80211_roamed’  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_update_wowl’:  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2791: warning: unused variable ‘wdev’  
make[1]: *** [/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.o] Error 1  
make: *** [_module_/usr/local/src/hybrid-wl] Error 2  
make: Leaving directory `/usr/src/kernels/2.6.32-573.7.1.el6.x86_64'

接下来就是el6el7步骤不同的地方

EL6

在EL6上,因为内核中 if-then-els语句会搜寻**wl_cfg80211_hybrid.**这个文件,为了修正这个问题,我们运行以下语句:

**

[user@host hybrid-wl]$ sed -i 's/[ >][>=] KERNEL_VERSION(2, 6, 3.)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c  
[user@host hybrid-wl]$ sed -i 's/[ >][>=] KERNEL_VERSION(3, ., .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c  
[user@host hybrid-wl]$ sed -i 's/[ >][>=] KERNEL_VERSION(3, 11, .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c  
[user@host hybrid-wl]$ sed -i 's/< KERNEL_VERSION(3, 18, .)/< KERNEL_VERSION(2, 6, 30)/' src/wl/sys/wl_cfg80211_hybrid.c  
[user@host hybrid-wl]$ sed -i 's/[ >][>=] KERNEL_VERSION(3, 15, .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c  
[user@host hybrid-wl]$ sed -i 's/[ >][>=] KERNEL_VERSION(4, 0, 0)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c  
[user@host hybrid-wl]$ sed -i 's/< KERNEL_VERSION(4,2,0)/< KERNEL_VERSION(2, 6, 30)/' src/wl/sys/wl_cfg80211_hybrid.c

EL7

而在EL7上,需要运行的是以下语句:

**

[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(3, 11, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(3, 15, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i 's/ < KERNEL_VERSION(3, 18, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(4, 0, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i 's/ < KERNEL_VERSION(4,2,0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(4, 7, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(4, 8, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c

[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(4, 11, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
[user@host hybrid-wl]$ sed -i 's/ < KERNEL_VERSION(4, 12, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
[user@host hybrid-wl]$ sed -i 's/ >= KERNEL_VERSION(4, 12, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
[user@host hybrid-wl]$ sed -i 's/ <= KERNEL_VERSION(4, 10, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_linux.c
[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-01_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch
patching file src/wl/sys/wl_cfg80211_hybrid.c
Hunk #6 succeeded at 1911 (offset 3 lines).
Hunk #7 succeeded at 2040 (offset 3 lines).
Hunk #8 succeeded at 2160 (offset 3 lines).
Hunk #9 succeeded at 2298 (offset 3 lines).
Hunk #10 succeeded at 2941 (offset 3 lines).
[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-02_kernel_4.8_add_cfg80211_scan_info_struct.patch
patching file src/wl/sys/wl_cfg80211_hybrid.c
Hunk #1 succeeded at 2442 (offset 3 lines).
Hunk #2 succeeded at 2553 (offset 3 lines).
Hunk #3 succeeded at 2989 (offset 3 lines).
[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-03_fix_kernel_warnings.patch
patching file src/wl/sys/wl_cfg80211_hybrid.c
Hunk #1 succeeded at 2008 (offset 3 lines).
Hunk #2 succeeded at 2032 (offset 3 lines).
Hunk #3 succeeded at 2056 (offset 3 lines).
Hunk #4 succeeded at 2071 (offset 3 lines).
Hunk #5 succeeded at 2107 (offset 3 lines).
Hunk #6 succeeded at 2386 (offset 3 lines).
Hunk #7 succeeded at 2401 (offset 3 lines).
Hunk #8 succeeded at 2441 (offset 3 lines).
[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-04_kernel_4.11_remove_last_rx_in_net_device_struct.patch
patching file src/wl/sys/wl_cfg80211_hybrid.c
patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 2911 (offset -18 lines).
[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-05_kernel_4.12_add_cfg80211_roam_info_struct.patch
patching file src/wl/sys/wl_cfg80211_hybrid.c
Hunk #3 succeeded at 2450 (offset 3 lines).
Hunk #4 succeeded at 2466 (offset 3 lines).

打补丁,再次编译

以下步骤在EL6和EL7上相同。

下载wl-kmod-fix-ioctl-handling.patch/usr/local/sr并运行

**

[user@host hybrid-wl]$ patch -p1 < ../wl-kmod-fix-ioctl-handling.patch  
patching file src/wl/sys/wl_cfg80211_hybrid.c  
Hunk #1 succeeded at 1467 (offset 17 lines).  
patching file src/wl/sys/wl_linux.c  
Hunk #1 succeeded at 1659 (offset 8 lines).

现在再次编译

**

[user@host hybrid-wl]$ make -C /lib/modules/`uname -r`/build/ M=`pwd`

这次我们得到的输出应该是这样:

**

make: Entering directory `/usr/src/kernels/2.6.32-573.7.1.el6.x86_64'   
CFG80211 API is prefered for this kernel version  
Using CFG80211 API   
  LD /usr/local/src/hybrid-wl/built-in.o   
  CC [M] /usr/local/src/hybrid-wl/src/shared/linux_osl.o   
  CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_linux.o   
  CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_iw.o   
  CC [M] /usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.o  
/usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:1802: warning: initialization from incompatible pointer type   
  LD [M] /usr/local/src/hybrid-wl/wl.o   
  Building modules, stage 2.  
CFG80211 API is prefered for this kernel version  
Using CFG80211 API   
  MODPOST 1 modules   
  CC /usr/local/src/hybrid-wl/wl.mod.o   
  LD [M] /usr/local/src/hybrid-wl/wl.ko.unsigned   
  NO SIGN [M] /usr/local/src/hybrid-wl/wl.ko  
make: Leaving directory `/usr/src/kernels/2.6.32-573.7.1.el6.x86_64'

之后可以去掉一些不必要的符号

**

[user@host hybrid-wl]$ strip --strip-debug wl.ko

至此,驱动已经编译完成,可以使用。

步骤四:将驱动载入内核

首先,移除已经存在的一些不可用的无线网卡驱动,这样才能载入新的。

**

[root@host ~]# modprobe -r bcm43xx  
[root@host ~]# modprobe -r b43  
[root@host ~]# modprobe -r b43legacy  
[root@host ~]# modprobe -r ssb  
[root@host ~]# modprobe -r bcma  
[root@host ~]# modprobe -r brcmsmac  
[root@host ~]# modprobe -r ndiswrapper

把驱动模块放在kernel能找到的地方

**

[root@host hybrid-wl]# cp -vi /usr/local/src/hybrid-wl/wl.ko /lib/modules/`uname -r`/extra/

然后运行

**

[root@host ~]# depmod $(uname -r)  
[root@host hybrid-wl]# modprobe wl

如果没有报错就可以用啦。

步骤五:将驱动载入程序加入开机启动

编辑 /etc/modprobe.d/blacklist.conf添加以下语句

**

blacklist bcm43xx  
blacklist b43  
blacklist b43legacy  
blacklist bcma  
blacklist brcmsmac  
blacklist ssb  
blacklist ndiswrapper

编辑 /etc/sysconfig/modules/kmod-wl.modules写入以下内容

**

#!/bin/bash  
for M in lib80211 cfg80211 wl; do   
  modprobe $M &>/dev/null  
done

这样,驱动就会开机启动啦!

宝剑锋从磨砺出,梅花香自苦寒来.