美文网首页Linux各种姿势CentOS / Ubuntu下 软件安装教程我用 Linux
安装CentOS 7双系统(四)——解决博通无线网卡问题

安装CentOS 7双系统(四)——解决博通无线网卡问题

作者: maxwell2ic | 来源:发表于2016-08-06 14:49 被阅读2945次

    上一篇我们安装好了CentOS 7系统,但是却发现笔记本电脑无法连接Wi-Fi,这是因为我的笔记本电脑使用博通的无线网卡,驱动不支持导致的。

    本文主要从英文翻译过来,希望能帮助一些童鞋解决这个问题,如果英文差不多可以直接看CentOS论坛上这篇,可以完美解决。

    前言

    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

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

    [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'
    

    注:博主发现在el7上错误信息和上面列的相同

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

    EL6

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

    [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
    

    打补丁,再次编译

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

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

    [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
    

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

    相关文章

      网友评论

      • maxwell2ic:@scarecrowlxb 呃,这个我还真的不是太懂呃。。。感觉是什么兼容性问题。
        scarecrowlxb: @Sun6 看了好多资料综合起来解决了😂,现在卡在了将驱动装入内核中
      • scarecrowlxb:楼主,我的无线网卡类型和你的一样,但在官网上没找到相应的驱动😁,求问下你是怎么解决的
        vicas: @scarecrowlxb 解决了吗,我也遇到跟你一样的问题
        scarecrowlxb:@Sun6按照教程来还是有一些错误 :joy: ,可以帮我看看么

        /usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2040:3: 错误:提供给函数‘cfg80211_inform_bss’的实参太少
        /usr/local/src/hybrid-wl/src/wl/sys/wl_cfg80211_hybrid.c:2040:3: 错误:‘cfg80211_inform_bss’的第 3 个实参类型不兼容
        (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
        maxwell2ic:@scarecrowlxb 没关系的,就下载那个BCM43开头的那个型号的就可以了。

      本文标题:安装CentOS 7双系统(四)——解决博通无线网卡问题

      本文链接:https://www.haomeiwen.com/subject/hwkwjttx.html