rtl8723bu rtl8723du在mstar平台上移植

调试平台为MSTAR芯片的 android 6.0平台,转载请注明出处,谢谢:https://blog.csdn.net/xiangzi10/article/details/83145296

wifi

重点注意:wifi.cfg文件修改一定要使用vim,使用notepad++或其他文本编辑工具很容易格式不对,导致不能启动

1、首先拿到wifi模块厂家的驱动包:

RTL8723BU_WiFi_linux_v5.2.17.1_26947_COEX20180201-6f52.20180307.rar

https://download.csdn.net/download/xiangzi10/10774452 下载页面

rtl8723du WiFi驱动,移植SDK

https://download.csdn.net/download/xiangzi10/10915017 下载页面

mstar的简单说明文档:

https://download.csdn.net/download/xiangzi10/11162108 下载页面

2、将driver文件夹下解压,解压出来的目录拷贝至mstar源码kernel下,vendor\mstar\kernel\linaro\drivers\net\wireless下并更改文件夹名称为rtl8723bu,修改makefile.mk

CONFIG_PLATFORM_I386_PC = n

CONFIG_PLATFORM_MSTAR = y

ifeq ($(CONFIG_PLATFORM_MSTAR), y)
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_PLATFORM_MSTAR
EXTRA_CFLAGS += -DCONFIG_PLATFORM_MSTAR_HIGH
ifeq ($(CONFIG_USB_HCI), y)
EXTRA_CFLAGS += -DCONFIG_USE_USB_BUFFER_ALLOC_TX -DCONFIG_FIX_NR_BULKIN_BUFFER
endif
ARCH:=$(R_ARCH)
CROSS_COMPILE:= $(R_CROSS_COMPILE)
KVER:= 3.10.86
KSRC:= $(KERNEL_BUILD_PATH)
MODULE_NAME := 8723bu
endif

修改drivers\net\wireless的makefile.mk,增加

obj-$(CONFIG_RTL8723BU)        += rtl8723bu/

修改Kconfig,增加:

source "drivers/net/wireless/rtl8723bu/Kconfig"

make menuconfig

rtl8723bu rtl8723du在mstar平台上移植_第1张图片

rtl8723bu rtl8723du在mstar平台上移植_第2张图片

3、编译kernel,发生编译错误:

*** No rule to make target `  /hal/phydm/phydm.mk

修改rel8723bu文件夹下的makefile.mk:

export TopDIR ?= $(shell pwd)修改为

export TopDIR ?= $(shell pwd)/drivers/net/wireless/rtl8723bu

编译成功

4、insmod 8723bu.ko   错误

root@almond:/system/lib/modules # insmod 8723bu.ko                             
[21073.743551] 8723bu: Unknown symbol wiphy_register (err 0)
[21073.752733] 8723bu: Unknown symbol cfg80211_remain_on_channel_expired (err 0)
[21073.760147] 8723bu: Unknown symbol wiphy_unregister (err 0)
[21073.765956] 8723bu: Unknown symbol cfg80211_ready_on_channel (err 0)
[21073.773037] 8723bu: Unknown symbol __ieee80211_get_channel (err 0)
[21073.779814] 8723bu: Unknown symbol wiphy_free (err 0)
[21073.785280] 8723bu: Unknown symbol cfg80211_inform_bss_frame (err 0)
[21073.792241] 8723bu: Unknown symbol cfg80211_get_bss (err 0)
[21073.798174] 8723bu: Unknown symbol cfg80211_disconnected (err 0)
[21073.798182] 8723bu: Unknown symbol cfg80211_michael_mic_failure (err 0)
[21073.798204] 8723bu: Unknown symbol cfg80211_ibss_joined (err 0)
insmod: [21073.798270] 8723bu: Unknown symbol cfg80211_scan_done (err 0)
[21073.798284] 8723bu: Unknown symbol cfg80211_roamed (err 0)
[21073.798289] 8723bu: Unknown symbol cfg80211_put_bss (err 0)
failed to load 8[21073.798317] 8723bu: Unknown symbol wiphy_new (err 0)
[21073.798349] 8723bu: Unknown symbol cfg80211_unlink_bss (err 0)
723bu.ko[21073.798368] 8723bu: Unknown symbol cfg80211_connect_result (err 0)
[21073.798391] 8723bu: Unknown symbol cfg80211_new_sta (err 0)
[21073.798433] 8723bu: Unknown symbol cfg80211_rx_mgmt (err 0)
: No such file o[21073.798442] 8723bu: Unknown symbol ieee80211_frequency_to_channel (err 0)
[21073.798449] 8723bu: Unknown symbol wiphy_apply_custom_regulatory (err 0)
r directory[21073.798467] 8723bu: Unknown symbol cfg80211_mgmt_tx_status (err 0)
[21073.798477] 8723bu: Unknown symbol cfg80211_del_sta (err 0)

这个是没有先安装cfg80211.ko导致的。

先 insmod cfg80211.ko,再 insmod 8723bu.ko后,

5、使用iw命令手动启动测试wifi模块

# ifconfig wlan0 up

#iwlist wlan0 sacn能扫描出所有网络了,于是我手机设了一个没有密码的wifi热点,用IW去连

#iwconfig wlan0 mode Managed 

#iwconfig wlan0 essid "HUAWEI nova",连上了,但是没有IP,下面不知道怎么弄了

#ifconfig wlan0 192.168.34.123 netmask 255.255.255.0

#ifconfig

wlan0     Link encap:Ethernet  HWaddr 8C:18:D9:9E:44:3F
          inet addr:192.168.34.123  Bcast:192.168.34.255  Mask:255.255.255.0 
          inet6 addr: fe80::8e18:d9ff:fe9e:443f/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:234 TX bytes:588 

换成路由器的open 设置的wifi

2|root@almond:/ # iwconfig wlan0 essid "RD1"
[ 2764.116061] RTW: _rtw_pwr_wakeup call ips_leave....
[ 2764.122391] RTW: ==>ips_leave cnts:5
[ 2764.126006] RTW: ===>  rtw_ips_pwr_up..............
[ 2764.130927] RTW: ===> ips_netdrv_open.........
[ 2764.135749] RTW:  power-on :REG_SYS_CLKR 0x09=0x30. REG_CR 0x100=0xea.
[ 2764.142320] RTW:  MAC has not been powered on yet.
[ 2764.151356] RTW: SetHwReg: bMacPwrCtrlOn=1
[ 2764.156727] RTW: rtl8723b_FirmwareDownload(wlan0) tmp_ps=0
[ 2764.162228] RTW: rtl8723b_FirmwareDownload fw: FW_NIC, size: 32272
[ 2764.168443] RTW: rtl8723b_FirmwareDownload: fw_ver=29 fw_subver=0000 sig=0x5301, Month=07, Date=25, Hour=14, Minute=43
[ 2764.179259] RTW: rtl8723b_FirmwareDownload(): Shift for fw header!
[ 2764.205108] RTW: polling_fwdl_chksum: Checksum report OK! (1, 0ms), REG_MCUFWDL:0x00070605
[ 2764.214477] RTW: _8051Reset8723: Finish
[ 2764.244167] RTW: _FWFreeToGo: Polling FW ready OK! (401, 30ms), REG_MCUFWDL:0x000706c6
[ 2764.252137] RTW: FWDL success. write_fw:1, 70ms
[ 2764.256804] RTW:  <=== rtl8723b_FirmwareDownload()
[ 2764.261620] RTW: fw download ok!
[ 2764.859682] RTW: usb_AggSettingRxUpdate: RX Agg-USB mode, size=4KB, timeout=1024us
[ 2764.869285] RTW: ===>phy_SwChnl8723B: Channel = 1
[ 2765.081496] RTW: rtl8723bu_hal_init in 950ms
[ 2765.085783] RTW: rtw_hal_set_macaddr_port wlan0- hw port(0) mac_addr =8c:18:d9:9e:44:3f
[ 2765.094414] RTW: rtw_hal_set_macaddr_port wlan1- hw port(1) mac_addr =8e:18:d9:9e:44:3f
[ 2765.103354] RTW: rtw_hal_get_macaddr_port wlan0- hw port(0) mac_addr =8c:18:d9:9e:44:3f
[ 2765.111389] RTW: wlan0- hw port(0) mac_addr =8c:18:d9:9e:44:3f
[ 2765.117723] RTW: rtw_hal_get_macaddr_port wlan1- hw port(1) mac_addr =8e:18:d9:9e:44:3f
[ 2765.125752] RTW: wlan1- hw port(1) mac_addr =8e:18:d9:9e:44:3f
[ 2765.132911] RTW: ===>phy_SwChnl8723B: Channel = 6
[ 2765.140987] RTW: rtw_hal_set_macaddr_port wlan0- hw port(0) mac_addr =8c:18:d9:9e:44:3f
[ 2765.149660] RTW: #### hw_var_set_opmode() -4497 hw_port(0) mode = 2 ####
[ 2765.156848] RTW: Using the default RF gain.
[ 2765.161361] RTW: <===  rtw_ips_pwr_up.............. in 1040ms
[ 2765.167134] RTW: nolinked power save leave
[ 2765.171372] RTW: ==> ips_leave.....LED(0x00e28282)...
[ 2765.180541] RTW: =>rtw_wx_set_essid
[ 2765.184254] RTW: ssid=RD1, len=3
[ 2765.187777] RTW: set ssid [RD1] fw_state=0x00000008
[ 2765.192906] RTW: Set SSID under fw_state=0x00000008
[ 2765.197844] RTW: [by_bssid:0][assoc_ssid:RD1][to_roam:0] new candidate: RD1(5c:09:79:c3:89:f4, ch8) rssi:-48
[ 2765.207736] RTW: rtw_select_and_join_from_scanned_queue: candidate: RD1(5c:09:79:c3:89:f4, ch:8)
[ 2765.216567] RTW: link to Ralink AP
[ 2765.220017] RTW: [HT] HAL Support STBC = 0x01
[ 2765.224408] RTW: [HT] Declare supporting RX STBC = 1
[ 2765.229419] RTW: rtw_restructure_ht_ie IEEE80211_HT_CAP_MAX_AMSDU is set
[ 2765.236209] RTW: <=rtw_wx_set_essid, ret 0
[ 2765.241068] RTW: rtw_chk_start_clnt_join(wlan0) req: 8,0,0
[ 2765.246594] RTW: rtw_chk_start_clnt_join(wlan0) ld_sta_num:0, ap_num:0, mesh_num:0
root@almond:/ # [ 2765.254315] RTW: rtw_chk_start_clnt_join(wlan0) union: 8,0,0
[ 2765.261858] RTW: rtw_hal_set_bssid wlan0- hw port -0 BSSID: 5c:09:79:c3:89:f4
[ 2765.279858] RTW: ===>phy_SwChnl8723B: Channel = 8
[ 2767.201101] RTW: OnBeacon: beacon keys ready
[ 2767.205397] RTW: link to Ralink AP
[ 2767.208878] RTW: start auth
[ 2767.211734] RTW: issue_auth
[ 2767.227025] RTW: OnAuthClient
[ 2767.230066] RTW: auth success, start assoc
[ 2767.234208] RTW: network.SupportedRates[0]=82
[ 2767.238608] RTW: network.SupportedRates[1]=84
[ 2767.242996] RTW: network.SupportedRates[2]=8B
[ 2767.247407] RTW: network.SupportedRates[3]=96
[ 2767.251771] RTW: network.SupportedRates[4]=12
[ 2767.256159] RTW: network.SupportedRates[5]=24
[ 2767.260523] RTW: network.SupportedRates[6]=48
[ 2767.264884] RTW: network.SupportedRates[7]=6C
[ 2767.269268] RTW: network.SupportedRates[8]=0C
[ 2767.273634] RTW: network.SupportedRates[9]=18
[ 2767.278007] RTW: network.SupportedRates[10]=30
[ 2767.282457] RTW: network.SupportedRates[11]=60
[ 2767.286922] RTW: bssrate_len = 12
[ 2767.295815] RTW: OnAssocRsp
[ 2767.298698] RTW: report_join_res(2)
[ 2767.302203] RTW: rtw_joinbss_update_network
[ 2767.306471] RTW: +rtw_update_ht_cap()
[ 2767.310154] RTW: rtw_alloc_macid(wlan0) if1, mac_addr:5c:09:79:c3:89:f4 macid:0
[ 2767.317488] RTW: rtw_joinbss_update_stainfo
[ 2767.321685] RTW: rtw_get_sta_tx_nss: 1 SS
[ 2767.325697] RTW: rtw_get_sta_rx_nss: 1 SS
[ 2767.329731] RTW: STA - MAC_ID:0, Tx - 1 SS, Rx - 1 SS
[ 2767.334796] RTW: STA - MAC_ID:0, SM_PS 3
[ 2767.338746] RTW: ht_mcs_set=ff 00 00 00, nss=1, bitmap=000000ff
[ 2767.344680] RTW: ### Set STA_(0) info ###
[ 2767.348724] RTW: rtw_cfg80211_indicate_connect(wlan0)
[ 2767.353818] RTW: pwdev->sme_state(b)=0
[ 2767.357606] ------------[ cut here ]------------
[ 2767.362263] WARNING: at net/wireless/sme.c:546 cfg80211_connect_result+0x184/0x1a4 [cfg80211]()
[ 2767.370995] Modules linked in: 8723bu cfg80211 uhid rtkm(O) firmware_class mtprealloc(PO) keymap_htp_51key optee_armtz optee mdrv_xc mali_kbase(O) [last unloaded: cfg80211]
[ 2767.386589] CPU: 0 PID: 4645 Comm: RTW_CMD_THREAD Tainted: P        W  O 3.10.86 #32
[ 2767.394340] Call trace:
[ 2767.396799] [] (dump_backtrace+0x0/0x13c) 
[ 2767.402463] [] dump_backtrace+0x0/0x13c
[ 2767.407919] [] (show_stack+0x10/0x1c) 
[ 2767.413241] [] show_stack+0x10/0x1c
[ 2767.418316] [] (dump_stack+0x1c/0x28) 
[ 2767.423641] [] dump_stack+0x1c/0x28
[ 2767.428729] [] (warn_slowpath_common+0x78/0x9c) 
[ 2767.434921] [] warn_slowpath_common+0x78/0x9c
[ 2767.440859] [] (warn_slowpath_null+0x14/0x20) 
[ 2767.446898] [] warn_slowpath_null+0x14/0x20
[ 2767.452669] [] (cfg80211_connect_result+0x180/0x1a4 [cfg80211]) 
[ 2767.460275] [] cfg80211_connect_result+0x180/0x1a4 [cfg80211]
[ 2767.467671] [] (rtw_cfg80211_indicate_connect+0x340/0x394 [8723bu]) 
[ 2767.475638] [] rtw_cfg80211_indicate_connect+0x340/0x394 [8723bu]
[ 2767.483349] [] ($x+0x2c/0x64 [8723bu]) 
[ 2767.488833] [] $x+0x2c/0x64 [8723bu]
[ 2767.494007] [] (rtw_indicate_connect+0x48/0x7c [8723bu]) 
[ 2767.501011] [] rtw_indicate_connect+0x48/0x7c [8723bu]
[ 2767.507813] [] (rtw_joinbss_event_prehandle+0x4b0/0x598 [8723bu]) 
[ 2767.515627] [] rtw_joinbss_event_prehandle+0x4b0/0x598 [8723bu]
[ 2767.523163] [] (report_join_res+0xd4/0x104 [8723bu]) 
[ 2767.529857] [] report_join_res+0xd4/0x104 [8723bu]
[ 2767.536264] [] (OnAssocRsp+0x264/0x288 [8723bu]) 
[ 2767.542583] [] OnAssocRsp+0x264/0x288 [8723bu]
[ 2767.548652] [] (_mgt_dispatcher+0x7c/0x90 [8723bu]) 
[ 2767.555250] [] _mgt_dispatcher+0x7c/0x90 [8723bu]
[ 2767.561590] [] (mgt_dispatcher+0x1bc/0x1d4 [8723bu]) 
[ 2767.568275] [] mgt_dispatcher+0x1bc/0x1d4 [8723bu]
[ 2767.574673] [] (validate_recv_mgnt_frame+0x124/0x150 [8723bu]) 
[ 2767.582204] [] validate_recv_mgnt_frame+0x124/0x150 [8723bu]
[ 2767.589506] [] (validate_recv_frame+0x29c/0x348 [8723bu]) 
[ 2767.596612] [] validate_recv_frame+0x29c/0x348 [8723bu]
[ 2767.603457] [] (recv_func_prehandle+0x50/0x84 [8723bu]) 
[ 2767.610403] [] recv_func_prehandle+0x50/0x84 [8723bu]
[ 2767.617097] [] (recv_func+0xb4/0x164 [8723bu]) 
[ 2767.623247] [] recv_func+0xb4/0x164 [8723bu]
[ 2767.629174] [] (rtw_recv_entry+0x18/0x54 [8723bu]) 
[ 2767.635675] [] rtw_recv_entry+0x18/0x54 [8723bu]
[ 2767.641912] [] (pre_recv_entry+0x104/0x11c [8723bu]) 
[ 2767.648606] [] pre_recv_entry+0x104/0x11c [8723bu]
[ 2767.655015] [] ($x+0x208/0x29c [8723bu]) 
[ 2767.660643] [] $x+0x208/0x29c [8723bu]
[ 2767.666071] [] (usb_recv_tasklet+0xd8/0x144 [8723bu]) 
[ 2767.672838] [] usb_recv_tasklet+0xd8/0x144 [8723bu]
[ 2767.679306] [] (tasklet_action+0x6c/0x128) 
[ 2767.685064] [] tasklet_action+0x6c/0x128
[ 2767.690583] [] (__do_softirq+0x10c/0x28c) 
[ 2767.696263] [] __do_softirq+0x10c/0x28c
[ 2767.701673] [] (do_softirq+0x5c/0x68) 
[ 2767.707011] [] do_softirq+0x5c/0x68
[ 2767.712073] [] (irq_exit+0x94/0xc8) 
[ 2767.717263] [] irq_exit+0x94/0xc8
[ 2767.722154] [] (handle_IRQ+0x44/0xc0) 
[ 2767.727495] [] handle_IRQ+0x44/0xc0
[ 2767.732561] [] (gic_handle_irq+0x3c/0x80) 
[ 2767.738237] [] gic_handle_irq+0x3c/0x80
[ 2767.743685] Exception stack(0xffffffc037a43a80 to 0xffffffc037a43ba0)
[ 2767.750177] 3a80: 00000001 00000000 00008958 00000000 37a43bc0 ffffffc0 00423e34 ffffffc0
[ 2767.758395] 3aa0: 00002ee0 00000000 c1e9ac08 00000007 c1e984b4 00000007 00000000 00000000
[ 2767.766608] 3ac0: 37a43bb0 ffffffc0 110db740 ffffffc0 110db740 ffffffc0 1a99a48c 00000000
[ 2767.774803] 3ae0: 2d4bc440 ffffffc0 00b92000 ffffffc0 00b92000 ffffffc0 fa83b2da 00000000
[ 2767.782998] 3b00: 00000008 00000000 00000000 00000000 0001728d 00000000 00000001 00000000
[ 2767.791206] 3b20: 0000061f 00000000 00000004 00000000 00000001 00000000 00000001 00000000
[ 2767.799398] 3b40: 00008958 00000000 000008b4 00000000 00010000 00000000 00000001 00000000
[ 2767.807604] 3b60: 00000000 00000000 fc98b010 ffffffbf fc85af58 ffffffbf 0208f0f4 ffffff80
[ 2767.815790] 3b80: 32d4fa00 ffffffc0 37a43bc0 ffffffc0 00423e68 ffffffc0 37a43bc0 ffffffc0
[ 2767.823985] [] (el1_irq+0x7c/0xe4) 
[ 2767.829071] [] el1_irq+0x7c/0xe4
[ 2767.833918] [] (rtw_mdelay_os+0x24/0x3c [8723bu]) 
[ 2767.840327] [] rtw_mdelay_os+0x24/0x3c [8723bu]
[ 2767.846506] [] (ODM_delay_ms+0x8/0x14 [8723bu]) 
[ 2767.852739] [] ODM_delay_ms+0x8/0x14 [8723bu]
[ 2767.858714] [] (phydm_check_clm_rdy+0x90/0x10c [8723bu]) 
[ 2767.865742] [] phydm_check_clm_rdy+0x90/0x10c [8723bu]
[ 2767.872521] [] (phydm_ccx_monitor_result+0x34/0xd4 [8723bu]) 
[ 2767.879908] [] phydm_ccx_monitor_result+0x34/0xd4 [8723bu]
[ 2767.887041] [] (phydm_ccx_monitor+0x48/0x64 [8723bu]) 
[ 2767.893794] [] phydm_ccx_monitor+0x48/0x64 [8723bu]
[ 2767.900293] [] (phydm_watchdog+0xdc/0xf0 [8723bu]) 
[ 2767.906820] [] phydm_watchdog+0xdc/0xf0 [8723bu]
[ 2767.913059] [] (rtw_phydm_watchdog+0x15c/0x174 [8723bu]) 
[ 2767.920078] [] rtw_phydm_watchdog+0x15c/0x174 [8723bu]
[ 2767.926866] [] (rtl8723b_HalDmWatchDog+0x98/0xa8 [8723bu]) 
[ 2767.934054] [] rtl8723b_HalDmWatchDog+0x98/0xa8 [8723bu]
[ 2767.940986] [] (rtw_hal_dm_watchdog+0x1c/0x2c [8723bu]) 
[ 2767.947944] [] rtw_hal_dm_watchdog+0x1c/0x2c [8723bu]
[ 2767.954595] [] (rtw_dynamic_chk_wk_hdl+0x24/0x3c [8723bu]) 
[ 2767.961765] [] rtw_dynamic_chk_wk_hdl+0x24/0x3c [8723bu]
[ 2767.968709] [] (rtw_drvextra_cmd_hdl+0x64/0x37c [8723bu]) 
[ 2767.975794] [] rtw_drvextra_cmd_hdl+0x64/0x37c [8723bu]
[ 2767.982616] [] (rtw_cmd_thread+0x368/0x5cc [8723bu]) 
[ 2767.989301] [] rtw_cmd_thread+0x368/0x5cc [8723bu]
[ 2767.995667] [] (kthread+0xb0/0xbc) 
[ 2768.000729] [] kthread+0xb0/0xbc
[ 2768.005528] ---[ end trace e605c03f78cfc60f ]---
[ 2768.010181] RTW: pwdev->sme_state(a)=0
[ 2768.013938] RTW: assoc success
[ 2768.017989] RTW: rtw_ndev_notifier_call(wlan0) state:4
[ 2768.205006] RTW: wlan0 cmd=57,2,0 process_time=1040
[ 2768.209932] RTW: HW_VAR_BASIC_RATE: 0x15f->0x15f->0x15f
[ 2768.215623] RTW: WMM(0): 0, a42b
[ 2768.218942] RTW: WMM(1): 0, a44f
[ 2768.222297] RTW: WMM(2): 0, 5e4322
[ 2768.225789] RTW: WMM(3): 0, 2f3222
[ 2768.229241] RTW: wmm_para_seq(0): 0
[ 2768.232734] RTW: wmm_para_seq(1): 1
[ 2768.236285] RTW: wmm_para_seq(2): 2
[ 2768.239779] RTW: wmm_para_seq(3): 3
[ 2768.243270] RTW: HTOnAssocRsp
[ 2768.249425] ============ STA [5c:09:79:c3:89:f4]  ===================
[ 2768.255969] mac_id : 0
[ 2768.258370] wireless_mode : 0x0b
[ 2768.261604] mimo_type : 0
[ 2768.264247] bw_mode : 20MHz, ra_bw_mode : 20MHz
[ 2768.268830] rate_id : 3
[ 2768.271282] rssi : 35 (%), rssi_level : 0
[ 2768.275297] is_support_sgi : Y, is_vht_enable : N
[ 2768.280025] disable_ra : N, disable_pt : N
[ 2768.284131] is_noisy : N
[ 2768.286703] txrx_state : 0
[ 2768.289416] curr_tx_rate : CCK_1M (L)
[ 2768.293082] curr_tx_bw : 20MHz
[ 2768.296156] curr_retry_ratio : 0
[ 2768.299390] ra_mask : 0x00000000000fffff
[ 2768.303667] RTW: SetHwReg8723B(wlan0): [HW_VAR_MACID_WAKEUP] macid=0, org reg_0x4d4=0x00000000
[ 2768.313742] RTW: +rtl8723b_download_rsvd_page(wlan0): hw_port=0 mstatus(1)
[ 2768.321489] RTW: _rtw_hal_set_fw_rsvd_page PageSize: 128, RsvdPageNUm: 16
[ 2768.328408] RTW: LocPsPoll: 1
[ 2768.331382] RTW: LocBTQosNull: 2
[ 2768.334614] RTW: LocNullData: 3
[ 2768.337832] RTW: LocQosNull: 4
[ 2768.340892] RTW: _rtw_hal_set_fw_rsvd_page PageNum(5), pktlen(714)
[ 2768.347213] RTW: _rtw_hal_set_fw_rsvd_page: Set RSVD page location to Fw ,TotalPacketLen(714), TotalPageNum(5)
[ 2768.357252] RTW: RsvdPageLoc: ProbeRsp=0 PsPoll=1 Null=3 QoSNull=4 BTNull=2
[ 2768.364563] RTW: wlan0: 1 DL RSVD page success! DLBcnCount:1, poll:1
[ 2768.374483] RTW: ===>phy_SwChnl8723B: Channel = 8
[ 2768.382868] RTW: =>mlmeext_joinbss_event_callback - End to Connection without 4-way
[ 2771.160443] RTW: hw_rate_to_m_rate(): Non supported Rate [ff]!!!
[ 2775.156199] RTW: rtw_set_ps_mode(wlan0) Enter 802.11 power save - WIFI-TRAFFIC_IDLE
[ 2775.166176] RTW: rtl8723b_set_FwPwrMode_cmd(): FW LPS mode = 2, SmartPS=2

以上问题在于没有IP地址,查看相关文档,修改如下:其实iw命令已经包含 iwconfig,iwlist等这些命令,iw命令更新

#ifconfig wlan0 up

#ifconfig

#iw wlan0 scan

#iw wlan0 connect RD1 此时没有ip

#ifconfig wlan0 192.168.1.156 netmask 255.255.255.0设置IP

#busybox iproute add default via 192.168.1.1  添加网关

#ping 192.168.1.1 OK了

#ping 180.97.33.107 (百度IP)也ok了

 

 

接下来就是手动调试wpa_supplicant

#wpa_supplicant -d -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -B&

#wpa_cli -p/var/run/wpa_supplicant scan      

Using interface 'wlan0'
Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory  

原因是 wpa_supplicant.conf 里面设置ctrl_interface=/var/run/wpa_supplicant

但是/var目录下没有/var/run/wpa_supplicant

新建一个可以解决此问题

# wpa_cli -p/var/run/wpa_supplicant scan_results      
Selected interface 'wlan0'
bssid / frequency / signal level / flags / ssid
1c:fa:68:6a:61:c8       2412    -50     [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] family_01
f4:6a:92:35:ec:0c       2467    -52     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      33333333
bc:46:99:ba:d2:04       2437    -66     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      TP-LINK_D204
94:d9:b3:ce:6a:e5       2412    -72     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]    TP-LINK_zonghe2
88:25:93:69:40:8f       2412    -74     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      TP-LINK_4090
88:25:93:60:2c:b1       2462    -38     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      DQA_2.4GHZ
d4:5f:25:40:7e:11       2417    -70     [WPA-PSK-CCMP+TKIP][WPS][ESS]   ChinaNet-cS5G
78:c1:a7:c5:61:78       2462    -70     [WPA-PSK-CCMP+TKIP][WPS][ESS]   ChinaNet-STxc
30:fc:68:76:4a:56       2412    -76     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      301-2
78:44:fd:96:f7:c6       2462    -76     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      TP-LINK_F7C6
34:96:72:a5:12:f7       2412    -79     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      TP-LINK_12F7
d6:5f:25:50:7e:11       2417    -72     [WPA-PSK-CCMP+TKIP][WPS][ESS]   iTV-cS5G
78:c1:a7:c5:5e:2a       2437    -72     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS]       ChinaNet-pQUG
8c:a6:df:07:84:94       2437    -80     [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]      TP-LINK_8494
94:d9:b3:d8:3c:b9       2462    -74     [ESS]   TP-LINK_3CB9
5c:09:79:c3:89:f4       2442    -54     [ESS]   RD1         

连接AP

OPEN

#wpa_cli -p/var/run/wpa_supplicant remove_network 0

#wpa_cli -p/var/run/wpa_supplicant ap_scan 1 

#wpa_cli -p/var/run/wpa_supplicant add_network 

#wpa_cli -p/var/run/wpa_supplicant set_network 0 ssid "RD1"  

#wpa_cli -p/var/run/wpa_supplicant set_network 0 key_mgmt NONE

#wpa_cli -p/var/run/wpa_supplicant select_network 0

 

以上是手动调试用来确认驱动和wpa_supplicant是否正常,以上linux驱动整合OK

修改安卓层,查看android_ref_codes_M_6.x文件夹里的文件进行安卓整合:

1、device/mstar/XXX 的目录下device.mk添加:


BOARD_WIFI_VENDOR := realtek
ifeq ($(BOARD_WIFI_VENDOR), realtek)
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl
#BOARD_WLAN_DEVICE := rtl8192cu
#BOARD_WLAN_DEVICE := rtl8192du
#BOARD_WLAN_DEVICE := rtl8192ce
#BOARD_WLAN_DEVICE := rtl8192de
#BOARD_WLAN_DEVICE := rtl8723as
#BOARD_WLAN_DEVICE := rtl8723au
#BOARD_WLAN_DEVICE := rtl8189es
#BOARD_WLAN_DEVICE := rtl8723bs
BOARD_WLAN_DEVICE := rtl8723bu
WIFI_DRIVER_MODULE_NAME := "8723bu"
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/8723bu.ko"
WIFI_DRIVER_MODULE_ARG := "ifname=wlan0 if2name=p2p0"
WIFI_FIRMWARE_LOADER := "rtw_fwloader"
WIFI_DRIVER_FW_PATH_STA := "STA"
WIFI_DRIVER_FW_PATH_AP := "AP"
WIFI_DRIVER_FW_PATH_P2P := "P2P"
WIFI_DRIVER_FW_PATH_PARAM := "/dev/null"

else
# Wifi related defines
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
WPA_SUPPLICANT_VERSION      := VER_0_8_X
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_bcmdhd
BOARD_HOSTAPD_DRIVER        := NL80211
BOARD_HOSTAPD_PRIVATE_LIB   := lib_driver_cmd_bcmdhd
BOARD_WLAN_DEVICE           := bcmdhd
endif
    
ifeq ($(BOARD_WIFI_VENDOR), realtek)
####rtl8723bu    
PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
    frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml


PRODUCT_PACKAGES += \
    rtw_fwloader \
    iwconfig \
    iwlist \
    iwpriv \
    iwspy \
    iwgetid \
    iwevent \
    macaddr \
    
endif
####rtl8723bu

2、去掉其他地方关于wifi的配置BoardConfig.mk,BoardConfigCommon.mk

3、修改init.xxx.rc

service rtw_fwloader /system/bin/rtw_fwloader
    class main
    disabled
    oneshot

######## supplicant patch to startSupplicant #########

service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL
    class main
    disabled
    oneshot

service dhcpcd_p2p /system/bin/dhcpcd -aABKL
    class main
    disabled
    oneshot

service iprenew_wlan0 /system/bin/dhcpcd -n
    class main
    disabled
    oneshot

service iprenew_p2p /system/bin/dhcpcd -n
    class main
    disabled
    oneshot
########  Realtek wifi patch ####################
 

p2p_supplicant wpa_supplicant的service不需要添加,因为mstar方案已经将此整合到startSupplicant里面去了

PRODUCT_PROPERTY_OVERRIDES += \
wifi.interface=wlan0
此原文件已有,无需添加

按文档修改ANDROID_SDK/device/ti/panda/overlay/frameworks/base/core/res/res/values/config.xml

使用mstar原有的supplicant

3、device/msar/xxx的   preinstall\preinstall.mk添加

$(LOCAL_PATH)/modules/8723bu.ko:system/lib/modules/8723bu.ko

4、修改preinstall\wifi\wifi.cfg

=====
wifi_vendor_name=RTL8723BU
order=1
count_vid_pid=1
vid_pid=0x0bda:0xb720
sta=1
softap=1
p2p=1

5、修改device\mstar\common\preinstall\wifi下wifi_load_apdriver.sh,wifi_load_driver.sh,wifi_unload_apdriver.sh,wifi_unload_driver.sh,startSupplicant.sh ,修改device\mstar\common\preinstall\preinstall.mk

6、编译AN,报错

make: *** No rule to make target `out/target/product/bennet/obj/STATIC_LIBRARIES/lib_driver_cmd_rtl_intermediates/export_includes', needed by `out/target/product/bennet/obj/EXECUTABLES/hostapd_intermediates/import_includes'.  Stop.

7、拷贝wlan到hardware\realtek\wlan

8、再次编译,无错误。升级完成后wifi可用。

 

蓝牙:

蓝牙移植包下载:https://download.csdn.net/download/xiangzi10/10774468

1、拷贝驱动文件至kernel/drivers/bluetooth/

修改linaro\drivers\bluetooth\Makefile添加

obj-$(CONFIG_BT_RTKBTUSB)    += rtk_btusb.o

修改linaro\drivers\bluetooth\Kconfig添加

config BT_RTKBTUSB
    tristate "RTK HCI USB driver"
    depends on USB
    help
       RTK Bluetooth HCI USB driver

执行make menuconfig

rtl8723bu rtl8723du在mstar平台上移植_第3张图片

rtl8723bu rtl8723du在mstar平台上移植_第4张图片

编译生成rtk_btusb.ko

2、device\mstar\common\sepolicy相关文件修改,依据文档

3、将模块厂家的包rtkbt整合进hardware\realtek\bt

4、修改device\mstar\xxx\ueventd.mainz.rc

/dev/rtk_btusb            0666   bluetooth  net_bt_stack

5、修改init.xxx.rc

######rtk_bt
    # bluetooth
    # change back to bluetooth from system
    chown bluetooth net_bt_stack /data/misc/bluetooth
    mkdir /data/misc/bluedroid 0777 bluetooth net_bt_stack
    # bluetooth LPM
    chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm
    chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite

    #USB device
#    insmod /system/lib/modules/rtk_btusb.ko
#    chmod 0666 /dev/rtk_btusb
#    chown bluetooth net_bt_stack /dev/rtk_btusb
    # rfkill
    chmod 0666 /sys/class/rfkill/rfkill0/state
    chmod 0666 /sys/class/rfkill/rfkill0/type
    chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state
    chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type


    # bluetooth MAC address programming
    chown bluetooth net_bt_stack ro.bt.bdaddr_path
    chown bluetooth net_bt_stack /system/etc/bluetooth
    chown bluetooth net_bt_stack /data/misc/bluetooth
    setprop ro.bt.bdaddr_path "/data/misc/bluetooth/bdaddr"
    
####rtk_bt  

6、编译升级后蓝牙可用

 

移植中问题点:

1、打不开蓝牙,lsmod 发现没有加载rtk_btusb.ko,打印logcat,如下:

01-01 08:28:08.165  1665  1707 I ActivityManager: Start proc 3557:com.android.bluetooth/1002 for service com.android.bluetooth/.btservice.AdapterService
01-01 08:28:08.201  1247  1723 E AudioFlinger: PlaybackThread::Track::getNextBuffer:There is not enough data from AudioTrack!!!
01-01 08:28:08.261  3557  3557 E RTKBT   : jniRegisterNativeMethods
01-01 08:28:08.284  3557  3557 D BtSettings.ProfileConfig: Adding HeadsetService
01-01 08:28:08.287  3557  3557 D BtSettings.ProfileConfig: Adding A2dpService
01-01 08:28:08.287  3557  3557 D BtSettings.ProfileConfig: Adding RtkbtService
01-01 08:28:08.287  3557  3557 D BtSettings.ProfileConfig: Adding HidService
01-01 08:28:08.287  3557  3557 D BtSettings.ProfileConfig: Adding HealthService
01-01 08:28:08.287  3557  3557 D BtSettings.ProfileConfig: Adding PanService
01-01 08:28:08.288  3557  3557 D BtSettings.ProfileConfig: Adding GattService
01-01 08:28:08.288  3557  3557 D BtSettings.ProfileConfig: Adding BluetoothMapService
01-01 08:28:08.288  3557  3557 D BtSettings.ProfileConfig: Adding A2dpSinkService
01-01 08:28:08.290  3557  3557 E BtSettings.ProfileConfig: *********Initializing Bluetooth Profile Settings*******
01-01 08:28:08.299  3557  3557 D BtSettings.ProfileConfig: deviceMode from shared preference   -1
01-01 08:28:08.301  3557  3557 E BluetoothServiceJni: No Bluetooth Library found
01-01 08:28:08.301  3557  3557 D BtSettings.ProfileConfig: checkAndAdjustDeviceModeConfiguration deviceMode0
01-01 08:28:08.302  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.hfp.HeadsetService
01-01 08:28:08.302  3557  3557 D BtSettings.ProfileConfig: saveProfileSetting profileName= com.android.bluetooth.hfp.HeadsetServiceenabledtrue
01-01 08:28:08.303  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.a2dp.A2dpService
01-01 08:28:08.303  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.rtkbt.RtkbtService
01-01 08:28:08.304  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.hid.HidService
01-01 08:28:08.304  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.hdp.HealthService
01-01 08:28:08.304  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.pan.PanService
01-01 08:28:08.304  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.gatt.GattService
01-01 08:28:08.305  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.map.BluetoothMapService
01-01 08:28:08.305  3557  3557 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.a2dp.A2dpSinkService
01-01 08:28:08.311  1665  1707 D BluetoothManagerService: Added callback: android.bluetooth.IBluetoothManagerCallback$Stub$Proxy@60f560b:true
01-01 08:28:08.312  3557  3557 D BluetoothAdapterState: make() - Creating AdapterState
01-01 08:28:08.315  3557  3574 I BluetoothAdapterState: Entering OffState
01-01 08:28:08.319  3557  3557 E BluetoothSdpJni: Bluetooth module is not loaded
01-01 08:28:08.323  1665  1707 E BluetoothManagerService: IBluetooth.configHciSnoopLog return false
01-01 08:28:08.326  1665  1707 D BluetoothManagerService: Broadcasting onBluetoothServiceUp() to 5 receivers.
01-01 08:28:08.329  3557  3574 D BluetoothAdapterState: Current state: OFF, message: 0
01-01 08:28:08.329  3557  3574 D BluetoothAdapterProperties: Setting state to 14
01-01 08:28:08.329  3557  3574 I BluetoothAdapterState: Bluetooth adapter state changed: 10-> 14
01-01 08:28:08.330  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.hfp.HeadsetService
01-01 08:28:08.330  3557  3574 W BluetoothAdapterService: isProfileEnabled(): profile not found com.android.bluetooth.hfp.HeadsetService
01-01 08:28:08.330  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.a2dp.A2dpService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: isProfileEnabled(): profile not found com.android.bluetooth.a2dp.A2dpService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.rtkbt.RtkbtService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: isProfileEnabled(): profile not found com.android.bluetooth.rtkbt.RtkbtService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.hid.HidService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: isProfileEnabled(): profile not found com.android.bluetooth.hid.HidService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.hdp.HealthService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: isProfileEnabled(): profile not found com.android.bluetooth.hdp.HealthService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.pan.PanService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: processStart(): profile not enabled: com.android.bluetooth.pan.PanService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.gatt.GattService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: isProfileEnabled(): profile not found com.android.bluetooth.gatt.GattService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.map.BluetoothMapService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: processStart(): profile not enabled: com.android.bluetooth.map.BluetoothMapService
01-01 08:28:08.331  3557  3574 D BtSettings.ProfileConfig: getProfileSaveSetting: com.android.bluetooth.a2dp.A2dpSinkService
01-01 08:28:08.331  3557  3574 W BluetoothAdapterService: processStart(): profile not enabled: com.android.bluetooth.a2dp.A2dpSinkService
01-01 08:28:08.332  3557  3574 D BluetoothBondStateMachine: make
01-01 08:28:08.334  3557  3575 I BluetoothBondStateMachine: StableState(): Entering Off State

解决办法:

在device.mk文件里有PRODUCT_PACKAGES += \
    libbluedroid \

查找libbluedroid,发现bluetooth.c文件里有pid,vid数组,添加相应的模块id,

static struct bt_vid_pid rtk_tables[] =
{
    {0x0bda,0x818c},//RTL8761AW bt + 8192EU wifi combo
    {0x0bda,0xb761},//RTL8761AUV bt only
    {0x0bda,0xb720},//RTL8723BU bt + wifi combo
    {0x0bda,0xb72a},//RTL8723BU bt + wifi combo
    {0x0bda,0xd723},//RTL8723DU bt + wifi combo
    {0x0bda,0xc820},//RTL8821CU bt + wifi combo
};

重新编译后升级,发现lsmod里出现rtk_btusb

2、lsmod里面有rtk_btusb,但是仍然打不开蓝牙,logcat如上还是有:

BluetoothServiceJni: No Bluetooth Library found

BluetoothSdpJni: Bluetooth module is not loaded

解决办法:

rtkbt里面的要对移植包做些修改,根据mstar的demo来修改。修改完成后测试OK,可以打开蓝牙。

3、蓝牙声音发现有声音变调及声音变快问题,已解决。

4、调试过程中相关log:https://download.csdn.net/download/xiangzi10/11158791

你可能感兴趣的:(android层)