一、kernel 驱动,我这里使用v5.8.1.2_35530.20191025_COEX20191014-4141这个版本,下载这个版本的驱动可以参考下面的文章。
2021-04-12 RK3288 Android7.1 USB wifi bluetooth 模块RTL8821CU 调试记录_rk平台rtl8821cu蓝牙调试-CSDN博客
二、Makefile文件需要修改下面的内容。
三、加载wifi模块ko文件,ifconfig wlan0 up后发现执行wpa_cli -i wlan0 scan是会提示Failed to connect to non-global ctrl_ifname: wlan0 error: Connection refused的。insmod模块的时候会打印一些串口信息,有一些error,但是不影响。
$ [ 78.786022] type=1400 audit(1711362065.983:75): avc: denied { write } for pid=1753 comm="grep" path="pipe:[28664]" dev="pipefs" ino=28664 scontext=u:r:shell:s0 tcontext=u:r:adbd:s0 tclass=fifo_file permissive=1
[ 78.786071] type=1400 audit(1711362080.473:76): avc: denied { module_load } for pid=1764 comm="insmod" path="/vendor/lib/modules/wifi/8821cu.ko" dev="mmcblk1p13" ino=219 scontext=u:r:su:s0 tcontext=u:object_r:vendor_file:s0 tclass=system permissive=1
[ 78.843111] RTW: module init start
[ 78.843159] RTW: rtl8821cu v5.8.1.2_35530.20191025_COEX20191014-4141
[ 78.843167] RTW: build time: Mar 25 2024 18:14:42
[ 78.843174] RTW: rtl8821cu BT-Coex version = COEX20191014-4141
[ 78.843232] RTW: rtw_inetaddr_notifier_register
[ 78.843357] RTW:
[ 78.843357] usb_endpoint_descriptor(0):
[ 78.843377] RTW: bLength=7
[ 78.843384] RTW: bDescriptorType=5
[ 78.843390] RTW: bEndpointAddress=84
[ 78.843396] RTW: wMaxPacketSize=512
[ 78.843402] RTW: bInterval=0
[ 78.843409] RTW: RT_usb_endpoint_is_bulk_in = 4
[ 78.843415] RTW:
[ 78.843415] usb_endpoint_descriptor(1):
[ 78.843423] RTW: bLength=7
[ 78.843429] RTW: bDescriptorType=5
[ 78.843435] RTW: bEndpointAddress=5
[ 78.843441] RTW: wMaxPacketSize=512
[ 78.843447] RTW: bInterval=0
[ 78.843453] RTW: RT_usb_endpoint_is_bulk_out = 5
[ 78.843459] RTW:
[ 78.843459] usb_endpoint_descriptor(2):
[ 78.843468] RTW: bLength=7
[ 78.843474] RTW: bDescriptorType=5
[ 78.843480] RTW: bEndpointAddress=6
[ 78.843491] RTW: wMaxPacketSize=512
[ 78.843497] RTW: bInterval=0
[ 78.843503] RTW: RT_usb_endpoint_is_bulk_out = 6
[ 78.843509] RTW:
[ 78.843509] usb_endpoint_descriptor(3):
[ 78.843517] RTW: bLength=7
[ 78.843523] RTW: bDescriptorType=5
[ 78.843529] RTW: bEndpointAddress=87
[ 78.843535] RTW: wMaxPacketSize=64
[ 78.843541] RTW: bInterval=3
[ 78.843548] RTW: RT_usb_endpoint_is_int_in = 7, Interval = 3
[ 78.843554] RTW:
[ 78.843554] usb_endpoint_descriptor(4):
[ 78.843562] RTW: bLength=7
[ 78.843568] RTW: bDescriptorType=5
[ 78.843574] RTW: bEndpointAddress=8
[ 78.843580] RTW: wMaxPacketSize=512
[ 78.843586] RTW: bInterval=0
[ 78.843592] RTW: RT_usb_endpoint_is_bulk_out = 8
[ 78.843599] RTW: nr_endpoint=5, in_num=2, out_num=3
[ 78.843599]
[ 78.843608] RTW: USB_SPEED_HIGH
[ 78.843615] RTW: CHIP TYPE: RTL8821C
[ 78.843670] RTW: loadparam, Select P2P interface: iface_id:1
[ 78.843721] RTW: [HALMAC]11692M
[ 78.843721] HALMAC_MAJOR_VER = 1
[ 78.843721] HALMAC_PROTOTYPE_VER = 6
[ 78.843721] HALMAC_MINOR_VER = 5
[ 78.843721] HALMAC_PATCH_VER = 5
[ 78.844995] RTW: Chip Version Info: CHIP_8821C_U5_1T1R_RomVer(4)
[ 78.845014] RTW: config_chip_out_EP OutEpQueueSel(0x07), OutEpNumber(3)
[ 78.845246] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.103557] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_LOGICAL_EFUSE
[ 79.103719] RTW: HW EFUSE
[ 79.103768] RTW: 0x000: 29 81 00 BC 09 00 21 00 6E 04 A4 34 10 00 30 0B
[ 79.103941] RTW: 0x010: FF FF FF FF FF FF FF FF FF FF FF 02 FF FF FF FF
[ 79.104108] RTW: 0x020: FF FF 26 26 26 28 27 27 27 26 26 26 25 25 25 26
[ 79.104289] RTW: 0x030: 02 FF FF FF FF FF 00 FF FF FF 23 22 22 22 23 23
[ 79.104473] RTW: 0x040: 2B 2B 2C 2C 2C 02 FF FF FF FF FF FF FF FF FF FF
[ 79.104657] RTW: 0x050: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.104841] RTW: 0x060: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.105011] RTW: 0x070: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.105176] RTW: 0x080: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.105413] RTW: 0x090: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.105686] RTW: 0x0A0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.105852] RTW: 0x0B0: FF FF FF FF FF FF FF FF 7F 29 20 00 FF FF FF FF
[ 79.106042] RTW: 0x0C0: FF 21 00 41 00 00 00 00 00 FF 22 FF FF FF FF FF
[ 79.106224] RTW: 0x0D0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.106404] RTW: 0x0E0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.106588] RTW: 0x0F0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.106754] RTW: 0x100: DA 0B 20 C8 E3 46 02 14 F5 F9 D4 E6 74 09 03 52
[ 79.106938] RTW: 0x110: 65 61 6C 74 65 6B 0E 03 38 30 32 2E 31 31 61 63
[ 79.107147] RTW: 0x120: 20 4E 49 43 08 03 31 32 33 34 35 36 FF FF FF FF
[ 79.107377] RTW: 0x130: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.107556] RTW: 0x140: FF FF FF FF 00 00 31 0F FF FF FF FF FF FF FF FF
[ 79.107740] RTW: 0x150: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.107923] RTW: 0x160: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.108107] RTW: 0x170: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.108273] RTW: 0x180: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.108498] RTW: 0x190: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.108737] RTW: 0x1A0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.108929] RTW: 0x1B0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.109114] RTW: 0x1C0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.109280] RTW: 0x1D0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.109497] RTW: 0x1E0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.109682] RTW: 0x1F0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
[ 79.109874] RTW: EEPROM ID = 0x8129
[ 79.109895] RTW: EEPROM Version = 0
[ 79.109918] RTW: EEPROM Regulatory=0x01
[ 79.109937] RTW: EEPROM Board Type=0x01
[ 79.110299] RTW: EEPROM Enable BT-coex, ant_num=1
[ 79.110346] RTW: hal_com_config_channel_plan chplan:0x7F
[ 79.110366] RTW: EEPROM crystal_cap=0x29
[ 79.110385] RTW: EEPROM ThermalMeter=0x20
[ 79.110404] RTW: EEPROM Customer ID=0x00
[ 79.110423] RTW: EEPROM SupportRemoteWakeup=0
[ 79.110441] RTW: EEPROM rfe_type=0x22
[ 79.110462] RTW: EEPROM PAType_2G is 0x0, ExternalPA_2G = 0
[ 79.110483] RTW: EEPROM PAType_5G is 0x0, external_pa_5g = 0
[ 79.110504] RTW: EEPROM LNAType_2G is 0x0, ExternalLNA_2G = 0
[ 79.110525] RTW: EEPROM LNAType_5G is 0x0, external_lna_5g = 0
[ 79.110557] RTW: EEPROM TypeGPA = 0x0
[ 79.110576] RTW: EEPROM TypeAPA = 0x0
[ 79.110595] RTW: EEPROM TypeGLNA = 0x0
[ 79.110613] RTW: EEPROM TypeALNA = 0x0
[ 79.110632] RTW: EEPROM tx_bbswing_24G =0x00
[ 79.110650] RTW: EEPROM tx_bbswing_5G =0x00
[ 79.110669] RTW: EEPROM USB Switch=0
[ 79.110689] RTW: EEPROM VID = 0x0BDA, PID = 0xC820
[ 79.124038] RTW: [HALMAC][ALWAYS]shall R reg twice!!
[ 79.125487] RTW: SetHwReg: bMacPwrCtrlOn=1
[ 79.230933] RTW: _rtw_hal_set_fw_rsvd_page((null)) Get [ NOR ] RsvdPageNUm ==>
[ 79.231000] RTW: LocPsPoll: 4
[ 79.231031] RTW: LocNullData: 5
[ 79.231098] RTW: LocQosNull: 6
[ 79.231123] RTW: LocBTQosNull: 7
[ 79.231152] RTW: _rtw_hal_set_fw_rsvd_page((null)) Get [ NOR ] RsvdPageNUm <==
[ 79.246539] RTW: WARN [HALMAC][WARN]the H2C ver. does not match halmac
[ 79.248029] RTW: rtl8821c_fw_dl Download Firmware from array success
[ 79.248077] RTW: NIC FW Version:24 SubVersion:5
[ 79.250410] RTW: SetHwReg: bMacPwrCtrlOn=0
[ 79.259289] RTW: hal_read_mac_hidden_rpt OK! (1, 13ms), fwdl:1, id:0x19
[ 79.259351] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.259657] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.259716] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.260027] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.260082] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.260401] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.260455] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.260776] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.260814] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.261151] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.261206] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.261530] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.261583] RTW: ERROR [HALMAC][ERR]Dump efuse in suspend
[ 79.261901] RTW: is_valid_id_status: HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE
[ 79.261953] RTW: rtw_hal_read_chip_info in 416 ms
[ 79.262079] RTW: init_channel_set((null)) ChannelPlan ID:0x7f, ch num:37
[ 79.262170] RTW: [RF_PATH] IC's RF PATH:RF_1T1R, max_tx_cnt:1
[ 79.262239] RTW: [RF_PATH] PG's trx_path_bmp:0x00, max_tx_cnt:0
[ 79.262282] RTW: [RF_PATH] Registry's RF PATH:UNKNOWN
[ 79.262318] RTW: [RF_PATH] HALDATA's trx_path_bmp:0x11, max_tx_cnt:1
[ 79.262337] RTW: [RF_PATH] HALDATA's RF PATH:RF_1T1R
[ 79.262356] RTW: [RF_PATH] NumTotalRFPath:1
[ 79.262382] RTW: rtw_hal_rfpath_init trx_path_bmp:0x11(RF_1T1R), NumTotalRFPath:1, max_tx_cnt:1
[ 79.262406] RTW: [TRX_Nss] HALSPEC - tx_nss :1, rx_nss:1
[ 79.262441] RTW: [TRX_Nss] Registry - tx_nss :0, rx_nss:0
[ 79.262462] RTW: [TRX_Nss] HALDATA - tx_nss :1, rx_nss:1
[ 79.262484] RTW: rtw_hal_trxnss_init tx_nss:1, rx_nss:1
[ 79.262765] RTW: init_mlme_default_rate_set: support CCK
[ 79.262802] RTW: init_mlme_default_rate_set: support OFDM
[ 79.263474] RTW: NR_RECVBUFF: 8
[ 79.263516] RTW: MAX_RECVBUF_SZ: 32768
[ 79.263545] RTW: NR_PREALLOC_RECV_SKB: 8
[ 79.263924] RTW: rtw_alloc_macid((null)) if1, mac_addr:ff:ff:ff:ff:ff:ff macid:1
[ 79.263976] RTW: rtw_init_pwrctrl_priv: IPS_mode=1, LPS_mode=2, LPS_level=0
[ 79.264020] RTW: IQK FW offload:enable
[ 79.264053] RTW: init_phydm_cominfo: Fv=1 Cv=4
[ 79.264166] RTW: [A] 2G G00 CCK-1T base:45 from IC_DEF
[ 79.264207] RTW: [A] 2G G01 CCK-1T base:45 from IC_DEF
[ 79.264232] RTW: [A] 2G G02 CCK-1T base:45 from IC_DEF
[ 79.264254] RTW: [A] 2G G03 CCK-1T base:45 from IC_DEF
[ 79.264277] RTW: [A] 2G G04 CCK-1T base:45 from IC_DEF
[ 79.264299] RTW: [A] 2G G05 CCK-1T base:45 from IC_DEF
[ 79.264323] RTW: [A] 2G G00 BW40-1S base:45 from IC_DEF
[ 79.264358] RTW: [A] 2G G01 BW40-1S base:45 from IC_DEF
[ 79.264381] RTW: [A] 2G G02 BW40-1S base:45 from IC_DEF
[ 79.264403] RTW: [A] 2G G03 BW40-1S base:45 from IC_DEF
[ 79.264426] RTW: [A] 2G G04 BW40-1S base:45 from IC_DEF
[ 79.264505] RTW: rtw_regsty_chk_target_tx_power_valid return _FALSE for band:0, path:0, rs:0, t:-1
[ 79.264625] RTW: phy_ConfigBBWithPgParaFile(): No File PHY_REG_PG.txt, Load from HWImg Array!
[ 79.264690] RTW: default power by rate loaded
[ 79.264723] RTW: phy_txpwr_by_rate_chk_for_path_dup duplicate 2.4G [A] to [B]
[ 79.264765] RTW: can't get autopm:
[ 79.264813] RTW: rtw_macaddr_cfg mac addr:14:f5:f9:d4:e6:74
[ 79.264841] RTW: bDriverStopped:True, bSurpriseRemoved:False, bup:0, hw_init_completed:0
[ 79.264914] RTW: loadparam, Select P2P interface: iface_id:1
[ 79.265259] RTW: init_mlme_default_rate_set: support CCK
[ 79.265404] RTW: init_mlme_default_rate_set: support OFDM
[ 79.266100] RTW: NR_RECVBUFF: 8
[ 79.266145] RTW: MAX_RECVBUF_SZ: 32768
[ 79.266176] RTW: NR_PREALLOC_RECV_SKB: 8
[ 79.266573] RTW: rtw_alloc_macid((null)) if2, mac_addr:ff:ff:ff:ff:ff:ff macid:1
[ 79.266643] RTW: rtw_drv_add_vir_if if2 mac_addr : 16:f5:f9:d4:e6:74
[ 79.266734] RTW: rtw_cfg80211_preinit_wiphy iface_id:0- don't set p2p capability
[ 79.266784] RTW: rtw_wiphy_alloc(phy0)
[ 79.266810] RTW: rtw_wdev_alloc(padapter=ffffff80097a9000)
[ 79.266877] RTW: rtw_wiphy_alloc(phy1)
[ 79.266901] RTW: rtw_wdev_alloc(padapter=ffffff8009fd2000)
[ 79.266928] RTW: rtw_wiphy_register(phy0)
[ 79.266952] RTW: Register RTW cfg80211 vendor cmd(0x67) interface
[ 79.269623] RTW: rtw_reg_notifier: NL80211_REGDOM_SET_BY_CORE
[ 79.271565] RTW: rtw_ndev_init(wlan0) if1 mac_addr=14:f5:f9:d4:e6:74
[ 79.272529] RTW: rtw_ndev_notifier_call(wlan0) state:16
[ 79.277351] RTW: rtw_ndev_notifier_call(wlan0) state:5
[ 79.277516] RTW: rtw_wiphy_register(phy1)
[ 79.277545] RTW: Register RTW cfg80211 vendor cmd(0x67) interface
[ 79.278307] RTW: rtw_reg_notifier: NL80211_REGDOM_SET_BY_CORE
[ 79.279670] RTW: rtw_ndev_init(p2p0) if2 mac_addr=16:f5:f9:d4:e6:74
[ 79.280558] RTW: rtw_ndev_notifier_call(p2p0) state:16
[ 79.286214] RTW: rtw_ndev_notifier_call(p2p0) state:5
[ 79.287311] usbcore: registered new interface driver rtl8821cu
[ 79.287353] RTW: module init ret=0
[ 123.964271] healthd: battery l=100 v=160 t=18.8 h=2 st=5 c=0 fc=1500000 chg=a
[ 183.964244] healthd: battery l=100 v=160 t=18.8 h=2 st=5 c=0 fc=1500000 chg=a
四、上一步wpa_cli -i wlan0 scan会提示Failed to connect to non-global ctrl_ifname: wlan0 error: Connection refused,Android 平台需要先使用 svc wifi enable打开wifi。这样就可以使用 wpa_cli -i wlan0 scan wpa_cli -i wlan0 scan_results扫描到wifi设备。
五、到这里在Android settings里面就会自动的打开WiFi了。
六、使用v5.14.2-32-gbab9939fd.20220913_COEX20210319-5555版本有下面的提示,略微有点不一样,执行svc wifi enable后还是可以工作。
七、参考文章:
PX30 android8.1添加RTL8723DU_config_resume_in_workqueue-CSDN博客