CentOS7编译BCM43XX无线网卡驱动

This commit is contained in:
游由 2021-07-20 16:36:36 +08:00
parent 065dfea5ad
commit 44092cdaf4
1 changed files with 100 additions and 0 deletions

100
bcm43xx.md Normal file
View File

@ -0,0 +1,100 @@
# CentOS7编译BCM43XX无线网卡驱动
[参考链接1](https://wiki.centos.org/zh/HowTos/Laptops/Wireless/Broadcom)
[参考链接2](http://elrepo.org/tiki/wl-kmod)
```shell
yum install pciutils
lspci | grep Broadcom
yum install kernel-headers kernel-devel gcc patch vim
mkdir -p /usr/local/src/hybrid-wl
cd /usr/local/src/hybrid-wl
wget https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_271.tar.gz
tar -zxvf hybrid-v35-nodebug-pcoem-6_30_223_271.tar.gz
chown -R nobody.nobody /usr/local/src/hybrid-wl
sed -i 's/ >= KERNEL_VERSION(3, 11, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(3, 15, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ < KERNEL_VERSION(3, 18, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 0, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ < KERNEL_VERSION(4,2,0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 7, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 8, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 11, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ < KERNEL_VERSION(4, 12, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ >= KERNEL_VERSION(4, 12, 0)/ >= KERNEL_VERSION(3, 10, 0)/' src/wl/sys/wl_cfg80211_hybrid.c
sed -i 's/ <= KERNEL_VERSION(4, 10, 0)/ < KERNEL_VERSION(3, 9, 0)/' src/wl/sys/wl_linux.c
cd ..
# vim wl-kmod-01_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch
# vim wl-kmod-02_kernel_4.8_add_cfg80211_scan_info_struct.patch
# vim wl-kmod-03_fix_kernel_warnings.patch
# vim wl-kmod-04_kernel_4.11_remove_last_rx_in_net_device_struct.patch
# vim wl-kmod-05_kernel_4.12_add_cfg80211_roam_info_struct.patch
# vim wl-kmod-fix-ioctl-handling.patch
cd hybrid-wl
patch -p1 < ../wl-kmod-01_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch
patch -p1 < ../wl-kmod-02_kernel_4.8_add_cfg80211_scan_info_struct.patch
patch -p1 < ../wl-kmod-03_fix_kernel_warnings.patch
patch -p1 < ../wl-kmod-04_kernel_4.11_remove_last_rx_in_net_device_struct.patch
patch -p1 < ../wl-kmod-05_kernel_4.12_add_cfg80211_roam_info_struct.patch
patch -p1 < ../wl-kmod-fix-ioctl-handling.patch
```
## 编译32位需要改一处代码
`vim src/shared/linux_osl.c`
[参考链接](https://bbs.archlinux.org/viewtopic.php?id=215189)
将935行后的代码
```c
#if defined(__i386__)
rdtscl(cycles);
#else
cycles = 0;
#endif
```
替换为
```c
#if defined(__i386__)
#if defined rdtscl
rdtscl(cycles);
#else
cycles = rdtsc();
#endif
#else
cycles = 0;
#endif
```
```shell
make -C /lib/modules/`uname -r`/build/ M=`pwd`
strip --strip-debug wl.ko
modprobe -r bcm43xx
modprobe -r b43
modprobe -r b43legacy
modprobe -r ssb
modprobe -r bcma
modprobe -r brcmsmac
modprobe -r ndiswrapper
cp -vi /usr/local/src/hybrid-wl/wl.ko /lib/modules/`uname -r`/extra/
depmod $(uname -r)
modprobe wl
```
```shell
vim /etc/modprobe.d/blacklist.conf
```
```txt
blacklist bcm43xx
blacklist b43
blacklist b43legacy
blacklist bcma
blacklist brcmsmac
blacklist ssb
blacklist ndiswrapper
```
```shell
vim /etc/sysconfig/modules/kmod-wl.modules
```
```shell
#!/bin/bash
for M in lib80211 cfg80211 wl; do
modprobe $M &>/dev/null
done
```