RK3562 移植 rtl8723ds WIFI 驱动
平台: RK3562,android13。
背景:最近需要移植 rtl8723ds wifi驱动。这款驱动之前RK有做过适配。但是在android13版本下,SDK里面的驱动旧了。于是找wifi厂商要了新驱动。
重新移植。记录下遇到的一些编译问题。
按照RK的SDK文档,先修改下rtl8723ds 驱动。如下:
第一步:修改rtl8723ds的makefile:
1. Realtek 发布的 wifi 驱动默认是平台是 PC 需要修改成 ROCKCHIP
CONFIG_PLATFORM_I386_PC = y 修改为 CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_ARM_RK3188 = n 修改为 CONFIG_PLATFORM_ARM_RK3188 = y
2. Rockchip 平台 wifi 驱动是以 ko 形式存在,因此需要将驱动 module 名修改为 8723ds
ifeq ($(CONFIG_PLATFORM_ARM_RK3188), y)
EXTRA_CFLAGS+=
-DCONFIG_LITTLE_ENDIAN
-DCONFIG_PLATFORM_ANDROID
-DCONFIG_PLATFORM_ROCKCHIPS
……
#EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC //注意这个要注释掉 Need
to comment this out
……
MODULE_NAME := 8723ds
Endif
第二步:修改驱动入口函数
因为rtl8723ds 是sdio接口的。找到入口函数: os_dep/linux/sdio_intf.c 在文件末尾换成RK注册接口。
#include "rtw_version.h"
#include <linux/rfkill-wlan.h>
extern int get_wifi_chip_type(void);
extern int rockchip_wifi_power(int on);
extern int rockchip_wifi_set_carddetect(int val);
int rockchip_wifi_init_module_rtkwifi(void)
{
//#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
// int type = get_wifi_chip_type();
// if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
//#endif
printk("\n");
printk("=======================================================\n");
printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
printk("=======================================================\n");
printk("Realtek 8723DS SDIO WiFi driver (Powered by Rockchip,Ver %s) init.\n", DRIVERVERSION);
rockchip_wifi_power(1);
rockchip_wifi_set_carddetect(1);
return rtw_drv_entry();
}
void rockchip_wifi_exit_module_rtkwifi(void)
{
//#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
// int type = get_wifi_chip_type();
// if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
//#endif
printk("\n");
printk("=======================================================\n");
printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
printk("=======================================================\n");
printk("Realtek 8723DS SDIO WiFi driver (Powered by Rockchip,Ver %s) init.\n", DRIVERVERSION);
rtw_drv_halt();
rockchip_wifi_set_carddetect(0);
rockchip_wifi_power(0);
}
#ifdef CONFIG_WIFI_BUILD_MODULE
module_init(rockchip_wifi_init_module_rtkwifi);
module_exit(rockchip_wifi_exit_module_rtkwifi);
#else
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
late_initcall(rockchip_wifi_init_module_rtkwifi);
module_exit(rockchip_wifi_exit_module_rtkwifi);
#else
EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
#endif
#endif
//module_init(rtw_drv_entry);
//module_exit(rtw_drv_halt);
编译遇到的问题记录如下:
error: switch condition has boolean value [-Werror,-Wswitch-bool]
switch (TXPWR_LMT_ALTERNATE_DEFINED(txpwr_lmt)) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC [M] /home/data/rb-a3562/external/wifi_driver/aic8800/aic8800_fdrv/aicwf_compat_8800dc.o
CC [M] /home/data/rb-a3562/external/wifi_driver/rtl8723cs/core/rtw_mlme.o
1 error generated.
这是编译器的布尔条件警告错误,在Makefil里面添加如下规则,编译通过。
EXTRA_CFLAGS += -Wno-switch-bool EXTRA_CFLAGS += -Wno-error=switch-bool EXTRA_CFLAGS += -Wno-switch EXTRA_CFLAGS += -Wno-error=switch
具体解释如下:
- -Wno-switch-bool : 禁用switch语句使用布尔值的警告
- -Wno-error=switch-bool : 防止switch-bool警告被视为错误
- -Wno-switch : 禁用一般的switch语句相关警告
- -Wno-error=switch : 防止switch相关警告被视为错误
遇到的第二个编译错误如下
ERROR: modpost: module 8723ds uses symbol kernel_write from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it. ERROR: modpost: module 8723ds uses symbol kernel_read from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it. ERROR: modpost: module 8723ds uses symbol filp_open from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it. ERROR: modpost: module 8723ds uses symbol kern_path from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it. scripts/Makefile.modpost:152: recipe for target '/home/data/rb-a3562/external/wifi_driver/Module.symvers' failed make[1]: *** [/home/data/rb-a3562/external/wifi_driver/Module.symvers] Error 1 make[1]: *** Deleting file '/home/data/rb-a3562/external/wifi_driver/Module.symvers' Makefile:1821: recipe for target 'modules' failed make: *** [modules] Error 2 make: Leaving directory '/home/data/rb-a3562/kernel-5.10'
这是 VFS 符号依赖,解决方法如下:
在rtl8723ds\os_dep\linux\os_intfs.c目录下添加 MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
最后重新编译测试,WIFI能正常使用。
浙公网安备 33010602011771号