linux 下手動編譯安裝無線網卡驅動

先參照 《本地yum源安裝GCC 》安裝好gccphp

hp的筆記本上安裝了CentOS6.3,沒有安裝無線網卡驅動,安裝這個驅動,在Google上找了好多資料,最後終於解決了這個問題。在這裏作點記錄,但願也能幫到別人。html

個人機子是32位,CentOS的內核版本是2.6.32-279.19.1.el6.i686,下載的無線網卡驅動是hybrid-portsrc_x86_32-v5_100_82_112.tar.gzlinux

下面是具體的步驟網絡

一:肯定無線網卡的型號,驅動下載

第一步要肯定機子的無線網卡型號是什麼,能夠用命令app

[root@CentOS ~]$/sbin/lspci | grep Broadcom
02:00.0 Network controller: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller (rev 01)

[root@CentOS ~]$lspci | grep Wirelessless

可見對應的驅動爲:Broadcom BCM4313ide

下載驅動:http://www.broadcom.com/support/802.11/linux_sta.phpui

其中,在下載頁面有一個README.txt文件,裏面有一段話這樣描述:this

SUPPORTED DEVICES
—————–
The cards with the following PCI Device IDs are supported with this driver.
Both Broadcom and and Dell product names are described. Cards not listed
here may also work.google

BRCM PCI PCI Dell
Product Name Vendor ID Device ID Product ID
————- ———- ——— ———–
4311 2.4 Ghz 0x14e4 0×4311 Dell 1390
4311 Dualband 0x14e4 0×4312 Dell 1490
4311 5 Ghz 0x14e4 0×4313
4312 2.4 Ghz 0x14e4 0×4315 Dell 1395
4313 2.4 Ghz 0x14e4 0×4727 Dell 1501
4321 Dualband 0x14e4 0×4328 Dell 1505
4321 Dualband 0x14e4 0×4328 Dell 1500
4321 2.4 Ghz 0x14e4 0×4329
4321 5 Ghz 0x14e4 0x432a
4322 Dualband 0x14e4 0x432b Dell 1510
4322 2.4 Ghz 0x14e4 0x432c
4322 5 Ghz 0x14e4 0x432d
43224 Dualband 0x14e4 0×4353 Dell 1520
43225 2.4 Ghz 0x14e4 0×4357
43227 2.4 Ghz 0x14e4 0×4358
43228 Dualband 0x14e4 0×4359 Dell 1530

To find the Device ID’s of Broadcom cards on your machines do:
# lspci -n | grep 14e4

運行:
[jimanyu@CentOS ~]$ lspci -n | grep 14e4
02:00.0 0280: 14e4:4727 (rev 01)
0b:00.0 0200: 14e4:1680 (rev 10)

CentOS的內核源碼是放在 /usr/src/kernels 目錄中; 若是經過在線升級內核, 也是放在這個目錄中; 若是你的系統中的 /usr/src/kernels/ 中沒有內容,說明沒有安裝內核的源碼包 kernel-devel 軟件包; 經過在線安裝的內核源碼包, 能夠經過 yum 安裝的, 內核源碼會被放到 /usr/src/kernel 下的目錄中

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

若是未安裝內核的源碼包,在後面make的時候會報錯誤:

[root@CentOS hybird-wl]$ make -C /lib/modules/`uname -r`/build/ M=`pwd`
make: *** /lib/modules/2.6.32-279.el6.i686/build/: No such file or directory. Stop.

二:創建安裝目錄

[root@CentOS ~]# mkdir -p /usr/local/src/hybrid-wl
[root@CentOS hybrid-wl]# cd /usr/local/src/hybrid-wl
[root@CentOS hybrid-wl]# tar xvfz /path/to/the/tarball/hybrid-portsrc_x86_32-v5_100_82_112.tar.gz(name of the downloaded file)
[root@CentOS hybrid-wl]# chown -R someuser.somegroup /usr/local/src/hybrid-wl

三:編譯

[root@CentOS hybird-wl]$ make

第一次編譯,報了以下的錯誤:

KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
make[1]: Entering directory `/usr/src/kernels/2.6.32-279.el6.i686′
CFG80211 API is prefered for this kernel version
Using CFG80211 API
LD /usr/local/src/hybird-wl/built-in.o
CC [M] /usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.o
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:64: warning: ‘enum tx_power_setting’ declared inside parameter list
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:64: warning: its scope is only this definition or declaration, which is probably not what you want
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1110: warning: ‘enum tx_power_setting’ declared inside parameter list
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1110: error: parameter 2 (‘type’) has incomplete type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c: In function ‘wl_cfg80211_set_tx_power’:
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1123: error: ‘TX_POWER_AUTOMATIC’ undeclared (first use in this function)
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1123: error: (Each undeclared identifier is reported only once
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1123: error: for each function it appears in.)
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1125: error: ‘TX_POWER_LIMITED’ undeclared (first use in this function)
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1131: error: ‘TX_POWER_FIXED’ undeclared (first use in this function)
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c: At top level:
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1649: warning: initialization from incompatible pointer type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1651: warning: initialization from incompatible pointer type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1652: warning: initialization from incompatible pointer type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1653: warning: initialization from incompatible pointer type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1654: warning: initialization from incompatible pointer type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1658: warning: initialization from incompatible pointer type
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c: In function ‘wl_inform_single_bss’:
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:1817: error: too few arguments to function ‘ieee80211_channel_to_frequency’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c: In function ‘wl_bss_roaming_done’:
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2117: warning: passing argument 2 of ‘cfg80211_roamed’ from incompatible pointer type
include/net/cfg80211.h:3035: note: expected ‘struct ieee80211_channel *’ but argument is of type ‘u8 *’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2117: warning: passing argument 4 of ‘cfg80211_roamed’ makes pointer from integer without a cast
include/net/cfg80211.h:3035: note: expected ‘const u8 *’ but argument is of type ‘s32’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2117: warning: passing argument 5 of ‘cfg80211_roamed’ makes integer from pointer without a cast
include/net/cfg80211.h:3035: note: expected ‘size_t’ but argument is of type ‘u8 *’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2117: warning: passing argument 6 of ‘cfg80211_roamed’ makes pointer from integer without a cast
include/net/cfg80211.h:3035: note: expected ‘const u8 *’ but argument is of type ‘s32’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2117: error: too few arguments to function ‘cfg80211_roamed’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c: In function ‘wl_bss_connect_done’:
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2149: warning: passing argument 2 of ‘cfg80211_roamed’ from incompatible pointer type
include/net/cfg80211.h:3035: note: expected ‘struct ieee80211_channel *’ but argument is of type ‘u8 *’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2149: warning: passing argument 4 of ‘cfg80211_roamed’ makes pointer from integer without a cast
include/net/cfg80211.h:3035: note: expected ‘const u8 *’ but argument is of type ‘s32’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2149: warning: passing argument 5 of ‘cfg80211_roamed’ makes integer from pointer without a cast
include/net/cfg80211.h:3035: note: expected ‘size_t’ but argument is of type ‘u8 *’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2149: warning: passing argument 6 of ‘cfg80211_roamed’ makes pointer from integer without a cast
include/net/cfg80211.h:3035: note: expected ‘const u8 *’ but argument is of type ‘s32’
/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.c:2149: error: too few arguments to function ‘cfg80211_roamed’
make[2]: *** [/usr/local/src/hybird-wl/src/wl/sys/wl_cfg80211.o] Error 1
make[1]: *** [_module_/usr/local/src/hybird-wl] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.32-279.el6.i686′
make: *** [all] Error 2

google了一下,發現CentOS6.3版本報的都是相同的錯誤,找了好多資料都沒有好的解決辦法。回頭再看broadcom的REAMME.txt,裏面寫了一段話:

If your driver does not build, check to make sure you have installed the
kernel package described in the requirements above.

This driver now supports the new linux cfg80211 wireless configuration API in
addition to the older Wireless Extensions (Wext). The makefile will
automaticly build the right version for your system but it can be
overridden if needed:

# make API=WEXT
or
# make API=CFG80211

嘗試從新編譯

[root@CentOS hybird-wl]$ make clean
[root@CentOS hybird-wl]$ make API=WEXT

編譯經過了,生成了wl.ko這個文件,發現仍是得看官方的文檔。完成編譯後即是安裝

[root@CentOS hybird-wl]$ make install

安裝就是把文件COPY到/lib/modules/<kernel-version>/kernel/net/wireless 目錄。

四:驅動配置

移除全部其它的BROADCOM 無線設備驅動。除了咱們已經編譯好的驅動外,其它的Broadcom 802.11芯片驅動象b43, bcma和ssb。 這個驅動和咱們新的驅動是衝突的。因此咱們要先把它們移除。

# lsmod  | grep 「b43\|ssb\|bcma\|wl」

若是如下任何一種驅動存在,移除它:

[root@CentOS hybird-wl]$rmmod b43
[root@CentOS hybird-wl]$rmmod ssb
[root@CentOS hybird-wl]$rmmod bcma
[root@CentOS hybird-wl]$rmmod wl

所這些配置加入黑名單,不讓它們被使用:

[root@CentOS hybird-wl]$echo 「blacklist ssb」 >> /etc/modprobe.d/blacklist.conf
[root@CentOS hybird-wl]$echo 「blacklist bcma」 >> /etc/modprobe.d/blacklist.conf
[root@CentOS hybird-wl]$echo 「blacklist b43″ >> /etc/modprobe.d/blacklist.conf

載入新的驅動

[root@CentOS hybird-wl]$modprobe lib80211 # 由於 wl.ko 須要依賴該模塊
[root@CentOS hybird-wl]$insmod wl.ko

如今你的網絡管理程序應該能夠找到設備, 你可使用無線網絡了!最後添加開機啓動

[root@butbueatiful wireles_smoudules]# cp wl.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless[root@butbueatiful wireles_smoudules]# depmod -a[root@butbueatiful wireles_smoudules]# echo modeprobe wl >> /etc/rc.local

相關文章
相關標籤/搜索