Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    【FAQ】全志D1芯片 如何移植 rtl8821cu wifi 驱动到 Linux-5.4内核?

    全志方案讨论区
    d1 faq 技术支持
    2
    2
    803
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • q1215200171
      budbool LV 8 last edited by

      问题背景
      移植 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 内核版本时运行的错误:

      04e7d843b1934a02af9d0335885f837c.jfif
      出现该问题的原因是 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
              },
      
      1 Reply Last reply Reply Quote Share 0
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • S
        szricky LV 2 last edited by

        这个有用。

        在 D1s 移植 RTL8189 上是有同样的问题。

        1 Reply Last reply Reply Quote Share 0
        • 1 / 1
        • First post
          Last post

        Copyright © 2021 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

        行为准则 | 用户协议 | 隐私权政策