rk3288 android8.1 wifi移植记录,rtl8723DU wifi驱动移植到android 8.1

此文记录了如何移植android8.1的wifi驱动,并且,在android系统上可以打开和使用wifi,具体是移植了驱动,hal,wpa等。


rk3288 android8.1 rtl8723du wifi移植终于开始了。

一、 内核部分代码移植步骤:

  1. 首先,问覃胖子要资料,要能治支持rk3288的wifi资料包,里面包含wifi和蓝牙的资料。
    是一个压缩包,我们附件里可以找到,名字叫:567_RTL8723DU_WiFi_linux_v5.6.5.3_35502_COEX20181130-2e2e.20191025.zip.

  2. 解压此包,看说明,看文档,先移植驱动,再移植hardware部分和修framework部分。

  3. 参考网上的资料:https://blog.csdn.net/bhj1119/article/details/51858635

  4. 先进入内核,make menuconfig配置linux内核:

(1)Networking support —>Wireless下增加802.11 协议栈的支持,debug的选项不一定要选上,非debug的选项802.11相关的,应该选上。

--- Wireless                                                                                                                         
<M>   cfg80211 - wireless configuration API
[*]     nl80211 testmode command   
[ ]     enable developer warnings                                                                                                     
[ ]     cfg80211 regulatory debugging 
[*]     enable powersave by default
[*]     cfg80211 DebugFS entries
[ ]     use statically compiled regulatory rules database  
[*]     cfg80211 wireless extensions compatibility
  [*]   Wireless extensions sysfs files 
-*-   Common routines for IEEE802.11 drivers
[ ]   lib80211 debugging messages  
[*]   Allow reconnect while already connected 
<M>   Generic IEEE 802.11 Networking Stack (mac80211)  
[ ]   PID controller based rate control algorithm  
[*]   Minstrel
[*]     Minstrel 802.11n support  
     Default rate control algorithm (Minstrel)  --->  
[*]   Enable mac80211 mesh networking (pre-802.11s) support 
  [ ]   Enable LED triggers  
[ ]   Export mac80211 internals in DebugFS
[ ]   Select mac80211 debugging features  ---> 

(2) 配置内核usb相关。

Device Drivers  --->
USB support  --->
<*>   USB Wireless Device Management support

这个选项一些内核,不一定有,有的选上,支持WIFI。

  1. 将RTL8723DU_WiFi_linux_v5.6.5.3_35502_COEX20181130-2e2e.20191025/driver下的压缩包拷贝到 XXX_ANDROID_SDK/kernel/drivers/net/wireless 下,解压,进入目录修改其Makefile,编译wifi驱动模块,修改动,先找到:CONFIG_PLATFORM_ARM_RK3188,我们参照这个,搜素相关条目,在这个参照基础上修改即可,例如我参照3188添加3288相关编译:

先修改定义:


CONFIG_PLATFORM_ARM_TCC8930_JB42 = n
CONFIG_PLATFORM_ARM_RK2818 = n
CONFIG_PLATFORM_ARM_RK3066 = n
CONFIG_PLATFORM_ARM_RK3188 = y
##add for test, modified by done lin
CONFIG_PLATFORM_ARM_RK3288 = y
CONFIG_PLATFORM_ARM_URBETTER = n
CONFIG_PLATFORM_ARM_TI_PANDA = n
CONFIG_PLATFORM_MIPS_JZ4760 = n

参照3188的配置部分的说明,在接下来的配置段文本内,添加,注意:CROSS_COMPILE, KSRC这两个路径,是绝对路径。

###################################################################
##add for test,add by lin
ifeq ($(CONFIG_PLATFORM_ARM_RK3288), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ANDROID -DCONFIG_PLATFORM_ROCKCHIPS
# default setting for Android 4.1, 4.2, 4.3, 4.4
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
# default setting for Power control
# default setting for Power control
##EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC//delete by lin.add for test,这个有些版本的android可能没有此功能,我这rk3288没有,要屏蔽,否则get_cournty_code错误。
##此功能是用于并发模式的,我们不需并发模式,所以这个功能可以不编译进去。
##我的解决方案是注释掉get_country_codec错误代码。
###if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) || defined(COMPAT_KERNEL_RELEASE)
##void *wifi_get_country_code(char *ccode)
##{
    
    
##	RTW_INFO("%s\n", __FUNCTION__);
##	if (!ccode)
##		return NULL;
##	//if (wifi_control_data && wifi_control_data->get_country_code)
##	//	return wifi_control_data->get_country_code(ccode);
##	return NULL;
##}
###endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) */
##
##
## EXTRA_CFLAGS += -DRTW_SUPPORT_PLATFORM_SHUTDOWN ##注释掉这个,这个我们的电源是io控制的。不影响使用,不去掉这个反而编译不过。
# default setting for Special function
ARCH := arm
CROSS_COMPILE := /Disk5/rk3288android8.1/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-
KSRC := /Disk5/rk3288android8.1/kernel
MODULE_NAME := wlan
endif
###################################################################

保存makefile,退出!

  1. 修改内核的Makefile和Kconfig,使得内核make menuconfig配置选择可以使用内核。
gedit  kernel/drivers/net/wireless/Makefile 

文件末尾,参照文本其他配置的方法,添加文本,注意目录名字,我的wifi驱动目录名字是rtl8723DU:

obj-$(CONFIG_RTL8723DU) += rtl8723DU/

gedit ./kernel/drivers/net/wireless/Kconfig
添加:
source "drivers/net/wireless/rtl8723DU/Kconfig"
  1. 之后,编译内核,发现内核编译正常通过,在rtl8723DU成wlan.ko文件。
    到此,内核驱动已经成功移植。

二. 移植hal层和framework层的wifi相关代码.

  1. 在厂家给的资料包里面,找到:realtek_wifi_SDK_for_android_O_8.0_20181001.tar.gz,
    反正就类似这个名字,里面就有很多安卓版本的资料,记得对应上,例如,我的是安卓8.1的。
    解压这个包,得到一个wlan名字的文件夹,这个就是android 8.1 HAL层wifi源码,我们需要,把它放到 ANDROID_SDK/hardware/realtek目录下面(原来有这个文件夹,的要替换,做好备份)。

  2. 修改BoardConfig.mk文件:
    gedit ./device/rockchip/rk3288/BoardConfig.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 := realtek
endif
  1. 修改init.rk3288.rc文件:

gedit ./device/rockchip/rk3288/init.rk3288.rc

在on boot添加下面的代码,目的是让android卡机时候可以加载模块:

exec u:r:vendor_modprobe:s0 root root -- /vendor/bin/toybox_vendor insmod /vendor/modules/wlan.ko ifname=wlan0

同时,在service的地方,添加一个新的service:

service wpa_supplicant /system/vendor/bin/hw/wpa_supplicant \
	-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
	-O/data/misc/wifi/sockets \
	-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
	socket wpa_wlan0 dgram 660 wifi wifi
	class main
	disabled
	oneshot
  1. 修改device.mk文件:
    gedit ./device/rockchip/rk3288/device.mk

添加:

PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml
  1. 在同一个device.mk文件中添加: wifi.interface
    Set wifi.interface

  2. 确保Toybox_vendor编译进系统里,因为busybox用到是gpl协议,所以android改用toybox, BSD协议(有些系统上面可能已经做了,不必要修改)

#ifeq ($(PRODUCT_FULL_TREBLE),true)
############################################
# static version to be installed in /vendor
#
….
LOCAL_MODULE := toybox_vendor
….
include $(BUILD_EXECUTABLE)
#endif
  1. 修改支持 wifi_hal(有些系统上面可能已经做了,不必要修改)
gedit $ANDROID_SDK/frameworks/opt/net/wifi/libwifi_hal/Android.mk

# Pick a vendor provided HAL implementation library.
# ============================================================
LIB_WIFI_HAL := libwifi-hal-fallback
….
else ifeq ($(BOARD_WLAN_DEVICE), realtek)
# support RTK WIFI HAL
LIB_WIFI_HAL := libwifi-hal-rtk
endif
….

8. 修改manifest.xml, 添加wifi支持,添加supplicant支持(有些系统上面可能已经做了,不必要修改):
gedit ./device/rockchip/rk3288/manifest.xml

    <hal format="hidl">
        <name>android.hardware.wifi</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IWifi</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.wifi.supplicant</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ISupplicant</name>
            <instance>default</instance>
        </interface>
    </hal>
  1. wpa_supplicant配置文件的修改(./external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.conf):
    如果你的wifi驱动版本大于等于 v5.9, 要修改文件wpa_supplicant.conf:
#Add this parameter
p2p_disabled=1
#Add this parameter
p2p_no_group_iface=1
  1. 配置系统资源,修改 frameworks/base/core/res/res/values/config.xml,添加如下(下面几个配置,都是在这个文件修改,但其实一般都是配置好的):
    <string-array translatable="false" name="networkAttributes">
        <item>"wifi,1,1,1,-1,true"</item>
        <item>"mobile,0,0,0,-1,true"</item>
        <item>"mobile_mms,2,0,2,60000,true"</item>
        <item>"mobile_supl,3,0,2,60000,true"</item>
        <item>"mobile_dun,4,0,2,60000,true"</item>
        <item>"mobile_hipri,5,0,3,60000,true"</item>
        <item>"mobile_fota,10,0,2,60000,true"</item>
        <item>"mobile_ims,11,0,2,60000,true"</item>
        <item>"mobile_cbs,12,0,2,60000,true"</item>
        <item>"wifi_p2p,13,1,0,-1,true"</item>
        <item>"mobile_ia,14,0,2,-1,true"</item>
        <item>"mobile_emergency,15,0,2,-1,true"</item>
    </string-array>

配置 networkAttributes
To define the system’s available network interfaces, make sure the wifi interface
items is defined in the networkAttributes resource configuration in the config.xml.
For example:
l radioAttributes
To define the system’s available network interfaces, we need to define interface
items for wifi in the radioAttributes resource configuration. For example:

<string-array translatable="false" name="radioAttributes">
<item>"1,1"</item>
<item>"7,1"</item>
<item>"9,1"</item>
....

l config_tether_wifi_regexs
The interfaces set here are tetherable Wi-Fi interfaces which will be used as
interfaces for Wi-Fi LAN port. We use ‘wlan0’ by default when our Wi-Fi is set as
softap mode. So it needs to set ‘wlan0’ here. For example:

<string-array translatable="false" name="config_tether_wifi_regexs">
<item>"wlan0"</item>
</string-array>

l 配置 config_tether_upstream_types
The connection types set here are used as the interfaces for WAN port to connect
to internet. For example, adding Wi-Fi and Ethernet:


<integer-array translatable="false" name="config_tether_upstream_types">
<item>1</item>
<item>9</item>
</integer-array>

l 配置 config_enableWifiDisplay

To enable Wi-Fi Display(Miracast) function, set config_enableWifiDisplay
<bool name="config_enableWifiDisplay">true</bool>

注意,最后面3个步骤的xml配置,其实一般android 8.1已经做好了,我们不需要做。。

  1. 按照流程走完了,可是还是发现不了wifi,提示出错? 一毛一样啊??
    为毛?
    原来rk自己修改了编译脚本,
    https://blog.csdn.net/kris_fei/article/details/73647370

我们要跟着修改:

ifneq ($(strip $(TARGET_BOARD_PLATFORM)), sofia3gr)
BOARD_CONNECTIVITY_VENDOR := realtek
BOARD_CONNECTIVITY_MODULE := ap6xxx
endif


BOARD_WIFI_VENDOR := realtek
ifeq ($(strip $(BOARD_CONNECTIVITY_VENDOR)), realtek)
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
WPA_SUPPLICANT_VERSION      := VER_0_8_X
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_HOSTAPD_DRIVER        := NL80211
BOARD_HOSTAPD_PRIVATE_LIB   := lib_driver_cmd_rtl
BOARD_WLAN_DEVICE           := realtek
endif
  1. 编译整个rk3288安卓系统,就可看到wifi打开了!哦,不,我这里还需要开机的时候,打开wifi电源,设置gpio225输出1!
    其实rtl官方提供了整一个开放资料包,里面有源码,工具,移植文档,支持从4.4—9.0版本的wifi移植,这个可以到我的下载区域去下载。记得doneli
    https://download.csdn.net/download/mynameislinduan/12837245

猜你喜欢

转载自blog.csdn.net/mynameislinduan/article/details/108531840