本文主要记录给Baytrail 平台 Android6.0系统移植EWM-W163M201E WiFi的过程和中间遇到的问题。Android版本是6.0,Kernel版本是3.14.64,CPU是 Bay Trail平台Vallyview-D/M系列,WiFi是研华的EWM-W163M201E模块。
WiFi驱动一般都是wifi 厂商提供的,一般情况下厂商会提供wifi驱动,wifi firmware和wifi potting guide等资料给软件工程师 。本次使用的EWM-W163M201E wifi模块的Main Chipset是 QCA6174A 它需要的驱动是ath10k。厂商说这个驱动是包含在Linux源码中的,但是通过查看源码发现我们的3.14.64 kernel里面的ath10k驱动由于版本较低的缘故还没有添加QCA6174A 的支持。那么就遇到一个比较尴尬的事情,没有任何驱动也没有任何资料可以使用参考。没办法我就查找各种资料幸好功夫不负有心人我找到了compat-wireless驱动源码,发现里面有我们需要的驱动。我们就从下面路径下载了comat-wireless驱动compat-wireless-2017-09-25.tar.xz,然后单独编译移植到我们的系统。
compat-wireless驱动下载地址:http://mirror2.openwrt.org/sources/
--- a/compat-wireless-2017-09-25/Makefile 2017-09-29 04:51:19.000000000 +0800
+++ b/compat-wireless-2017-09-25/Makefile 2019-01-15 17:29:54.336700189 +0800
@@ -8,14 +8,18 @@ MAKEFLAGS += --no-print-directory
SHELL := /bin/bash
BACKPORT_DIR := $(shell pwd)
-KMODDIR ?= updates
+KMODDIR = kernel
ifneq ($(origin KLIB), undefined)
KMODPATH_ARG := "INSTALL_MOD_PATH=$(KLIB)"
else
-KLIB := /lib/modules/$(shell uname -r)/
+KLIB := "/home/work/Android_BSP/byt_mr_2016ww32/device/advantech/upos-kernel/x86_64/"
-KMODPATH_ARG :=
+KMODPATH_ARG := "INSTALL_MOD_PATH=$(KLIB)"
endif
-KLIB_BUILD ?= $(KLIB)/build/
+KLIB_BUILD = "/home/work/Android_BSP/byt_mr_2016ww32/device/advantech/upos-kernel/linux"
KERNEL_CONFIG := $(KLIB_BUILD)/.config
KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')
Android相关修改主要包括添加wifi firmware,hardware层修改,framwork层修改,wpa_supplicant服务添加等。下面我们逐一来介绍。
--- a/device/advantech/upos/upos.mk
+++ b/device/advantech/upos/upos.mk
@@ -68,6 +68,18 @@ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/third_party/busybox-x86_64:system/bin/busybox-x86_64 \
$(LOCAL_PATH)/third_party/busybox-x86_64:system/bin/busybox
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw3.0/board.bin:system/vendor/firmware/ath10k/QCA6174/hw3.0/board.bin \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw3.0/board-2.bin:system/vendor/firmware/ath10k/QCA6174/hw3.0/board-2.bin \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw3.0/firmware-4.bin:system/vendor/firmware/ath10k/QCA6174/hw3.0/firmware-4.bin \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw3.0/notice_ath10k_firmware-4.txt:system/vendor/firmware/ath10k/QCA6174/hw3.0/notice_ath10k_firmware-4.txt \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw2.1/board.bin:system/vendor/firmware/ath10k/QCA6174/hw2.1/board.bin \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw2.1/board-2.bin:system/vendor/firmware/ath10k/QCA6174/hw2.1/board-2.bin \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw2.1/firmware-5.bin:system/vendor/firmware/ath10k/QCA6174/hw2.1/firmware-5.bin \
+ $(LOCAL_PATH)/third_party/ath10k/QCA6174/hw2.1/notice_ath10k_firmware-5.txt:system/vendor/firmware/ath10k/QCA6174/hw2.1/notice_ath10k_firmware-5.txt \
+ $(LOCAL_PATH)/third_party/ath10k/ath10k.conf:system/etc/modprobe.d/ath10k.conf
+
+
PRODUCT_PACKAGES += \
AndroidTerm \
libjackpal-androidterm4 \
需要注意的是给系统的system/etc/modprobe.d/路径下还拷贝了ath10k.conf文件,该文件只有一条命令,但是是必须添加的因为发现如果不添加驱动加载的时候会报错 options ath10k_core skip_otp=y
--- a/device/advantech/upos/BoardConfig.mk
+++ b/device/advantech/upos/BoardConfig.mk
@@ -207,6 +207,19 @@ BOARD_HAVE_BLUETOOTH_LINUX := false
BOARD_KERNEL_CMDLINE += acpi_backlight=video
+##############################################################
+# Source: device/intel/mixins/groups/wlan/autodetect/BoardConfig.mk
+##############################################################
+ADDITIONAL_DEFAULT_PROPERTIES += wifi.interface=wlan0
+#WPA_SUPPLICANT_VERSION := VER_2_1_DEVEL
+WPA_SUPPLICANT_VERSION := VER_0_8_X
+BOARD_WPA_SUPPLICANT_DRIVER := NL80211
+#WIFI_DRIVER_MODULE_PATH ?= auto
+#BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
+BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_qcwcn
+BOARD_WLAN_DEVICE := qcwcn
+DEVICE_PACKAGE_OVERLAYS += device/intel/common/wlan/overlay-wifi-display
+
DEVICE_PACKAGE_OVERLAYS += device/intel/common/audio/overlay
DEVICE_PACKAGE_OVERLAYS += device/intel/common/audio/overlay-no-ultrasound
--- a/device/intel/common/wlan/overlay-wifi-display/frameworks/base/core/res/res/values/config.xml
+++ b/device/intel/common/wlan/overlay-wifi-display/frameworks/base/core/res/res/values/config.xml
@@ -14,4 +14,50 @@
-->
true
+
+
+
+
+
+ - "wifi,1,1,1,-1,true"
+ - "mobile,0,0,0,-1,true"
+ - "mobile_mms,2,0,2,60000,true"
+ - "mobile_supl,3,0,2,60000,true"
+ - "mobile_hipri,5,0,3,60000,true"
+ - "ethernet,9,9,1,-1,true"
+ - "mobile_fota,10,0,2,60000,true"
+ - "mobile_ims,11,0,2,60000,true"
+ - "mobile_cbs,12,0,2,60000,true"
+ - "wifi_p2p,13,1,0,-1,true"
+
+
+
+
+ - "1,1"
+ - "0,1"
+ - "9,1"
+
+
+
+
+ - 0
+ - 2
+ - 3
+ - 4
+ - 5
+ - 9
+ - 10
+ - 11
+ - 12
+
+
+
--- a/device/advantech/upos/device.mk
+++ b/device/advantech/upos/device.mk
@@ -303,6 +303,19 @@ PRODUCT_COPY_FILES += \
PRODUCT_PACKAGES += \
audio.a2dp.default
+##############################################################
+# Source: device/intel/mixins/groups/wlan/autodetect/product.mk
+##############################################################
+PRODUCT_COPY_FILES += \
+ device/intel/common/wlan/wpa_supplicant-common.conf:system/etc/wifi/wpa_supplicant.conf \
+ device/intel/common/wlan/wpa_supplicant_overlay.conf:system/etc/wifi/wpa_supplicant_overlay.conf \
+ 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 += \
+ wpa_supplicant
+
+
# Tinyalsa
PRODUCT_PACKAGES_DEBUG += \
tinymix \
上面出来添加wpa_supplicant的编译外还将需要的wpa_cupplicant.conf配置文件也拷贝到了系统指定目录,另外frameworks/native/data/etc/android.hardware.wifi.xml和frameworks/native/data/etc/android.hardware.wifi.direct.xml分别代表的是设备是否支持wifi功能和wifi直连功能,如果不添加android.hardware.wifi.xml的话在Setting中就无法看到WIFI选项。--- a/device/advantech/upos/init.rc
+++ b/device/advantech/upos/init.rc
@@ -14,6 +14,12 @@ on post-fs-data
on post-fs-data
setprop persist.sys.root_access 3
+on post-fs-data
+ mkdir /data/misc/wifi 0770 wifi wifi
+ mkdir /data/misc/wifi/sockets 0770 wifi wifi
+ mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
+ mkdir /data/misc/dhcp 0770 dhcp dhcp
+
on boot
setprop service.adb.tcp.port 5555
@@ -214,6 +220,42 @@ on post-fs-data
import /init.debug-charging.rc
+
+service wpa_supplicant /system/bin/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
+ class main
+ socket wpa_wlan0 dgram 660 wifi wifi
+ disabled
+
+
+#setprop wifi.supplicant wpa_supplicant
+
+
+service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL
+ class main
+ disabled
+ oneshot
+
+service iprenew_wlan0 /system/bin/dhcpcd -n
+ class main
+ disabled
+ oneshot
+
+on property:init.svc.wpa_supplicant=stopped
+ stop dhcpcd
+
on fs
mkdir /dev/pstore 0755 root system
mount pstore pstore /dev/pstore
我们在移植的时候发现系统状态栏的网络状态显示不正常,老是存在一个感叹号,但是网络却是可以使用的。经过追踪代码发现是Android网络的验证机制导致的。Android系统可以通过Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED全局变量来控制网络连接以后是否需要进行网络可用性检查。如果该值被设置为1或者没有设置该值则系统会通过访问Settings.Global.CAPTIVE_PORTAL_SERVER全局变量指定的网址来判断网络是否可用。如果全局变量Settings.Global.CAPTIVE_PORTAL_SERVER没有被设置系统则会使用默认的DEFAULT_SERVER="connectivitycheck.gstatic.com"网址测试。那么问题就出在这里,国内由于某种原因这个网址有时可用连接上有时连接不上,所以当连接不上的时候无论是Ethernet网络、WiFi网络还是3G/4G网络,它的状态栏图标都会有感叹号。想了解这部分可以参考/frameworks/base/services/core/java/com/android/server/connectivity/NetworkMonitor.java代码。那么问题找到了该怎么解决呢?一般有下面两种方法可以解决:
那么我们就是使用第二种方法解决了这个问题的。做法如下:
--- a/device/advantech/upos/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/device/advantech/upos/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -22,6 +22,12 @@
false
true
+
+
+ 1
+
+
+ 204.gentool.top
--- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2576,6 +2576,12 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadBooleanSetting(stmt, Settings.Global.ASSISTED_GPS_ENABLED,
R.bool.assisted_gps_enabled);
+ loadIntegerSetting(stmt, Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED,
+ R.integer.def_captive_portal_detection_enable);
+
+ loadStringSetting(stmt, Settings.Global.CAPTIVE_PORTAL_SERVER,
+ R.string.def_captive_portal_server);
+
loadBooleanSetting(stmt, Settings.Global.AUTO_TIME,
R.bool.def_auto_time); // Sync time to NITZ