Cubieboard2(六)RTL8188ETV 驱动
文章目录
- 1 RTL8188ETV 驱动源码
- 2 驱动编译
- 2.1 添加驱动源代码
- 2.1.1 添加 AIC8800 驱动源代码(可选)
- 2.1.2 添加 RTL8188ETV 驱动源代码
- 2.2 编译
- 2.2.1 linux 内核
- 2.2.2 编译 RTL8188ETV 模块
- 3 驱动安装与配置
- 4 修改网卡名称
- 5 测速
- 6 参考
1 RTL8188ETV 驱动源码
- https://github.com/quickreflex/rtl8188eus.git
该仓库最后一次更新已经是 5 年前(2019 年),支持的最新 Linux 内核版本为 5.1.x
- https://github.com/lwfinger/rtl8188eu.git
该仓库最后一次更新已经是 2 年前(2022 年),支持的最新 Linux 内核版本为 5.17
2 驱动编译
2.1 添加驱动源代码
2.1.1 添加 AIC8800 驱动源代码(可选)
# 复制内核源码(来自其驱动的 deb 包解压)
cp ~/aic8800/drivers/aic8800/ -r drivers/net/wireless/# 打开 drivers/net/wireless/Makefile 文件,添加:
obj-$(CONFIG_AIC_WLAN_SUPPORT) += aic8800/# 打开 drivers/net/wireless/Kconfig 文件,添加:
source "drivers/net/wireless/aic8800/Kconfig"
2.1.2 添加 RTL8188ETV 驱动源代码
1)lwfinger 仓库的 rtl8188eu 代码不需要合并到内核中一起编译,只需要在将内核编译一遍后引用内核自行即可。
2)quickreflex 仓库的 rtl8188eus 代码,经测试,如果按照 AIC8800 驱动的方式添加到源码中无法编译出驱动,而在驱动外引用内核编译则可以成功生成。
2.2 编译
2.2.1 linux 内核
首先清理一下编译生成的中间文件:
make mrproper # Remove all generated files + config + various backup files'
make distclean # mrproper + remove editor backup and patch files'
1)以 sunxi_defconfig 为基础,生成 .config 配置文件:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig......
#
# configuration written to .config
#
2)编译菜单项配置:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
第一级 | 第二级 | 第三级 | 第四级 | 第五级 | 说明 |
---|---|---|---|---|---|
Enable loadable module support | |||||
Networking support | Wireless | cfg80211 - wireless configuration API | |||
Networking support | Wireless | cfg80211 wireless extensions compatibility | |||
Networking support | Wireless | Generic IEEE 802.11 Networking Stack (mac80211) | |||
Networking support | Wireless | Enable mac80211 mesh networking (pre-802.11s)s support | |||
Networking support | RF switch subsystem support | GPIO RFKILL driver | |||
------------ | |||||
Device Drivers | Serial ATA and Parallel ATA drivers | Allwinner sunxi AHCI SATA support | SATA,默认已选中 | ||
Device Drivers | Network device support | Universal TUN/TAP device driver support | Tun/Tap | ||
Device Drivers | Network device support | Wireless LAN | AIC wireless Support | AIC8800 wlan Support AIC8800 Load Firmware Support | USB 无线网卡 |
Device Drivers | Network device support | Wireless LAN | IEEE 802.11 for Host AP 以及其下方两项 | USB 无线网卡 | |
------------ | |||||
Device Drivers | USB support | USB Wireless Device Mangement support | |||
Device Drivers | USB support | USB Mass Storage support | 勾选其所有展开的菜单项(16) | USB 转 stat、USB 读卡器等支持 | |
Device Drivers | USB support | USB Serial Converter support | USB Prolific 2303 Single Port Serial Driver | USB 转串口 | |
------------ | |||||
Kernel hacking | Kernel debugging | ||||
Kernel hacking | arm Debugging | Kernel low-level debugging functions | Kernel low-level debugging port | Kernel low-level debugging messages via sunxi UART0 | |
Kernel hacking | arm Debugging | Early printk |
- 3)开始编译:
# (1)设置干净的版本号:
vi .config # 打开 .config 文件# 确定 CONFIG_LOCALVERSION = ""# 注释掉 CONFIG_LOCALVERSION_AUTO# 编译时指定 LOCALVERSION=
# 查看版本号
make LOCALVERSION= kernelversion# (2)内核编译
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION= zImage dtbs......OBJCOPY arch/arm/boot/zImageKernel: arch/arm/boot/zImage is ready# (3)模块编译
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION= modules......LD [M] crypto/echainiv.koLD [M] drivers/net/wireless/aic8800/aic_load_fw/aic_load_fw.koLD [M] drivers/net/wireless/aic8800/aic8800_fdrv/aic8800_fdrv.ko# (4)把 zImage 转换为 uImage
cd ~/mainline/linux
mkimage -A arm -O linux -T kernel -C none -a 0x46000000 -e 0x46000000 -n "Linux kernel uImage" -d arch/arm/boot/zImage ../uImage
问题 1,编译时出现:/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc’; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
// 打开 scripts/dtc/dtc-lexer.lex.c 文件,在 YYLTYPE yylloc 前面添加 extern 关键字。
extern YYLTYPE yylloc;
2.2.2 编译 RTL8188ETV 模块
1)使用有最多 star 的仓库 https://github.com/quickreflex/rtl8188eus.git 来编译:
cd rtl8188eus_quickreflex# 编译驱动
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KSRC=~/mainline/linux LOCALVERSION= all......Building modules, stage 2.MODPOST 1 modulesCC /root/driver/rtl8188etv/rtl8188eus_quickreflex/8188eu.mod.oLD [M] /root/driver/rtl8188etv/rtl8188eus_quickreflex/8188eu.ko
make[1]: Leaving directory '/root/mainline/linux'# 生成 8188eu.ko,将 8188eu.ko 上传到开发板,通过 insmod 安装即可
2)使用支持内核较新(v5.17)的 https://github.com/lwfinger/rtl8188eu.git 来编译:
cd rtl8188eu_lwfinger# 编译驱动
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KSRC=~/mainline/linux LOCALVERSION= all......Building modules, stage 2.MODPOST 1 modulesCC /root/driver/rtl8188etv/rtl8188eu_lwfinger/8188eu.mod.oLD [M] /root/driver/rtl8188etv/rtl8188eu_lwfinger/8188eu.ko
make[1]: Leaving directory '/root/mainline/linux'# 生成 8188eu.ko,将 8188eu.ko 上传到开发板,通过 insmod 安装即可
3 驱动安装与配置
1)安装模块:
# 1)安装模块
mound /dev/sdx1 /mnt/h
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/mnt/h/ LOCALVERSION= modules_install# 2)安装头文件(不太推荐以下方式)
# mound /dev/sdx2 /mnt/h
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=/mnt/h/usr/src LOCALVERSION= headers_install# -------------- 至此,与内核相关的模块(如 AIC8800),头文件安装完成# 3)安装 rtl8188.ko
cp rtl8188.ko /mnt/h/lib/modules/5.1.0/# 4)安装头文件(源码)的另一种方式:
tar -czvf --exclude-vcs linux-5.1.0.tar.gz linux # 压缩 Linux 源码目录,剔除版本控制目录,v5.1 版本压缩完成大概 300+MB
scp linux-5.1.0.tar.gz root@192.168.1.2:/root # 上传到开发板
tar-zxvf linux-5.1.0.tar.gz # 解压
mv linux /usr/src/kernels/ # 移动到 /usr/src/kernels 目录(不存在时需要手动创建目录)
ln -sf /usr/src/kernels/linux-5.1.0/ /lib/modules/5.1.0/build # 添加源码目录软链接
ln -sf /usr/src/kernels/linux-5.1.0/ /lib/modules/5.1.0/source # 添加源码目录软链接
2)配置开机自动加载模块
# 生成模块依赖关系表
depmod -a# 添加 AIC8800 配置
echo "options aic_load_fw antenna_diversity=1" >> /etc/modprobe.d/aic8800.conf
echo "options aic8800_fdrv antenna_diversity=1" >> /etc/modprobe.d/aic8800.conf# 添加 RTL8188ETV 配置
echo "options 8188eu antenna_diversity=1" >> /etc/modprobe.d/realtek_rtl.conf# 探测模块是否正常
modprobe 8188eu
modprobe aic_load_fw
modprobe aic8800_fdrv
4 修改网卡名称
无线网卡成功被识别后,其名称为 wlxe0b2f14aba0d 而不是 wlan0,这里修改一下。
cp /lib/udev/rules.d/80-net-setup-link.rules /etc/udev/rules.d/# 打开复制后的 80-net-setup-link.rules 文件:
vi /etc/udev/rules.d/80-net-setup-link.rules# 修改如下内容:
NAME=="", ENV{ID_NET_NAME}!="", NAME="$env{ID_NET_NAME}"
# 为:
NAME=="", ENV{ID_NET_NAME}!="", NAME="$env{ID_NET_SLOT}"
5 测速
1)基于 RTL8188ETV 芯片无线网卡:
# 开发板上运行如下命令:
iperf -s# 局域网其它主机上运行如下命令:
iperf -c 192.168.101.23
------------------------------------------------------------
Client connecting to 192.168.101.23, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.101.18 port 60488 connected with 192.168.101.23 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.0000-11.9629 sec 23.9 MBytes 16.7 Mbits/sec
2)基于 AIC8800 芯片无线网卡:
# 开发板上运行如下命令:
iperf -s# 测试 AIC8800 芯片,局域网其它主机上运行如下命令:
iperf -c 192.168.101.19
------------------------------------------------------------
Client connecting to 192.168.101.19, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.101.18 port 60568 connected with 192.168.101.19 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.0000-10.5543 sec 63.4 MBytes 50.4 Mbits/sec# 测试有线网速:
iperf -c 192.168.1.2
------------------------------------------------------------
Client connecting to 192.168.1.2, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.101.18 port 60596 connected with 192.168.1.2 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.0000-10.2415 sec 109 MBytes 88.9 Mbits/sec
6 参考
- https://blog.csdn.net/qq_28877125/article/details/127301761
- https://www.cnblogs.com/duapple/p/17915563.html
- https://zhuanlan.zhihu.com/p/358038347
- https://blog.csdn.net/weixin_42409052/article/details/113065704