当前位置:   article > 正文

Android 开机自动加载新wifi模块驱动_手机wifi驱动

手机wifi驱动

在android ROM 开发中经常会遇到产品更换wifi模块的情况,一般常见的wifi驱动android内核中自带都有,无需过多调试,要是碰上内核中没有的就需要根据厂商提供的驱动进行移植。

wifi驱动移植过程不多说,根据厂商提供的文档说明进行移植编译出驱动文件xxx.ko即可。

在成功编译出驱动ko文件后,手动insmod 加载驱动是可以的,但是开机时不会自动加载,这时可按以下步骤进行调整,让设备开机自动加载新模块的驱动。以USB类型模块为例:

1.通过adb shell lsusb 命令查看wifi的设备名称。

λ adb shell
Hi3798MV200:/ # lsusb
Bus 001 Device 002: ID 1a40:0101
Bus 001 Device 003: ID 1a40:0101
Bus 004 Device 002: ID 1d5c:2000
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0001
Bus 003 Device 001: ID 1d6b:0002
Bus 004 Device 001: ID 1d6b:0003
Bus 001 Device 004: ID 1a40:0101
Bus 001 Device 005: ID 1a86:7523
Bus 001 Device 006: ID 046d:c534
Bus 001 Device 007: ID 248a:8367
Bus 001 Device 008: ID 174c:55aa
Bus 001 Device 009: ID 0bda:8152

可通过拔插排除无关usb设备或查看usb设备的具体信息来判断是哪一个,比如我目前用的rtl8188fu模块的设备名称为:0bda:f179

2.添加该设备名称到系统支持的wifi设备列表中:hardware\libhardware_legacy\wifi\wifi.c

每个模块名称与设备名称一一对应{WIFI_REALTEK_RTL8188FU, "0bda:f179"},

  1. /* Product ID of supported WiFi devices */
  2. static wifi_device_s devices[] = {
  3. {WIFI_RALINK_MT7601U, "148f:7601"},
  4. {WIFI_REALTEK_RTL8188EUS, "0bda:8179"},
  5. {WIFI_REALTEK_RTL8188ETV, "0bda:0179"},
  6. {WIFI_REALTEK_RTL8192EU, "0bda:818b"},
  7. {WIFI_REALTEK_RTL8812AU, "0bda:8812"},
  8. {WIFI_REALTEK_RTL8723BU, "0bda:b720"},
  9. {WIFI_MEDIATEK_MT7632U, "0e8d:7632"},
  10. {WIFI_MEDIATEK_MT7662U, "0e8d:7662"},
  11. {WIFI_MEDIATEK_MT7612U, "0e8d:7612"},
  12. {WIFI_REALTEK_RTL8821AU, "0bda:0823"},
  13. {WIFI_ATHEROS_QCA6174, "168c:003e"},
  14. {WIFI_REALTEK_RTL8822BU, "0bda:b82c"},
  15. {WIFI_REALTEK_RTL8822BE, "10ec:b822"},
  16. {WIFI_HISI_HI1131C, "0296:5347"},
  17. {WIFI_AMPAK_AP6356S, "02D0:4356"},
  18. {WIFI_REALTEK_RTL8188FU, "0bda:f179"},
  19. {WIFI_MEDIATEK_MT7662TE, "14c3:7662"},
  20. {WIFI_MEDIATEK_MT7662TU, "0e8d:76a0"},
  21. {WIFI_REALTEK_RTL8821CU, "0bda:c811"}
  22. };

WIFI_REALTEK_RTL8188FU是我们自定义的名称,需要先在头文件的模块名称列表中声明:

\hardware\libhardware_legacy\include\hardware_legacy\wifi.h

  1. /* ID of supported WiFi devices */
  2. typedef enum {
  3. WIFI_RALINK_MT7601U,
  4. WIFI_REALTEK_RTL8188EUS,
  5. WIFI_REALTEK_RTL8188ETV,
  6. WIFI_REALTEK_RTL8192EU,
  7. WIFI_REALTEK_RTL8812AU,
  8. WIFI_REALTEK_RTL8723BU,
  9. WIFI_MEDIATEK_MT7632U,
  10. WIFI_MEDIATEK_MT7662U,
  11. WIFI_MEDIATEK_MT7612U,
  12. WIFI_REALTEK_RTL8821AU,
  13. WIFI_ATHEROS_QCA6174,
  14. WIFI_REALTEK_RTL8822BU,
  15. WIFI_REALTEK_RTL8822BE,
  16. WIFI_HISI_HI1131C,
  17. WIFI_AMPAK_AP6356S,
  18. WIFI_REALTEK_RTL8188FU,
  19. WIFI_MEDIATEK_MT7662TE,
  20. WIFI_MEDIATEK_MT7662TU,
  21. WIFI_REALTEK_RTL8821CU,
  22. WIFI_INVALID_DEVICE = ~0x0 ,
  23. } wifi_id_e;

3.声明wifi新模块要加载的驱动名称rtl8188fu.ko和位置:wifi.c中

  1. #define DRIVER_MODULE_RTL8188FU 2, \
  2. { \
  3. {"cfg80211",MODULE_PATH"cfg80211.ko","","cfg80211 "}, \
  4. {"rtl8188fu",MODULE_PATH"rtl8188fu.ko","rtw_channel_plan=0x0C ifname=wlan0 if2name=p2p0","rtl8188fu "} \
  5. }

4.将声明的新驱动模块DRIVER_MODULE_RTL8188FU添加到系统对应的驱动列表中:wifi.c

  1. static wifi_modules_s sta_drivers[] = {
  2. {DRIVER_MODULE_MT7601U_STA}, // MediaTek MT7601U
  3. {DRIVER_MODULE_RTL8188EUS}, // RealTek RTL8188EUS
  4. {DRIVER_MODULE_RTL8188EUS}, // RealTek RTL8188ETV
  5. {DRIVER_MODULE_RTL8192EU}, // RealTek RTL8192EU
  6. {DRIVER_MODULE_RTL8812AU}, // RealTek RTL8812AU
  7. {DRIVER_MODULE_RTL8723BU}, // RealTek RTL8723BU
  8. {DRIVER_MODULE_MT7632U}, // MediaTek MT7632U
  9. {DRIVER_MODULE_MT7632U}, // MediaTek MT7662U
  10. {DRIVER_MODULE_MT7632U}, // MediaTek MT7612U
  11. {DRIVER_MODULE_RTL8821AU}, // RealTek RTL8821AU
  12. {DRIVER_MODULE_QCA6174}, // Atheros QCA6174
  13. {DRIVER_MODULE_RTL8822BU}, // RealTek RTL8822BU
  14. {DRIVER_MODULE_RTL8822BE}, // RealTek RTL8822BE
  15. {DRIVER_MODULE_HI1131C}, // Hisi Hi1131C
  16. {DRIVER_MODULE_AP6356S_STA}, // AMPAK AP6356S
  17. {DRIVER_MODULE_RTL8188FU}, // RealTek RTL8188FTV
  18. {DRIVER_MODULE_MT7662TE}, //MediaTek MT7662TE
  19. {DRIVER_MODULE_MT7662TU}, //MediaTek MT7662TU
  20. {DRIVER_MODULE_RTL8821CU} //RealTek RTL8821CU
  21. };

注意sta_drivers[] 中的名称位置顺序需要跟步骤2中的devices[]一一对应。

5.编译hardware\libhardware_legacy得到libhardware_legacy.so,adb push 到 system/lib/,至此开机后就会自动加载、system/lib/modules/rtl8188fu.ko 新WiFi模块的驱动了。

最后,梳理一下wifi驱动自动加载流程:

1.libhardware_legacy会遍历所有的usb设备名称,与devices[]中的wifi模块名称进行对比,有匹配到的话,就会记住该名称的索引位置

2.寻找sta_drivers[]中对应步骤1记住的索引位置指向的驱动名称

3.根据步骤2中找到的驱动名称,自动加载该名称声明时配置的驱动名称和位置进行insmod

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/229529?site
推荐阅读
相关标签
  

闽ICP备14008679号