本文介绍了如何再OKMX6UL这块主控IMX6UL开发板上使用板载的RTL8723BU芯片连接wifi,包括了模块的编译、加载的方式
目录
1.编译RTL8723
2.模块加载
3.无线网络连接
4.开机连接wifi
在我的嵌入式板子上(OKMX6UL)是板载了RTL8723BU芯片的,飞凌提供的okmx6ul_defconfig文件在编译内核的时候已经默认将RTL8723BU芯片编译为模块,这里没有实验单独的将RTL8723进行模块编译,只是单纯将编译好的模块从drivers/net/wireless/realtek/rtl8723BU 目录下拷出放到板子上
这里我需要用到三个模块,ch34x.ko 、cp210x.ko、以及8723bu.ko,在加载模块是遇到问题,提示无法加载,dmesg查看发现提示 UNKNOWN SYMBOL _GLOBAL_OFFSET_TABLE_
全局变量偏移表(_GLOBAL_OFFSET_TABLE_ )是用来做与位置无关的程序编译时使用到的,如果想要补充背景知识可以看看:http://www.wowotech.net/basic_subject/pic.html
经过寻找,发现了这篇文章:https://dtbaker.net/random-bits/android-unknown-symbol-_global_offset_table_/
按照里面的方法修改重新编译内核及模块后成功加载,重点翻译如下
在加载模块时系统提示我一个错误
[ 1525.047424] bcm4329: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)
确认使用了正确的工具链,但依旧insmod加载模块时有这个错误
为了解决这个问题,打开内核的Makefile文件,在其中将
MODFLAGS = -DMODULE -march=armv7-a -mfpu=vfpv3 -ftree-vectorize
修改为
MODFLAGS = -DMODULE -march=armv7-a -mfpu=vfpv3 -ftree-vectorize -fno-pic
然后重新编译内核,模块,问题解决,模块成功加载
如果你找不到MODFLAGS这个定义,试试
CFLAGS_MODULE =
然后将其修改为
CFLAGS_MODULE = -fno-pic
这里使用的是NetworkManager使用nmcli命令进行连接,部分没有安装的设备可以使用iw以及iwlist指令进行网络扫描与连接
参考:
iwlist/iwconfig/iw命令_运维_unbroken-CSDN博客
linux下如何使用命令连接wifi_运维_小马的博客-CSDN博客
Wireless network configuration (简体中文) - ArchWiki
首先下载NetworkManager
$sudo apt install network-manager
ifconfig -a 查看你的无线网卡名称
sements@LEE-IMX6:/etc/network/interfaces.d$ ifconfig -a
can0: flags=128 mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 28
can1: flags=128 mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 29
enxac35eecf5943: flags=4099 mtu 1500
ether ac:35:ee:cf:59:43 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163 mtu 1500
inet 192.168.2.179 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::40f8:22ff:feb3:d5d prefixlen 64 scopeid 0x20
ether 42:f8:22:b3:0d:5d txqueuelen 1000 (Ethernet)
RX packets 8444 bytes 8615327 (8.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4143 bytes 689199 (689.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4098 mtu 1500
ether 26:83:5f:2c:4d:90 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 90 bytes 6620 (6.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 90 bytes 6620 (6.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
sit0: flags=128 mtu 1480
sit txqueuelen 0 (IPv6-in-IPv4)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
使用 ifconfig 指令看不到你的网卡,但是使用 ifconfig -a 指令可以看到时,可以使用
$ ifconfig 网卡名称 up
将你的网卡唤起
这里我的无线网卡名称被命名为enxac35eecf5943
在dmesg里面看到
[ 105.617109] rtl8723bu 1-1.4:1.2 enxac35eecf5943: renamed from wlan0
发现其被重命名了?这个问题目前未解决
使能无线网卡,发现NetworkManager未运行,重启一下NetworkManager
$sudo ifconfig enxac35eecf5943 up
$sudo systemctl restart NetworkManager
扫描wifi
sements@LEE-IMX6:/etc/network/interfaces.d$ nmcli device wifi
IN-USE SSID MODE CHAN RATE SIGNAL BARS SECURITY
GENIUS Infra 10 44 Mbit/s 94
**** WPA1 WPA2
???? Infra 12 44 Mbit/s 82
**** WPA1 WPA2
Xiaomi_C89E Infra 7 16 Mbit/s 58
*** WPA1 WPA2
连接wifi
sements@LEE-IMX6:/etc/network/interfaces.d$ sudo nmcli d wifi connect "GENIUS" password "genius2018"
Device 'enxac35eecf5943' successfully activated with 'aa18f13d-32d5-41fa-a7f4-406bc75f8eaa'.
查看网络连接
sements@LEE-IMX6:~$ ifconfig
enxac35eecf5943: flags=4163 mtu 1500
inet 192.168.2.12 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::109b:fe18:bae2:735a prefixlen 64 scopeid 0x20
ether ac:35:ee:cf:59:43 txqueuelen 1000 (Ethernet)
RX packets 89 bytes 36454 (36.4 KB)
RX errors 0 dropped 19 overruns 0 frame 0
TX packets 16 bytes 2188 (2.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163 mtu 1500
inet 192.168.2.179 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::40f8:22ff:feb3:d5d prefixlen 64 scopeid 0x20
ether 42:f8:22:b3:0d:5d txqueuelen 1000 (Ethernet)
RX packets 9150 bytes 8681614 (8.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4810 bytes 814092 (814.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 94 bytes 6940 (6.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 94 bytes 6940 (6.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
可以看到,已经成功连接,这里我板子上eth0口还插着网线
由于已经设置好NetworkManager进行wifi连接,所以我们这里只需要开机时加载模块即可
也可以直接把RTL8723BU在内核编译阶段设置为编译到内核内部
在/etc/rc.local文件中修改如下
#!/bin/bash
#load 8723bu
insmod /home/sements/8723bu.ko
startx&
exit 0