RS9116是Silicon Labs(芯科科技)推出的一款高性能无线SoC(System on Chip,系统级芯片)或无线模块,它提供了全面的多协议无线连接解决方案,记录一下使用芯片实现wifi功能的过程;
1. 开发环境配置
- 硬件平台
- 芯片型号:RS9116.NB0.NL.GENR.LNX.1.2.1
- 内核版本:4.19.78-linux4sam-6.2-icp
- 工具链
- 交叉编译器:
arm-linux-gnueabihf-7.5.0
- 依赖库:libnl-3.5.0
- 交叉编译器:
- 环境变量
1.配置环境变量 export PATH=$PATH:/home/arm/arm-gcc/bin(当前终端有效)
/home/arm/arm-gcc/bin(交叉编译工具所在具体目录)
ubuntu:~/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.1/source/host$ export PATH=$PATH:/home/arm/arm-linux-gnueabihf-7.5.0/bin
2. 编译流程
-
Makefile配置调整
- 内核驱动路径:修改wifi Makefile,指定硬件驱动正确的目录文件
DEF_KERNEL_DIR := /home/arm/armLinuxKernel/armDrive-wifi/lib/modules/4.19.78-linux4sam-6.2-icp/build
- libnl库路径声明:
修改 source/host/wlan/supplicant/linux/wpa_supplicant里的Makefile,添加libnl库相关路径
CFLAGS += -I/home/arm/libnl/armLibnl/include
LIBS += -L/home/arm/libnl/armLibnl/lib -lpthread
- 菜单配置:选择配置环境 make menuconfig
ubuntu:~/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.1/source/host$ make menuconfig
make -C /home/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.1/source/host/config/lxdialog lxdialog
make[1]: Entering directory '/home/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.1/source/host/config/lxdialog'
make[1]: 'lxdialog' is up to date.
make[1]: Leaving directory '/home/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.1/source/host/config/lxdialog'
/home/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.1/source/host/config/Menuconfig config/config.in
Using defaults found in .config
Preparing scripts: functionsloding is done
, parsing.done.
Saving your configuration...
- 交叉编译:make 生成wifi驱动所需相关文件
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
3. 关键问题与解决方案
3.1 编译错误:netlink/genl/genl.h
缺失
- 现象:编译过程相关错误:找不到netlink/genl/genl.h:
../src/drivers/driver_nl80211.c:19:10: fatal error: netlink/genl/genl.h: 没有那个文件或目录
#include <netlink/genl/genl.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:1651: recipe for target '../src/drivers/driver_nl80211.o' failed
make[1]: *** [../src/drivers/driver_nl80211.o] Error 1
make[1]: Leaving directory '/home/arm/rs9116/RS9116.NB0.NL.GENR.LNX.1.2.23/source/host/wlan/supplicant/linux/wpa_supplicant'
Makefile:401: recipe for target 'wpa_supplicant' failed
make: *** [wpa_supplicant] Error 2
- 解决方案:wlan/supplicant/linux/wpa_supplicant/.config 取消注释 CONFIG_LIBNL32=y
# Use libnl 3.2 libraries (if this is selected, CONFIG_LIBNL20 is ignored)
CONFIG_LIBNL32=y
3.2 运行时热点列表获取异常
- 现象:
运行过程相关错误:获取不到热点列表
> scan
OK
> scan_r
bssid / frequency / signal level / flags / ssid
- 解决方案:
修改启动脚本start_sta.sh
,指定nl80211
驱动模式:
# vi start_sta.sh
cat /dev/null > /var/log/messages
sh wlan_enable.sh
./onebox_util rpine0 create_vap wifi0 sta sw_bmiss
#./wpa_supplicant -i wifi0 -D bsd -c sta_settings.conf -ddddt > log1 &
./wpa_supplicant -i wifi0 -D nl80211 -c sta_settings.conf -ddddt > log1 &
最后结果:问题 当前wifi模块处于连接状态时,一段时间后scan返回搜索热点列表只有当前连接的热点信息;
scan
> OK
> scan_r
bssid / frequency / signal level / flags / ssid
50:bd:5f:77:4b:91 2437 -62 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] LGtest
02:36:76:2e:33:1e 2462 -54 [WPA2-PSK-CCMP][ESS] Chnn-net
c0:61:18:73:55:42 2437 -44 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] TP-LINK_2042
90:5d:7c:05:22:cd 5180 -73 [ESS]
90:5d:7c:05:64:c6 2462 -70 [ESS]
8c:a6:df:c5:87:00 2462 -61 [ESS] TP-LINK_7A00
00:07:26:5a:45:13 2427 -47 [WPS][ESS] dlink
> status
bssid=50:bd:5f:77:4b:91
ssid=LGtest
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=TKIP
key_mgmt=WPA2-PSK-CCMP
wpa_state=COMPLETED
p2p_device_address=50:bd:5f:77:4b:91
address=50:bd:5f:77:4b:91
uuid=12345678-9abc-def0-1234-56789abcdef0
> scan
OK
> scan_r
bssid / frequency / signal level / flags / ssid
50:bd:5f:77:4b:91 2412 -59 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] LGtest
> scan
OK
> scan_r
bssid / frequency / signal level / flags / ssid
50:bd:5f:77:4b:91 2412 -59 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] LGtest
4. 功能验证
4.1 扫描结果示例
bssid frequency signal flags ssid
50:bd:5f:77:4b:91 2412 -59 [WPA2-PSK-CCMP] LGtest
c0:61:18:73:55:42 2437 -44 [WPA2-PSK-CCMP] TP-LINK_2042
4.2 连接状态检查
> status
bssid=50:bd:5f:77:4b:91
ssid=LGtest
wpa_state=COMPLETED # 确认连接成功
5. 已知问题与优化方向
- 当前限制:
模块连接后,扫描功能仅返回当前热点(需排查驱动行为或射频状态机逻辑)。 - 优化建议:
- 启用内核调试日志(
dmesg -w
)跟踪射频扫描事件。 - 检查
wpa_supplicant
配置中的scan_cur_freq
参数,禁用频段过滤。
- 启用内核调试日志(
总结:通过定制化配置驱动路径、依赖库版本及运行时参数,成功实现RS9116在ARM平台的WiFi连接功能,为嵌入式无线通信开发提供可靠参考。