【FAQ】全志D1芯片 如何移植 rtl8821cu wifi 驱动到 Linux-5.4内核?
-
问题背景
移植 Linux-4.9 或之前的内核版本下的 wifi 驱动到 Linux-5.4 内核版本时会出现编译和运行错误,
该 FAQ 主要用于帮助开发人员解决驱动移植出现的问题。问题分析
移植到 Linux-5.4 内核版本时出现如下编译错误:WARNING: module 8821cu uses symbol kernel_read from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it.
出现该 WANRING 的原因是内核版本升级后文件系统存在差异,驱动调用了 kernel_read()和 kernel_write() 函数,需要进行 import VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver 处理。
移植到 Linux-5.4 内核版本时运行的错误:
出现该问题的原因是 Linux-5.3 及以后版本 cfg80211.h 里结构体 wiphy_vendor_command 新增了变量 policy 和 maxattr。解决方案
出现编译错误时解决方案如下:
diff --git a/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c b/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c index c4b515763ac8..466a3b27f521 100644 --- a/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c +++ b/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c @@ -28,6 +28,8 @@ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); MODULE_VERSION(DRIVERVERSION); +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
出现运行错误时解决方案为遍历驱动里所有使用 wiphy_vendor_command 结构体并修改如下:
diff --git a/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c b/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c index 6bac27d37766..09e24dcc9480 100644 --- a/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c +++ b/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c @@ -1756,6 +1756,11 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, .doit = rtw_cfgvendor_gscan_get_capabilities +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) + , + .policy = VENDOR_CMD_RAW_DATA, + .maxattr = 1 +#endif },
-
-
-
-
-
-
-
这个有用。
在 D1s 移植 RTL8189 上是有同样的问题。
-
-
你好,现在正在移植wifi驱动到F133,在加载内核时出现了:
module uses symbol (kernel_read) from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it.,看上面说的:
出现该 WANRING 的原因是内核版本升级后文件系统存在差异,驱动调用了 kernel_read()和 kernel_write() 函数,需要进行 import VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver 处理。
这个怎么操作? -
@wyljkl 出现编译错误时解决方案如下:
diff --git a/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c b/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c index c4b515763ac8..466a3b27f521 100644 --- a/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c +++ b/drivers/net/wireless/rtl8821cu/os_dep/linux/os_intfs.c @@ -28,6 +28,8 @@ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); MODULE_VERSION(DRIVERVERSION); +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
出现运行错误时解决方案为遍历驱动里所有使用 wiphy_vendor_command 结构体并修改如下:
diff --git a/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c b/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c index 6bac27d37766..09e24dcc9480 100644 --- a/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c +++ b/drivers/net/wireless/rtl8821cu/os_dep/linux/rtw_cfgvendor.c @@ -1756,6 +1756,11 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, .doit = rtw_cfgvendor_gscan_get_capabilities +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) + , + .policy = VENDOR_CMD_RAW_DATA, + .maxattr = 1 +#endif },
-
@q1215200171 收到,感谢,可以了
-
-
几乎是同类型的芯片 rtl8818FU,也是USB接口的WiFi芯片,但是移植编译加载后
[ 65.256086] 8188fu: loading out-of-tree module taints kernel. [ 91.352280] RTW: module init start [ 91.352292] RTW: rtl8188fu v5.11.5.4-0-g65b8f0aad.20220413 [ 91.352298] RTW: build time: Feb 28 2023 11:52:06 [ 91.352307] RTW: rtw_drv_entry: power on failed!!(-22) [ 91.352312] RTW: module init ret=-1 [ 117.393206] RTW: module init start [ 117.393217] RTW: rtl8188fu v5.11.5.4-0-g65b8f0aad.20220413 [ 117.393223] RTW: build time: Feb 28 2023 11:52:06 [ 117.393232] RTW: rtw_drv_entry: power on failed!!(-22) [ 117.393237] RTW: module init ret=-1
好像设备注册或者什么出了问题,导致有个变量没有初始化
还有你们没有遇到驱动原本的platform_ARM_SUNxl_usb.c不能使用吗,我很好奇你们你们这个文件中的函数是怎么写的platform_wifi_power_on platform_wifi_power_off
这是我的,大佬看看有问题吗
/****************************************************************************** * * Copyright(c) 2013 - 2017 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * *****************************************************************************/ /* * Description: * This file can be applied to following platforms: * CONFIG_PLATFORM_ARM_SUNXI Series platform * */ #include <drv_types.h> extern int sunxi_usb_disable_hcd(__u32 usbc_no); extern int sunxi_usb_enable_hcd(__u32 usbc_no); extern int sunxi_wlan_get_bus_index(void); extern void sunxi_wlan_set_power(int on); int platform_wifi_power_on(void) { int ret = 0; int wlan_bus_index = sunxi_wlan_get_bus_index(); if (wlan_bus_index < 0) return wlan_bus_index; sunxi_wlan_set_power(1); mdelay(100); sunxi_usb_enable_hcd(wlan_bus_index); return ret; } void platform_wifi_power_off(void) { int wlan_bus_index = sunxi_wlan_get_bus_index(); if (wlan_bus_index < 0) return wlan_bus_index; sunxi_usb_disable_hcd(wlan_bus_index); sunxi_wlan_set_power(0); }
就是platform_wifi_power_on报错才加载失败的,求指点
-
@q1215200171 这个有用
Copyright © 2023 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号