我是靠谱客的博主 苗条板栗,最近开发中收集的这篇文章主要介绍[RK3399 Android7.1.2]新增wifi&bt模块:rtl8822cs驱动以及解决所遇问题,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Platform: ROCKCHIP
Chip: RK3399
OS: Android7.1.2
Kernel: 4.4.126

背景

硬件替换芯片rtl8822cs;未改代码情况下,WIFI:点pown on立即跳到off
bt:点on 无反应,串口打印

[  875.649281] ret = 0
[  875.704811] [BT_RFKILL]: bt shut off power
[  875.726554] [BT_RFKILL]: rfkill_rk_set_power: set bt wake_host high!
[  875.771901] [BT_RFKILL]: ENABLE UART_RTS
[  875.875559] [BT_RFKILL]: DISABLE UART_RTS
[  875.875683] [BT_RFKILL]: bt turn on power
[  875.875708] [BT_RFKILL]: Request irq for bt wakeup host
[  875.875748] [BT_RFKILL]: ** disable irq

在这里插入图片描述

代码改动

1.修改WIFI配置的dtsi:



    wireless-wlan {
        compatible = "wlan-platdata";
        rockchip,grf = <&grf>;
        wifi_chip_type = "rtl8822cs";
        sdio_vref = <1800>;
        WIFI,host_wake_irq = <&gpio0 3 GPIO_ACTIVE_HIGH>; /* GPIO0_a3 */
        status = "okay";
    };

2.2.添加驱动
将供应商提供的驱动放在目录:kerneldriversnetwirelessrockchip_wlan
修改当前目录下makefile:

obj-$(CONFIG_RTL8822CS)    += rtl8822cs/
修改kconfig:
source "drivers/net/wireless/rockchip_wlan/rtl8822cs/Kconfig"

修改rtl8822cs/makefile:

    CONFIG_PLATFORM_I386_PC=n
    CONFIG_PLATFORM_ARM_RK3188=y
make ARCH=arm64 menuconfig 添加勾选
   Device Drivers  --->  
   [*] Network device support  --->  
    [*]   Wireless LAN  --->    
    [*]   Rockchip Wireless LAN support  --->  
    <M>   Realtek 8822C SDIO WiFi  

3.添加芯片类型枚举:
kernel/net/rfkill/rfkill-wlan.c

int get_wifi_chip_type(void)添加


    } else if (strcmp(wifi_chip_type_string, "rtl8822cs") == 0) {
        type = WIFI_RTL8822CS;
kernel/include/linux/rfkill-wlan.h
添加芯片枚举:
    enum {
    WIFI_RK901,
    WIFI_RK903,
    WIFI_AP6181,
    WIFI_AP6210,
    WIFI_AP6XXX_SERIES,
    WIFI_RTL8188EU,
    WIFI_RTL8192DU,
    WIFI_RTL8723AS,
    WIFI_RTL8723BS,
    WIFI_RTL8822CS,
    WIFI_RTL8812AU,
    WIFI_RTL8822CS,
    WIFI_RTL_SERIES,
    WIFI_ESP8089,
    TYPE_MAX,
    };
  1. 然后编译内核 编译出8822cs.ko
    5.上层VID PID加进去,命令查看后调整正确。
cat /sys/bus/sdio/devices/mmc2:0001:1/uevent
DRIVER=rtl88x2cs
SDIO_CLASS=07
SDIO_ID=024C:C822
MODALIAS=sdio:c07v024CdC822

这一步如果devices目录下没有节点 可以检查下硬件。

添加: hardwarelibhardware_legacywifirk_wifi_ctrl.c

static wifi_device supported_wifi_devices[] = {
+   {"RTL8822CS",   "024c:c822"},
    {"RTL8188FU",    "0bda:f179"},
    {"RTL8822BU",    "0bda:b82c"},
    {"RTL8189ES",    "024c:8179"},
          ALOGD("PCIE WIFI identify sucess");
     else {
            ALOGD("maybe there is no usb wifi or sdio or pcie wifi,set default wifi module Brocom APXXX");
-           strcpy(recoginze_wifi_chip, "APXXX");
+           strcpy(recoginze_wifi_chip, "RTL8822CS");
            identify_sucess = 1 ;
                }
        }

diff --git a/wifi/wifi.c b/wifi/wifi.c
index 04da01c…73d0f5d 100755
— a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -95,6 +95,7 @@ extern int ifc_down(const char *name);

#define RTL8192DU_DRIVER_MODULE_PATH "/system/lib/modules/8192du.ko"
#define RTL8812AU_DRIVER_MODULE_PATH "/system/lib/modules/8812au.ko"
#define RTL8822BE_DRIVER_MODULE_PATH "/system/lib/modules/8822be.ko"
+#define RTL8822CS_DRIVER_MODULE_PATH "/system/lib/modules/8822cs.ko"
#define SSV6051_DRIVER_MODULE_PATH   "/system/lib/modules/ssv6051.ko"
#define ESP8089_DRIVER_MODULE_PATH   "/system/lib/modules/esp8089.ko"
#define BCM_DRIVER_MODULE_PATH       "/system/lib/modules/bcmdhd.ko"
@@ -112,6 +113,7 @@ extern int ifc_down(const char *name);
#define RTL8189FS_DRIVER_MODULE_NAME "8189fs"
#define RTL8192DU_DRIVER_MODULE_NAME "8192du"
#define RTL8812AU_DRIVER_MODULE_NAME "8812au"
+#define RTL8812AU_DRIVER_MODULE_NAME "8822cs"
#define SSV6051_DRIVER_MODULE_NAME      "ssv6051"
#define ESP8089_DRIVER_MODULE_NAME      "esp8089"
#define BCM_DRIVER_MODULE_NAME       "bcmdhd"
@@ -206,6 +208,7 @@ wifi_ko_file_name module_list[] =
        {"RTL8189ES", RTL8189ES_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
        {"RTL8723BS", RTL8723BS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
        {"RTL8723CS", RTL8723CS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
+       {"RTL8822CS", RTL8822CS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
        {"RTL8723DS", RTL8723DS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
        {"RTL8812AU", RTL8812AU_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
        {"RTL8189FS", RTL8189FS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},

调试命令

            cat /sys/bus/sdio/devices/mmc2:0001:1/uevent         //可查看SDIO设备ID  
            cat /sys/kernel/debug/mmcx/ios                         //可查看WIFI_sdio 相关信息
            logcat | grep WifiHW                                //查看WIFI加载信息

WIFI 芯片识别流程

  1. 开机对 wifi 模块上电,并自动进行扫描 sdio 操作。
  2. 系统启动打开 wifi 操作时, 分别对系统 sys/bus/sdio(sdio wifi), sys/bus/usb(usb wifi),
    sys/bus/pic (pcie wifi )文件系统下的 uevent 进行读取。
  3. 获取到 wifi 芯片 vid pid 加载相应的 wifi ko 驱动。
  4. 识别到 wifi 类型后加载不同的 wpa_supplicant 参数启动 wifi。

所遇问题

1.打印如下:-5 :IO error

18:15:12[    2.938387] mmc_host mmc2: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
18:15:12[    2.951718] dwmmc_rockchip fe310000.dwmmc: 1 slots initialized
18:15:12[    2.952814] rockchip-dmc dmc: Failed to get leakage
18:15:12[    2.953123] rockchip-dmc dmc: Failed to get pvtm
18:15:12[    2.954708] rockchip-dmc dmc: could not find power_model node
18:15:12[    2.961065] dwmmc_rockchip fe310000.dwmmc: card claims to support voltages below defined range
18:15:12[    2.961680] rk808-rtc rk808-rtc: setting system clock to 2013-01-18 09:54:29 UTC (1358502869)
18:15:12[    2.963159] It doesn't contain Rogue gpu
18:15:12[    2.975194] mmc_host mmc2: Voltage change didn't complete
18:15:12[    2.977144] mmc2: error -5 whilst initialising SDIO card

2.sdio_clk输出只到200khz 没达到50Mhz
3.sdio的reset脚 复位后拉低

解决

1 . 2.3 问题:打入补丁后正常
Realtek 88x2BS系列: SDIO 3.0是1.8V,原先代码是走到一个函数里设置信号电压为1.8V,正常就可继续流程 错误返回I/O error ;所以要跳过设置信号电压这个步骤即可

--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -648,8 +648,14 @@ try_again:
      * to make sure which speed mode should work.
      */
     if (!powered_resume && (rocr & ocr & R4_18V_PRESENT)) {
+#if 0 /* SDIO 3.0 patch for Realtek 88x2BS */
         err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180,
                     ocr_card);
+#else
+        pr_warn("%s: Skip set signal voltage to 1.8vn",
+                mmc_hostname(host));
+        err = 0;
+#endif
         if (err == -EAGAIN) {
             mmc_sdio_resend_if_cond(host, card);
             retries--;

BT模块

1.替换rtkbt
2.打入system.patch

最后

以上就是苗条板栗为你收集整理的[RK3399 Android7.1.2]新增wifi&bt模块:rtl8822cs驱动以及解决所遇问题的全部内容,希望文章能够帮你解决[RK3399 Android7.1.2]新增wifi&bt模块:rtl8822cs驱动以及解决所遇问题所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部