• 全志A40i android7.1 移植wifi驱动的一般流程


    一,问题分析

    一般情况下移植一款模组,会涉及到驱动,firmware, hal层,方案端的适配。
    下面以RTL8723ds为例详细列出移植的通用步骤。


    二,移植步骤

    1. 移植Wi-Fi驱动

    RTL原厂或者已经支持的其他把内核版本中获取驱动源码。
    1.1. 源码重命名为rtl8723ds后放到lichee/linux-3.10/drivers/net/wireless/
    1.2. 修改 wireless 目录下的 Kconfig,添加:

    source "drivers/net/wireless/rtl8723ds/Kconfig"
    
    • 1

    1.3. 修改 wireless 目录下的 Makefile添加

    obj-$(CONFIG_RTL8822CS) += rtl8723ds/
    
    • 1

    1.4. 修改 rtl8723ds 目录下的 Makefile

    CONFIG_PLATFORM_I386_PC = n
    ....
    CONFIG_PLATFORM_ARM_SUNxI = y
    
    • 1
    • 2
    • 3

    1.5. 修改 platform 文件
    SDIO 接口模组 路径:

    lichee/linux-3.10/drivers/net/wireless/rtl8189fs/platform/platform_ARM_SUNnI_sdio.c
    
    • 1

    可以从其他已经支持的模组中拷贝。

    完成以上步骤之后,在lichee/linux-3.10/,执行 make menuconfig ARCH=arm,将所需 Wi-Fi driver 编译为模块,进行编译。


    2. 添加 BT firmware

    路径:android/hardware/realtek/bluetooth/firmware
    把 rtl8723ds_config 和 rtl8723ds_fw 添加到此目录,Wi-Fi 不需要 Firmware。

    3. 确认 dts 中模组的 GPIO pin 正确分配

    lichee/linux-3.10/arch/arm/boot/dts/sun50iw1p1-perf1_v1_0.dts

         wlan:wlan {
             compatible = "allwinner,sunxi-wlan";
             clocks = <&clk_losc_out>;
             wlan_power = "vcc-wifi";
             wlan_io_regulator = "vcc-wifi-io";
             wlan_busnum = <1>;
             wlan_regon = <&r_pio PL 2 1 1 1 0>;
             wlan_hostwake = <&r_pio PL 3 6 0 0 0>;
             status = "okay";
         };
         bt:bt {
             compatible = "allwinner,sunxi-bt";
             clocks = <&clk_losc_out>;
             bt_power = "vcc-wifi";
             bt_io_regulator = "vcc-wifi-io";
             bt_rst_n = <&r_pio PL 4 1 1 1 0>;
             status = "okay";
         };
         btlpm:btlpm {
             compatible = "allwinner,sunxi-btlpm";
             uart_index = <1>;
             bt_wake = <&r_pio PL 6 1 1 1 1>;
             bt_hostwake = <&r_pio PL 5 6 0 0 0>;
             status = "okay";
         };
     };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    wifi dts配置说明:

    “clocks” 用于配置使用主控提供的 32k 时钟;
    “pinctrl-0” 用于配置 pin 的复用功能;
    “pinctrl-names” 用于配置 pin state;
    4 “wlan_busnum” 表示 WiFi 所使用的 SDIO 控制器号;
    “wlan_power” 表示给 WiFi 模组供电的 regulator 名称;
    “wlan_io_regulator” 表示给 WiFi 模组的 GPIO 供电的 regulator 名称;
    “wlan_regon” WiFi 模组 power on 控制引脚;
    “wlan_hostwake” 表示 WiFi 唤醒主控的 GPIO;
    “chip_en” 表示 WiFi 模组使能引脚,硬件未使用时不配置;
    “power_en” 表示模块外部的电源开关控制引脚;
    bt dts配置说明:
    “clocks” 用于配置使用主控提供的 32k 时钟;
    “bt_power” 表示 BT 模组所用的供电,与 wlan_power 相同;
    “bt_io_regulator” 表示 BT 模组所用的 IO 供电,与 wlan_regulator 相同;
    “bt_rst_n” 表示 Bt 模组 power on 控制引脚;
    “uart_index” 表示 BT 模组使用的硬件通信端口号;
    “bt_wake” 表示 BT 模组休眠后被唤醒时的控制引脚;
    “uart_index” 表示 BT 模组使用的硬件通信端口号;
    “bt_hostwake” 表示 BT 模组中断输出引脚,用于唤醒 AP;
    当前 SDK 中的 board.dts 已经有模组的 GPIO 配置,如果硬件连接不一样,请根据实际硬件原理图进行配置

    4. 方案端适配 Wi-Fi/BT 模组加载

    android/device/softwinner/a40-p1/BoardConfig.mk

    # wifi and bt configuration
    BOARD_WIFI_VENDOR := realtek
    BOARD_USR_WIFI    := rtl8723ds
    WIFI_DRIVER_MODULE_PATH := "/system/vendor/modules/8723ds.ko"
    WIFI_DRIVER_MODULE_NAME := "8723ds"
    WIFI_DRIVER_MODULE_ARG  := "ifname=wlan0 if2name=p2p0"
    
    # 2. Bluetooth Configuration
    BOARD_BLUETOOTH_VENDOR    := realtek
    BOARD_HAVE_BLUETOOTH_NAME := rtl8723ds
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    “BOARD_WIFI_VENDOR := realtek” 指明使用 realtek 的 Wi-Fi 模组,常见的有 broadcom、realtek、xradio;
    “BOARD_USR_WIFI” 指明具体使用的 Wi-Fi 型号;
    “WIFI_DRIVER_MODULE_PATH” 表示该模组的驱动 ko 的路径;
    “WIFI_DRIVER_MODULE_NAME” 表示该模组的驱动名称;realtek 的各个 Wi-Fi 的驱动名称不一样,需根据实际情况设置;
    “BOARD_BLUETOOTH_VENDOR” 指明使用那个厂商的 bt 模组,常见的有 broadcom、realtek、xradio;
    “BOARD_HAVE_BLUETOOTH_NAME” 指定蓝牙模组型号。

    5.配置init文件

    各平台通用,一般不需要修改。
    android/device/softwinner/a40-common/init.sun8iw11p1.rc android/device/softwinner/a40-common/init.sun8iw11p1.rc

    5.1. Wi-Fi资源和服务配置

    on post-fs-data
    # Create the directories used by the Wireless subsystem
    mkdir /data/vendor/wifi 0771 wifi wifi
    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
    # broadcom/realtek/xradio wifi sta p2p concurrent service
    service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ -O/data/vendor/wifi/wpa/sockets -dd \ -g@android:wpa_wlan0
    interface android.hardware.wifi.supplicant@1.0::ISupplicant default
    interface android.hardware.wifi.supplicant@1.1::ISupplicant default
    interface android.hardware.wifi.supplicant@1.2::ISupplicant default
    socket wpa_wlan0 dgram 660 wifi wifi
    class main
    disabled
    oneshot```
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    5.2.BT资源和服务配置

    on post-fs-data
    # Create the directories used by the Wireless subsystem
    mkdir /data/vendor/wifi 0771 wifi wifi
    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
    # broadcom/realtek/xradio wifi sta p2p concurrent service
    service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ -O/data/vendor/wifi/wpa/sockets -dd \ -g@android:wpa_wlan0
    interface android.hardware.wifi.supplicant@1.0::ISupplicant default
    interface android.hardware.wifi.supplicant@1.1::ISupplicant default
    interface android.hardware.wifi.supplicant@1.2::ISupplicant default
    socket wpa_wlan0 dgram 660 wifi wifi
    class main
    disabled
    oneshot
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    5.3.init.wireless.bluetooth.rc相关配置文件

    on boot
    # UART device
    chmod 0660 ${persist.vendor.bluetooth_port}
    chown bluetooth net_bt_admin ${persist.vendor.bluetooth_port} # bluetooth power up/down interface
    chmod 0660 /sys/class/rfkill/rfkill0/state
    chmod 0660 /sys/class/rfkill/rfkill0/type
    chown bluetooth net_bt_admin /sys/class/rfkill/rfkill0/state
    chown bluetooth net_bt_admin /sys/class/rfkill/rfkill0/type
    write /sys/class/rfkill/rfkill0/state 0 # bluetooth MAC address programming
    chown bluetooth net_bt_admin ${ro.bt.bdaddr_path}
    on property:persist.vendor.bluetooth_vendor=broadcom
    insmod /vendor/modules/bcm_btlpm.ko
    setprop vendor.driver.lpm.load 1
    on property:persist.vendor.bluetooth_vendor=realtek
    insmod /vendor/modules/rtl_btlpm.ko
    setprop vendor.driver.lpm.load 1
    on property:persist.vendor.bluetooth_vendor=xradio
    insmod /vendor/modules/xradio_btlpm.ko
    insmod /vendor/modules/xradio_btfdi.ko
    setprop vendor.driver.lpm.load 1
    on property:persist.vendor.bluetooth_vendor=sprd
    insmod /vendor/modules/sprdbt_tty.ko
    chmod 0666 /sys/class/rfkill/rfkill1/state
    chmod 0666 /sys/class/rfkill/rfkill1/type
    chmod 0660 /dev/ttyBT0
    chown bluetooth net_bt_admin /dev/ttyBT0
    setprop vendor.driver.lpm.load 1
    on property:vendor.driver.lpm.load=1
    chmod 0660 /proc/bluetooth/sleep/lpm
    chmod 0660 /proc/bluetooth/sleep/btwrite
    chmod 0660 /proc/bluetooth/sleep/btwake
    chown bluetooth net_bt_admin /proc/bluetooth/sleep/lpm
    chown bluetooth net_bt_admin /proc/bluetooth/sleep/btwrite
    chown bluetooth net_bt_admin /proc/bluetooth/sleep/btwake
    on property:persist.vendor.bluetooth_vendor=realtek && property:sys.boot_completed=1
    setprop persist.vendor.bluetooth.rtkcoex true
    on property:persist.vendor.bluetooth_vendor=realtek && property:sys.boot_completed=0
    setprop persist.vendor.bluetooth.rtkcoex false
    on property:persist.vendor.bluetooth_vendor=xradio && property:vold.post_fs_data_done=1
    mkdir /data/vendor/bluetooth 0771 bluetooth bluetooth
    mkdir /data/vendor/bluetooth/sdd 0770 bluetooth bluetooth
    mkdir /data/vendor/bluetooth/fdi 0770 bluetooth bluetooth```
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
  • 相关阅读:
    NVIDIA Jetson测试安装yolox过程记录
    IT人的2022演讲
    开源医疗大模型Llama3-Aloe-8B-Alpha,性能超越 MedAlpaca 和 PMC-LLaMA
    关闭win10安全模式引导
    保障人脸安全!顶象发布《人脸识别安全白皮书》
    Worthington过氧化物酶活性的6种测定方法
    TCP和UDP C#代码实战
    支付行业稳步发展,畅联助企惠民、合规前行
    【单元测试】--测试驱动开发(TDD)
    JAVA 中的代码生成包 CGLIB (Code Generation Library)
  • 原文地址:https://blog.csdn.net/weixin_45639314/article/details/137351706