RTL8723BU移植

硬件平台:IMX6Q+RTL8723BU(蓝牙4.0+WIFI)
软件操作系统:Android 4.2
rtl8723bu驱动版本:
rtl8723BU_WiFi_linux_v4.3.9.3_13200.20150106_BTCOEX20140929-5443.tar.gz

解压rtl8723bu驱动
到”/root/IMX6Q_android4.2.2/kernel_imx/drivers/net/wireless”,
重命名为rtl8723bu
RTL8723BU移植_第1张图片
修改IMX6Q_android4.2.2/kernel_imx/drivers/net/wireless/Makefile
添加:

obj-$(CONFIG_RTL8723BU) += rtl8723bu/

修改IMX6Q_android4.2.2/kernel_imx/drivers/net/wireless/Kconfig
添加
source “drivers/net/wireless/rtl8723bu/Kconfig”

修改rtl8723bu驱动Makefile文件,支持IMX6Q

diff -Npur a/Makefile b/Makefile
--- a/Makefile  2015-01-06 16:37:13.000000000 +0800
+++ b/Makefile  2016-08-15 15:10:28.698828578 +0800
@@ -70,7 +70,7 @@ CONFIG_AP_WOWLAN = n
 ######### Notify SDIO Host Keep Power During Syspend ##########
 CONFIG_RTW_SDIO_PM_KEEP_POWER = y
 ###################### Platform Related #######################
-CONFIG_PLATFORM_I386_PC = y
+CONFIG_PLATFORM_I386_PC = n
 CONFIG_PLATFORM_ANDROID_X86 = n
 CONFIG_PLATFORM_ANDROID_INTEL_X86 = n
 CONFIG_PLATFORM_JB_X86 = n
@@ -115,6 +115,9 @@ CONFIG_PLATFORM_ARM_WMT = n
 CONFIG_PLATFORM_TI_DM365 = n
 CONFIG_PLATFORM_MOZART = n
 CONFIG_PLATFORM_RTK119X = n
+CONFIG_PLATFORM_NOVATEK_NT72668 = n
+CONFIG_PLATFORM_HISILICON = n
+CONFIG_PLATFORM_FSL_IMX6Q = y
 ###############################################################

 CONFIG_DRVEXT_MODULE = n
@@ -1048,6 +1051,17 @@ KSRC := /home/android_sdk/nvidia/tegra-1
 MODULE_NAME := wlan
 endif

+ifeq ($(CONFIG_PLATFORM_FSL_IMX6Q), y)
+EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
+EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
+EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
+EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
+EXTRA_CFLAGS += -DCONFIG_P2P_IPS
+ARCH := arm
+CROSS_COMPILE := /root/IMX6Q_android4.2.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
+KSRC := /root/IMX6Q_android4.2.2/kernel_imx
+MODULE_NAME := 8723bu
+endif
 ifeq ($(CONFIG_PLATFORM_TEGRA4_DALMORE), y)
 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
 # default setting for Android 4.1, 4.2

配置内核,添加支持rtl8723bu
WIFI部分
RTL8723BU移植_第2张图片
BT部分
RTL8723BU移植_第3张图片

修改Android代码,支持RTL8723BU (BT+WIFI)
修改device/fsl/imx6/etc/init.rc

diff -Npur a/device/fsl/imx6/etc/init.rc b/device/fsl/imx6/etc/init.rc
--- a/device/fsl/imx6/etc/init.rc   2016-04-20 00:36:51.000000000 +0800
+++ b/device/fsl/imx6/etc/init.rc   2016-06-03 19:35:24.000000000 +0800
@@ -111,6 +111,7 @@ loglevel 3
     write /proc/sys/kernel/kptr_restrict 2
     write /proc/sys/kernel/dmesg_restrict 1
     write /proc/sys/vm/mmap_min_addr 32768
+    write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
     write /proc/sys/kernel/sched_rt_runtime_us 950000
     write /proc/sys/kernel/sched_rt_period_us 1000000

@@ -139,6 +140,11 @@ loglevel 3
     write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
     write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000

+# qtaguid will limit access to specific data based on group memberships.
+#   net_bw_acct grants impersonation of socket owners.
+#   net_bw_stats grants access to other apps' detailed tagged-socket stats.
+    chown root net_bw_acct /proc/net/xt_qtaguid/ctrl
+    chown root net_bw_stats /proc/net/xt_qtaguid/stats
 # Allow everybody to read the xt_qtaguid resource tracking misc dev.
 # This is needed by any process that uses socket tagging.
     chmod 0644 /dev/xt_qtaguid
@@ -216,12 +222,16 @@ on post-fs-data
     mkdir /data/misc/ 0770 system 
     mkdir /data/misc/systemkeys 0700 system system
     # give system access to wpa_supplicant.conf for backup and restore
-    mkdir /data/misc/wifi 0770 wifi system
-    chmod 0770 /data/misc/wifi
+    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
+    chown dhcp system /data/misc/dhcp
     chmod 0660 /data/misc/wifi/wpa_supplicant.conf
     chmod 0775 /data/misc/wifi/ipconfig.txt
     chmod 0775 /system/etc/dhcpcd/dhcpcd-run-hooks
     mkdir /data/local 0751 root root
+    mkdir /data/misc/media 0700 media media

     # For security reasons, /data/local/tmp should always be empty.
     # Do not place files or directories in /data/local/tmp
@@ -235,9 +245,6 @@ on post-fs-data
     mkdir /data/property 0700 root root
     mkdir /data/ssh 0750 root shell
     mkdir /data/ssh/empty 0700 root root
-    mkdir /data/system 0775 system system
-    mkdir /data/system/wpa_supplicant 0771 wifi wifi
-    chmod 0771 /data/system/wpa_supplicant

     # create dalvik-cache, so as to enforce our permissions
     mkdir /data/dalvik-cache 0771 system system
@@ -264,6 +271,36 @@ on post-fs-data
     # Set indication (checked by vold) that we have finished this action
     setprop vold.post_fs_data_done 1

+#wifi  
+   mkdir /data/system 0775 system system
+       mkdir /data/system/wpa_supplicant 0771 wifi wifi
+       chmod 0771 /data/system/wpa_supplicant
+       symlink /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant
+   
+   setprop wifi.supp_delay_para 800
+   setprop wifi.supplicant_scan_interval 10
+   setprop wifi.wapi.supported true
+   setprop wifi.interface wlan0
+   setprop wlan.driver.status ok
+   mkdir /system/etc/wifi 0777 wifi wifi
+   chmod 0777 /system/etc/wifi
+   chmod 0777 /system/etc/wifi/wpa_supplicant.conf
+   chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
+   mkdir /data/misc/wifi 0777 wifi wifi
+   mkdir /data/misc/wifi/sockets 0777 wifi wifi
+   chmod 0777 /data/misc/wifi
+   chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
+   chown wifi wifi /data/misc/wifi
+   chmod 0666 /data/misc/wifi/wpa_supplicant.conf
+   mkdir /data/system/wpa_supplicant
+   chmod 0777 /data/system/wpa_supplicant
+   chmod 0777 /wlan0
+   #chown wifi system /data/system/wpa_supplicant
+   chown wifi system /wlan0
+   mkdir /data/misc/dhcp 0777 system system
+   chmod 0770 /data/misc/dhcp
+   chown dhcp dhcp /data/misc/dhcp
+   chown root system /data

 on boot
 # basic network init
@@ -324,12 +361,6 @@ on boot
     chown system system /sys/class/leds/red/device/grpfreq
     chown system system /sys/class/leds/red/device/grppwm
     chown system system /sys/class/leds/red/device/blink
-    chown system system /sys/class/leds/red/brightness
-    chown system system /sys/class/leds/green/brightness
-    chown system system /sys/class/leds/blue/brightness
-    chown system system /sys/class/leds/red/device/grpfreq
-    chown system system /sys/class/leds/red/device/grppwm
-    chown system system /sys/class/leds/red/device/blink
     chown system system /sys/class/timed_output/vibrator/enable
     chown system system /sys/module/sco/parameters/disable_esco
     chown system system /sys/kernel/ipv4/tcp_wmem_min
@@ -344,6 +375,7 @@ on boot
 #   ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
     setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
     setprop net.tcp.buffersize.wifi    524288,1048576,2097152,262144,524288,1048576
+    setprop net.tcp.buffersize.ethernet 524288,2097152,4194304,524288,2097152,4194304
     setprop net.tcp.buffersize.lte     524288,1048576,2097152,262144,524288,1048576
     setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
     setprop net.tcp.buffersize.hspa    4094,87380,262144,4096,16384,262144
@@ -373,10 +405,8 @@ on boot
 # Prepare for wifi
     setprop wifi.interface wlan0
     setprop wifi.ap.interface wlan0
-    mkdir /data/misc/wifi/sockets 0770 wifi system
-    mkdir /data/misc/dhcp 0770 dhcp dhcp
-    chown dhcp dhcp /data/misc/dhcp

+#  write /sys/bus/usb/devices/2-1.4/bConfigurationValue 1

     chmod 777 /dev/ttyUSB0
     chmod 777 /dev/ttyUSB2
@@ -394,9 +424,9 @@ on boot
     write /sys/bus/platform/drivers/fsl-ehci/fsl-ehci.1/power/wakeup disabled

 # serial no, vendor id,etc configure
-    write /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturer
-    write /sys/class/android_usb/android0/iProduct $ro.product.model
-    write /sys/class/android_usb/android0/iSerial $ro.serialno
+    write /sys/class/android_usb/android0/iSerial ${ro.serialno}
+    write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
+    write /sys/class/android_usb/android0/iProduct ${ro.product.model}

 # Prepare for RIL
     setprop gsm.ril.delay 15
@@ -560,20 +590,7 @@ service bootanim /system/bin/bootanimati
     disabled
     oneshot

-service dbus /system/bin/dbus-daemon --system --nofork
-    class main
-    socket dbus stream 660 bluetooth bluetooth
-    user bluetooth
-    group bluetooth net_bt_admin
-
-service bluetoothd /system/bin/bluetoothd -n
-    class main
-    socket bluetooth stream 660 bluetooth bluetooth
-    socket dbus_bluetooth stream 660 bluetooth bluetooth
-    # init.rc does not yet support applying capabilities, so run as root and
-    # let bluetoothd drop uid to bluetooth with the right linux capabilities
-    group bluetooth net_bt_admin misc
-    disabled
+

 service installd /system/bin/installd
     class main
@@ -630,32 +647,43 @@ service mdnsd /system/bin/mdnsd
     disabled
     oneshot

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

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

 service dhcpcd_eth0 /system/bin/dhcpcd -ABKL 
-    class late_start
+    class main
     disabled
     oneshot

-service dhcpcd_eth1 /system/bin/dhcpcd -ABKL 
-    class late_start
+service dhcpcd_bt-pan /system/bin/dhcpcd -ABKL
+    class main
     disabled
     oneshot

-service hostapd /system/bin/hostapd /data/misc/wifi/hostapd.conf
-    socket hostapd_wlan0 dgram 660 root wifi
-    user root
-    group wifi
+service iprenew_wlan0 /system/bin/dhcpcd -n
+    class main
+    disabled
+    oneshot
+service iprenew_p2p /system/bin/dhcpcd -n
+    class main
+    disabled
     oneshot
+
+service iprenew_eth0 /system/bin/dhcpcd -n
+    class main
+    disabled
+    oneshot
+service iprenew_bt-pan /system/bin/dhcpcd -n
+    class main
     disabled
+    oneshot

 service ril-daemon /system/bin/rild -l /system/lib/libhuawei-ril.so 
     class main

修改device/fsl/imx6/etc/ueventd.freescale.rc

diff -Npur a/device/fsl/imx6/etc/ueventd.freescale.rc b/device/fsl/imx6/etc/ueventd.freescale.rc
--- a/device/fsl/imx6/etc/ueventd.freescale.rc  2016-01-14 10:04:15.000000000 +0800
+++ b/device/fsl/imx6/etc/ueventd.freescale.rc  2016-06-01 16:12:29.000000000 +0800
@@ -1,5 +1,6 @@
 /dev/pmem_gpu             0660   system     graphics
 /dev/irtouch              0666   root    root
+/dev/rtk_btusb       0660   bluetooth  bluetooth
 /dev/snd/*                0664   system     audio
 /dev/ttyUSB*              0640   radio      radio
 /dev/ttyACM*              0640   radio      radio

修改device/fsl/imx6/imx6.mk

diff -Npur a/device/fsl/imx6/imx6.mk b/device/fsl/imx6/imx6.mk
--- a/device/fsl/imx6/imx6.mk   2016-05-06 00:20:01.000000000 +0800
+++ b/device/fsl/imx6/imx6.mk   2016-06-01 17:52:32.000000000 +0800
@@ -19,6 +19,8 @@ PRODUCT_PACKAGES += \
    Email                   \
    FSLOta                  \
    CactusPlayer                            \
+   WfdSink                                 \
+   wfd                                     \
    ethernet                                \
    VideoEditor             \
    FSLProfileApp               \
@@ -35,13 +37,13 @@ PRODUCT_PACKAGES += \
    ip-up-ppp0              \
    ip-down-ppp0                \
    wpa_supplicant              \
+   rtl_wpa_supplicant          \
    wpa_supplicant.conf         \
-   wpa_supplicant_p2p.conf         \
+   p2p_supplicant_overlay.conf         \
+   wpa_supplicant_overlay.conf         \
    dispd                   \
    ts_calibrator               \
    libion                                  \
-   MarvellWirelessDaemon           \
-   libMarvellWireless          \
    display_mode_fb0.conf                   \
    display_mode_fb2.conf                   \
    display_mode_fb4.conf
@@ -134,9 +136,6 @@ PRODUCT_PACKAGES += \
    iwlwifi-6000-4.ucode            \
    iwlwifi-5000-5.ucode            \
    iwlagn.ko
-#MARVELL sd8787 wifi firmware
-PRODUCT_PACKAGES += \
-   sd8787_uapsta.bin           \
 # gps related lib
 PRODUCT_PACKAGES += \
@@ -307,17 +306,8 @@ PRODUCT_COPY_FILES +=  \
    device/fsl/common/input/Dell_Dell_USB_Keyboard.idc:system/usr/idc/Dell_Dell_USB_Keyboard.idc \
    device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/eGalax_Touch_Screen.idc \
    device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/HannStar_P1003_Touchscreen.idc \
-   device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/Vendor_0eef_Product_725e.idc \
-   device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/Vendor_6615_Product_0001.idc \
    device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/Novatek_NT11003_Touch_Screen.idc \
-   device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/Vendor_0eef_Product_0001.idc \
    device/fsl/common/input/eGalax_Touch_Screen.idc:system/usr/idc/ft5x0x_ts.idc \
-   device/fsl/common/input/Vendor_6615_Product_0080.idc:system/usr/idc/Vendor_6615_Product_0080.idc \
-   device/fsl/common/input/Vendor_6615_Product_0081.idc:system/usr/idc/Vendor_6615_Product_0081.idc \
-   device/fsl/common/input/Vendor_6615_Product_0081.idc:system/usr/idc/Vendor_14e1_Product_3500.idc \
-   device/fsl/common/input/PenMount_6000_USB_TouchScreen.idc:system/usr/idc/PenMount_6000_USB_TouchScreen.idc \
-   device/fsl/common/input/ilitek_hid.idc:system/usr/idc/ilitek_hid.idc \
-   device/fsl/common/input/eGalaxTouch_VirtualDevice.idc:system/usr/idc/eGalaxTouch_VirtualDevice.idc \
    device/fsl/imx6/etc/init.rc:root/init.rc \
    device/fsl/imx6/etc/apns-conf.xml:system/etc/apns-conf.xml \
    device/fsl/imx6/etc/init.usb.rc:root/init.freescale.usb.rc \

修改device/fsl/sabresd_6dq/bluetooth/bdroid_buildcfg.h

diff -Npur a/device/fsl/sabresd_6dq/bluetooth/bdroid_buildcfg.h b/device/fsl/sabresd_6dq/bluetooth/bdroid_buildcfg.h
--- a/device/fsl/sabresd_6dq/bluetooth/bdroid_buildcfg.h    2015-02-06 23:22:50.000000000 +0800
+++ b/device/fsl/sabresd_6dq/bluetooth/bdroid_buildcfg.h    2016-06-01 16:12:29.000000000 +0800
@@ -24,10 +24,9 @@
 // Networking, Capturing, Object Transfer
 // MAJOR CLASS: COMPUTER
 // MINOR CLASS: PALM SIZE PC/PDA
-#define BTA_DM_COD {0x1A, 0x01, 0x14}
+#define BTA_DM_COD {0x5A, 0x01, 0x1C}

 #define BTIF_HF_SERVICES (BTA_HSP_SERVICE_MASK)
 #define BTIF_HF_SERVICE_NAMES  { BTIF_HSAG_SERVICE_NAME }
-#define PAN_NAP_DISABLED TRUE

 #endif

修改device/fsl/sabresd_6dq/BoardConfig.mk

diff -Npur a/device/fsl/sabresd_6dq/BoardConfig.mk b/device/fsl/sabresd_6dq/BoardConfig.mk
--- a/device/fsl/sabresd_6dq/BoardConfig.mk 2016-05-06 07:44:52.000000000 +0800
+++ b/device/fsl/sabresd_6dq/BoardConfig.mk 2016-06-01 16:12:29.000000000 +0800
@@ -3,6 +3,7 @@
 #

 include device/fsl/imx6/soc/imx6dq.mk
+#include device/fsl/imx6/imx6.mk
 include device/fsl/sabresd_6dq/build_id.mk
 include device/fsl/imx6/BoardConfigCommon.mk
 include device/fsl-proprietary/gpu-viv/fsl-gpu.mk
@@ -16,76 +17,25 @@ PRODUCT_MODEL := SABRESD-MX6DQ

 # Wifi
 # BOARD_WLAN_VENDOR             := ATHEROS
-
-#BOARD_WIFI_VENDOR := realtek
-BOARD_WLAN_DEVICE            := SD8XXX
-# for atheros vendor
-# ifeq ($(BOARD_WLAN_VENDOR),ATHEROS)
-ifeq ($(BOARD_WLAN_DEVICE),ATHEROS)
-BOARD_WLAN_DEVICE           := ar6003
-BOARD_HAS_ATH_WLAN              := true
-WPA_SUPPLICANT_VERSION          := VER_0_8_ATHEROS
-WIFI_DRIVER_MODULE_PATH             := "/system/lib/modules/ath6kl_sdio.ko"
-WIFI_DRIVER_MODULE_NAME             := "ath6kl_sdio"
-WIFI_DRIVER_MODULE_ARG              := "suspend_mode=3 wow_mode=2 ar6k_clock=26000000 ath6kl_p2p=1"
-WIFI_DRIVER_P2P_MODULE_ARG          := "suspend_mode=3 wow_mode=2 ar6k_clock=26000000 ath6kl_p2p=1 debug_mask=0x2413"
-WIFI_SDIO_IF_DRIVER_MODULE_PATH     := "/system/lib/modules/cfg80211.ko"
-WIFI_SDIO_IF_DRIVER_MODULE_NAME     := "cfg80211"
-WIFI_SDIO_IF_DRIVER_MODULE_ARG      := ""
-WIFI_COMPAT_MODULE_PATH             := "/system/lib/modules/compat.ko"
-WIFI_COMPAT_MODULE_NAME             := "compat"
-WIFI_COMPAT_MODULE_ARG          := ""
-else ifeq ($(BOARD_WLAN_DEVICE), SD8XXX)
-#TARGET_KERNEL_MODULES        := \
-                                kernel_imx/drivers/net/wireless/sd8787/wlan_src/mlan.ko:system/lib/modules/mlan.ko \
-                                kernel_imx/drivers/net/wireless/sd8787/wlan_src/sd8xxx.ko:system/lib/modules/sd8xxx.ko \
-               kernel_imx/drivers/net/wireless/sd8787/mbtc_src/mbt8xxx.ko:system/lib/modules/mbt8xxx.ko
-BOARD_WPA_SUPPLICANT_DRIVER := NL80211
-WPA_SUPPLICANT_VERSION := VER_0_8_MARVELL
-BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_mrvl
-BOARD_ENABLE_MARVELL_WIFI := true
-BOARD_HAVE_BLUETOOTH := true
-BOARD_HAVE_BLUETOOTH_MRVL := true
-##BOARD_HAVE_BLUETOOTH_DUN := true
-##BOARD_ENABLE_MARVELL_BLUETOOTH := true
-#BOARD_ENABLE_MARVELL_EAP_SIM := true
-BOARD_HOSTAPD_DRIVER := NL80211
-BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_mrvl
-SD8787_CAL_ON_BOARD := true
-FM_NOT_USES_RECORD := true
-FM_USES_DIGITAL_MODE := false
-endif
-#for intel vendor
-# ifeq ($(BOARD_WLAN_VENDOR),INTEL)
-ifeq ($(BOARD_WLAN_DEVICE),INTEL)
-BOARD_HOSTAPD_PRIVATE_LIB       ?= private_lib_driver_cmd
-BOARD_WPA_SUPPLICANT_PRIVATE_LIB    ?= private_lib_driver_cmd
-WPA_SUPPLICANT_VERSION          := VER_0_8_X
-HOSTAPD_VERSION                 := VER_0_8_X
-BOARD_WPA_SUPPLICANT_PRIVATE_LIB         := private_lib_driver_cmd_intel
-WIFI_DRIVER_MODULE_PATH             := "/system/lib/modules/iwlagn.ko"
-WIFI_DRIVER_MODULE_NAME             := "iwlagn"
-WIFI_DRIVER_MODULE_PATH             ?= auto
-endif
+BOARD_HAVE_WIFI := true
+BOARD_WIFI_VENDOR := realtek

 ifeq ($(BOARD_WIFI_VENDOR), realtek)
+TARGET_KERNEL_MODULES  :=        \
+           device/fsl/sabresd_6dq/bluetooth/rtl8723b_fw:system/etc/firmware/rtl8723b_fw            \
+           device/fsl/sabresd_6dq/bluetooth/rtl8723bu_config:system/etc/firmware/rtl8723bu_config      \
+           kernel_imx/drivers/net/wireless/rtl8723bu/8723bu.ko:system/lib/modules/8723bu.ko        \
+           kernel_imx/drivers/bluetooth/rtk_btusb.ko:system/lib/modules/rtk_btusb.ko 
+
 WPA_SUPPLICANT_VERSION := VER_0_8_X
 BOARD_WPA_SUPPLICANT_DRIVER := NL80211
 CONFIG_DRIVER_WEXT :=y
 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:= "8723bs"
-WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/8723bs.ko"
+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 := ""
 WIFI_DRIVER_FW_PATH_STA := ""
@@ -99,8 +49,8 @@ WIFI_TEST_INTERFACE            := "sta"

 BOARD_MODEM_VENDOR := AMAZON

-BOARD_HAVE_HARDWARE_GPS := true
-USE_ATHR_GPS_HARDWARE := true
+BOARD_HAVE_HARDWARE_GPS := false
+USE_ATHR_GPS_HARDWARE := false
 USE_QEMU_GPS_HARDWARE := false

 #for accelerator sensor, need to define sensor type here
@@ -138,10 +88,9 @@ BOARD_KERNEL_CMDLINE +=  mtdparts=gpmi-n
 endif

 # atheros 3k BT
-ifeq ($(BOARD_HAVE_BLUETOOTH_MRVL),)
-BOARD_USE_AR3K_BLUETOOTH := true
-BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/fsl/sabresd_6dq/bluetooth
-endif
+BOARD_HAVE_BLUETOOTH := true
+BOARD_HAVE_BLUETOOTH_RTK := true
+BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR ?= device/fsl/sabresd_6dq/bluetooth

 USE_ION_ALLOCATOR := false
 USE_GPU_ALLOCATOR := true
@@ -152,6 +101,10 @@ IMX_CAMERA_HAL_V2 := true
 # define frame buffer count
 NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3

+PRODUCT_PROPERTY_OVERRIDES += \
+           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 \
+           wifi.interface=wlan0

 TARGET_BOOTLOADER_CONFIG := 6q:mx6q_sabresd_android_config 6dl:mx6dl_sabresd_android_config

修改device/fsl/sabresd_6dq/device.mk
diff -Npur a/device/fsl/sabresd_6dq/device.mk b/device/fsl/sabresd_6dq/device.mk
— a/device/fsl/sabresd_6dq/device.mk 1970-01-01 08:00:00.000000000 +0800
+++ b/device/fsl/sabresd_6dq/device.mk 2016-06-01 16:12:29.000000000 +0800
@@ -0,0 +1,5 @@
+…
+
+#Realtek add start
+$(call inherit-product, device/fsl/sabresd_6dq/realtek/bt/firmware/rtl8723b/device-rtl.mk)
+#realtek add end

修改device/fsl/sabresd_6dq/init.freescale.rc

diff -Npur a/device/fsl/sabresd_6dq/init.freescale.rc b/device/fsl/sabresd_6dq/init.freescale.rc
--- a/device/fsl/sabresd_6dq/init.freescale.rc  1970-01-01 08:00:00.000000000 +0800
+++ b/device/fsl/sabresd_6dq/init.freescale.rc  2016-06-01 16:12:29.000000000 +0800
@@ -0,0 +1,228 @@
+import init.${ro.hardware}.usb.rc
+
+on init
+    start watchdogd
+
+    # See storage config details at http://source.android.com/tech/storage/
+    mkdir /mnt/shell/emulated 0700 shell shell
+    mkdir /storage/emulated 0555 root root
+
+    export EXTERNAL_STORAGE /storage/emulated/legacy
+    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
+    export EMULATED_STORAGE_TARGET /storage/emulated
+
+    # Support legacy paths
+    symlink /storage/emulated/legacy /sdcard
+    symlink /storage/emulated/legacy /mnt/sdcard
+    symlink /storage/emulated/legacy /storage/sdcard0
+    symlink /mnt/shell/emulated/0 /storage/emulated/legacy
+
+on boot
+
+    # Set permission for IIM node
+    symlink /dev/mxs_viim /dev/mxc_mem
+
+    # Set GPS serial and reset GPIO pin
+    write /sys/class/gpio/export 60
+    write /sys/class/gpio/gpio60/direction "out"
+    write /sys/class/gpio/gpio60/value 1
+
+    # Enable Tethering in the Settings
+    setprop ro.tether.denied false
+
+    # 3D acceleration property
+    setprop debug.sf.showfps    0
+    setprop debug.sf.enable_hgl 1
+    setprop debug.egl.hw   1
+
+    setprop hwc.stretch.filter  1
+    setprop hwc.enable_dither   1
+
+    # fsl omx graphic manager media framework property
+    setprop media.omxgm.enable-player 1
+    setprop media.omxgm.enable-record 1
+    setprop media.omxgm.enable-scan 1
+    setprop rw.VIDEO_RENDER_NAME video_render.surface
+
+    #Define the config for dual camera
+    setprop camera.disable_zsl_mode 1
+    #For landscape mode, orient is 0
+    #For portrait mode, orient is 90
+    #the android before honycomb are all in portrait mode
+    #setprop back_camera_name ov5640_mipi
+    setprop back_camera_name ov5640_camera
+    setprop back_camera_orient 0
+    #setprop front_camera_name uvc,ov5642_camera,ov5640_camera
+    setprop front_camera_name uvc
+    setprop front_camera_orient 0
+
+    # Set OpenGLES version
+    setprop ro.opengles.version 131072
+
+    # Set rotation to 270 to cofigure as portrait mode
+    setprop ro.sf.hwrotation 0
+
+    # Set the density to 160dpi, default 128dpi is not good
+    setprop ro.sf.lcd_density 160
+    # Set extsd access permission
+    setprop persist.sampling_profiler 1
+# change for FSL specific service
+    chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+    chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+    chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
+    chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
+    chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+    chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+    chown root system /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
+    chmod 0440 /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
+    chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
+    chown root system /sys/devices/system/cpu/cpu0/online
+    chmod 0664 /sys/devices/system/cpu/cpu0/online
+    chown root system /sys/devices/system/cpu/cpu1/online
+    chmod 0664 /sys/devices/system/cpu/cpu1/online
+    chown root system /sys/devices/system/cpu/cpu2/online
+    chmod 0664 /sys/devices/system/cpu/cpu2/online
+    chown root system /sys/devices/system/cpu/cpu3/online
+    chmod 0664 /sys/devices/system/cpu/cpu3/online
+
+   mkdir /system/etc/wifi 0770 wifi wifi
+   chmod 0770 /system/etc/wifi
+   chmod 0660 /system/etc/wifi/wpa_supplicant.conf
+   chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
+   #wpa_supplicant control socket for android wifi.c (android private socket)
+   mkdir /data/misc/wifi 0770 wifi wifi
+   mkdir /data/misc/wifi/sockets 0770 wifi wifi
+   chmod 0770 /data/misc/wifi
+   chmod 0660 /data/misc/wifi/wpa_supplicant.conf
+   chown wifi wifi /data/misc/wifi
+   chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
+
+
+    chmod 0777 /dev/ttymxc0
+    chmod 0777 /dev/ttymxc1
+    chmod 0777 /dev/ttymxc2
+    chmod 0777 /dev/ttymxc3
+    chmod 0777 /dev/ttymxc4
+
+
+    # prepare for ril
+    setprop gsm.ril.delay 15
+    setprop ro.ril.wake_lock_timeout 300
+
+    # Default backlight device
+    setprop hw.backlight.dev "pwm-backlight.0"
+    # Chmod/chown FSL specific sys entry
+    chown system system /sys/class/backlight/pwm-backlight.0/brightness
+    chmod 0660 /sys/class/backlight/pwm-backlight.0/brightness
+
+    # Set light sensor sysfs path and light sensor threshold lux value
+    setprop ro.hardware.lightsensor "/sys/class/i2c-dev/i2c-2/device/2-0044/"
+    setprop ro.lightsensor.threshold  20
+
+    # No bluetooth hardware present
+    setprop hw.bluetooth 0
+    setprop wlan.interface wlan0
+    setprop wlan.driver.status "ok"
+
+    setprop hw.bluetooth 1
+    # bluetooth
+    # change back to bluetooth from system
+    chown bluetooth net_bt_stack /data/misc/Bluetooth
+    mkdir /data/misc/bluedroid 0770 bluetooth net_bt_stack
+
+    # Add for bluetooth
+    insmod /system/lib/modules/rtk_btusb.ko
+    chmod 0660 /dev/rtk_btusb
+    chown bluetooth net_bt_stack /dev/rtk_btusb
+
+    # 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"
+
+# mount the debugfs
+    mount debugfs none /sys/kernel/debug/
+   
+# Set watchdog timer to 30 seconds and pet it every 10 seconds to get a 20 second margin
+    service watchdogd /sbin/watchdogd 10 20
+    class core
+
+service p2p_supplicant /system/bin/wpa_supplicant \
+    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
+    -I/system/etc/wifi/p2p_supplicant_overlay.conf -N \
+    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+    -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \
+    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
+    class late_start
+    socket wpa_wlan0 dgram 660 wifi wifi
+    disabled
+    oneshot
+
+service rtw_suppl_con /system/bin/rtl_wpa_supplicant \
+    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
+    -I/system/etc/wifi/p2p_supplicant_overlay.conf -N \
+    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+    -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \
+    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
+    class late_start
+    socket wpa_wlan0 dgram 660 wifi wifi
+    disabled
+    oneshot
+
+service wpa_supplicant /system/bin/wpa_supplicant \
+    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+    -O/data/misc/wifi/sockets \
+    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
+    socket wpa_wlan0 dgram 660 wifi wifi
+    class late_start
+    disabled
+    oneshot
+
+service rtw_suppl /system/bin/wpa_supplicant -dd -iwlan0 -Dnl80211 \
+    -c/data/misc/wifi/wpa_supplicant.conf
+    socket wpa_wlan0 dgram 660 wifi wifi
+    class main
+    disabled
+    oneshot
+
+
+service dhcpcd_wlan0 /system/bin/dhcpcd -aABKL
+    class main
+    disabled
+    oneshot
+
+service iprenew_wlan0 /system/bin/dhcpcd -n
+    class main
+    disabled
+    oneshot
+
+# magd daemon
+service magd /system/bin/magd
+    class main
+    user system
+    group input
+    oneshot
+
+# Orion InG
+#service ing /system/bin/ingsvcd -c /system/etc/gps/Orion.ini
+#    socket athrkv9988    stream 666 system system
+#    socket athrshmsocket stream 666 system system
+#    socket athrsupl59991 stream 666 system system
+#    class late_start
+#    user root
+#    group gps
+#    oneshot
+
+
+
+
+
+
+
+on fs
+# mount ext4 partitions
+    mount_all /fstab.freescale

修改device/fsl/sabresd_6dq/init.rc

diff -Npur a/device/fsl/sabresd_6dq/init.rc b/device/fsl/sabresd_6dq/init.rc
--- a/device/fsl/sabresd_6dq/init.rc    2016-04-21 17:03:07.000000000 +0800
+++ b/device/fsl/sabresd_6dq/init.rc    2016-06-03 19:35:00.000000000 +0800
@@ -45,14 +45,16 @@ on boot
     setprop rw.VIDEO_RENDER_NAME video_render.surface

     #Define the config for dual camera
-    setprop camera.disable_zsl_mode 1
+    #setprop camera.disable_zsl_mode 1
     #For landscape mode, orient is 0
     #For portrait mode, orient is 90
     #the android before honycomb are all in portrait mode
-    setprop back_camera_name  uvc,ov5642_camera,ov5640_camera,ov5640_mipi
-    setprop back_camera_orient 0
-    setprop front_camera_name uvc,ov5642_camera,ov5640_camera
-    setprop front_camera_orient 0
+    #setprop back_camera_name ov5640_mipi
+    #setprop back_camera_name ov5640_camera
+    #setprop back_camera_orient 0
+    #setprop front_camera_name uvc,ov5642_camera,ov5640_camera
+    #setprop front_camera_name uvc
+    #setprop front_camera_orient 0

     # Set OpenGLES version
     setprop ro.opengles.version 131072
@@ -62,6 +64,8 @@ on boot

     # Set the density to 160dpi, default 128dpi is not good
     setprop ro.sf.lcd_density 160
+    # Set extsd access permission
+    setprop persist.sampling_profiler 1
 # change for FSL specific service
     chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
     chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
@@ -82,13 +86,14 @@ on boot
     chmod 0664 /sys/devices/system/cpu/cpu3/online


-
     chmod 0777 /dev/ttymxc0
     chmod 0777 /dev/ttymxc1
     chmod 0777 /dev/ttymxc2
     chmod 0777 /dev/ttymxc3
     chmod 0777 /dev/ttymxc4

     # prepare for ril
     setprop gsm.ril.delay 15
     setprop ro.ril.wake_lock_timeout 300
@@ -104,82 +109,89 @@ on boot
     setprop ro.lightsensor.threshold  20

     # No bluetooth hardware present
+    setprop hw.bluetooth 0
     setprop wlan.interface wlan0
+    setprop wlan.driver.status "ok"
+
+    setprop hw.bluetooth 1
+    # bluetooth
+    # change back to bluetooth from system
+    chown bluetooth net_bt_stack /data/misc/Bluetooth
+    mkdir /data/misc/bluedroid 0770 bluetooth net_bt_stack
+
+    # Add for bluetooth
+    insmod /system/lib/modules/rtk_btusb.ko
+    chmod 0660 /dev/rtk_btusb
+    chown bluetooth net_bt_stack /dev/rtk_btusb
+
+    # 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"

 # mount the debugfs
     mount debugfs none /sys/kernel/debug/

-  # chmod 0777 system/lib/modules/irtouchusb-dt.ko
-   #insmod system/lib/modules/irtouchusb-dt.ko
+# Set watchdog timer to 30 seconds and pet it every 10 seconds to get a 20 second margin
+    service watchdogd /sbin/watchdogd 10 20
+    class core

-service mwirelessd /system/bin/MarvellWirelessDaemon
-    class main
-
-# this service is for marvell wifi 8787
-service p2p_supplicant /system/bin/wpa_supplicant \
-    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -N \
-    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf
-    class late_start
-    socket wpa_wlan0 dgram 660 wifi wifi
-    disabled
-    oneshot
+# Orion InG
+#service ing /system/bin/ingsvcd -c /system/etc/gps/Orion.ini
+#    socket athrkv9988    stream 666 system system
+#    socket athrshmsocket stream 666 system system
+#    socket athrsupl59991 stream 666 system system
+#    class late_start
+#    user root
+#    group gps
+#    oneshot

-# this is for rtl8723 
-#service rtw_suppl_con /system/bin/wpa_supplicant \
-#  -ip2p0 -Dnl80211 -c /data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -N \
-#  -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf
-#  class main
-#  socket wpa_wlan0 dgram 660 wifi wifi
-#  disabled
-#  oneshot
-
-#service rtw_suppl /system/bin/wpa_supplicant -iwlan0 -Dnl80211
-#  -c/data/misc/wifi/wpa_supplicant.conf
-#  socket wpa_wlan0 dgram 660 wifi wifi
-#  class main
-#  disabled
-#  oneshot

-# magd daemon
-service magd /system/bin/magd
-    class main
-    user system
-    group input
-    oneshot
-
-# Orion InG
-service ing /system/bin/ingsvcd -c /system/etc/gps/Orion.ini
-    socket athrkv9988    stream 666 system system
-    socket athrshmsocket stream 666 system system
-    socket athrsupl59991 stream 666 system system
-    class late_start
-    user root
-    group gps
-    oneshot
+on fs
+# mount ext4 partitions
+    mount_all /fstab.freescale

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

+service rtw_suppl_con /system/bin/wpa_supplicant \
+   -ip2p0 -Dnl80211 -c /data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -N \
+   -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf
+   class main
+   socket wpa_wlan0 dgram 660 wifi wifi
+   disabled
+   oneshot
+   
+service rtw_suppl /system/bin/wpa_supplicant -iwlan0 -Dnl80211
+   -c/data/misc/wifi/wpa_supplicant.conf
+   socket wpa_wlan0 dgram 660 wifi wifi
+   class main
+   disabled
+   oneshot

-service iprenew_p2p /system/bin/dhcpcd -n
+service dhcpcd_wlan0 /system/bin/dhcpcd -aABKL
    class main
    disabled
    oneshot

-service init-setup /system/bin/insmod.sh
-    user root
-    group root
-    disabled
-    oneshot
+service dhcpcd_p2p /system/bin/dhcpcd -aABKL
+   class main
+   disabled
+   oneshot

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

-on property:sys.boot_completed=1
-    start  init-setup
+service iprenew_p2p /system/bin/dhcpcd -n
+   class main
+   disabled    
+   oneshot

-setprop sys.emulated.battery 1
+# magd daemon
+service magd /system/bin/magd
+    class main
+    user system
+    group input
+    oneshot

-on fs
-# mount ext4 partitions
-    mount_all /fstab.freescale

修改
device/fsl/sabresd_6dq/overlay/frameworks/base/core/res/res/values/config.xml

diff -Npur a/device/fsl/sabresd_6dq/overlay/frameworks/base/core/res/res/values/config.xml b/device/fsl/sabresd_6dq/overlay/frameworks/base/core/res/res/values/config.xml
--- a/device/fsl/sabresd_6dq/overlay/frameworks/base/core/res/res/values/config.xml 2015-02-06 23:22:50.000000000 +0800
+++ b/device/fsl/sabresd_6dq/overlay/frameworks/base/core/res/res/values/config.xml 2016-06-01 16:12:29.000000000 +0800
@@ -37,13 +37,9 @@
     
-    <integer-array translatable="false" name="config_tether_upstream_types">
-        <item>0item>
-        <item>1item>
-        <item>5item>
-        <item>7item>
-        <item>9item>
-    integer-array>
+    <string-array translatable="false" name="config_tether_bluetooth_regexs">
+      <item>"bt-pan"item>
+    string-array>

     
@@ -73,7 +69,6 @@
         <item>"mobile_fota,10,0,3,60000,true"item>
         <item>"mobile_ims,11,0,3,60000,true"item>
         <item>"mobile_cbs,12,0,3,60000,true"item>
-        <item>"wifi_p2p,13,1,0,-1,true"item>
         <item>"bluetooth,7,7,2,-1,true"item>
         <item>"ethernet,9,9,2,-1,true"item>
     string-array>

修改device/fsl/sabresd_6dq/realtek/bt/firmware/rtl8723a/device-rtl.mk

diff -Npur a/device/fsl/sabresd_6dq/realtek/bt/firmware/rtl8723a/device-rtl.mk b/device/fsl/sabresd_6dq/realtek/bt/firmware/rtl8723a/device-rtl.mk
--- a/device/fsl/sabresd_6dq/realtek/bt/firmware/rtl8723a/device-rtl.mk 1970-01-01 08:00:00.000000000 +0800
+++ b/device/fsl/sabresd_6dq/realtek/bt/firmware/rtl8723a/device-rtl.mk 2016-06-01 16:12:30.000000000 +0800
@@ -0,0 +1,4 @@
+RTK_BT_FIRMWARE_DIR := rtl8723a
+PRODUCT_COPY_FILES += \
+   $(LOCAL_PATH)/$(RTK_BT_FIRMWARE_DIR)_fw:system/etc/firmware/rtl8723a_fw \
+   $(LOCAL_PATH)/$(RTK_BT_FIRMWARE_DIR)_config:system/etc/firmware/rtl8723a_config

修改hardware/realtek/bt/libbt-vendor/Android.mk

diff -Npur a/hardware/realtek/bt/libbt-vendor/Android.mk b/hardware/realtek/bt/libbt-vendor/Android.mk
--- a/hardware/realtek/bt/libbt-vendor/Android.mk   1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/Android.mk   2013-07-08 12:28:42.000000000 +0800
@@ -0,0 +1,29 @@
+LOCAL_PATH := $(call my-dir)
+
+ifneq ($(BOARD_HAVE_BLUETOOTH_RTK),)
+
+include $(CLEAR_VARS)
+
+BDROID_DIR := $(TOP_DIR)external/bluetooth/bluedroid
+
+LOCAL_SRC_FILES := \
+        src/bt_vendor_rtk.c
+
+LOCAL_C_INCLUDES += \
+        $(LOCAL_PATH)/include \
+        $(BDROID_DIR)/hci/include
+
+LOCAL_SHARED_LIBRARIES := \
+        libcutils
+
+LOCAL_MODULE := libbt-vendor
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_OWNER := hci
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
+
+include $(LOCAL_PATH)/vnd_buildcfg.mk
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # BOARD_HAVE_BLUETOOTH_RTK

修改hardware/realtek/bt/libbt-vendor/include/bt_vendor_rtk.h

diff -Npur a/hardware/realtek/bt/libbt-vendor/include/bt_vendor_rtk.h b/hardware/realtek/bt/libbt-vendor/include/bt_vendor_rtk.h
--- a/hardware/realtek/bt/libbt-vendor/include/bt_vendor_rtk.h  1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/include/bt_vendor_rtk.h  2016-05-29 15:14:55.000000000 +0800
@@ -0,0 +1,64 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2009-2012 Broadcom Corporation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ *  Filename:      bt_vendor_rtk.h
+ *
+ *  Description:   A wrapper header file of bt_vendor_lib.h
+ *
+ *                 Contains definitions specific for interfacing with Broadcom
+ *                 Bluetooth chipsets
+ *
+ ******************************************************************************/
+
+
+#ifndef BT_VENDOR_RTK_H
+#define BT_VENDOR_RTK_H
+
+#include "bt_vendor_lib.h"
+#include "vnd_buildcfg.h"
+
+/******************************************************************************
+**  Constants & Macros
+******************************************************************************/
+
+#ifndef FALSE
+#define FALSE  0
+#endif
+
+#ifndef TRUE
+#define TRUE   (!FALSE)
+#endif
+
+/* Device port name where Bluetooth controller attached */
+#ifndef BLUETOOTH_UART_DEVICE_PORT
+#define BLUETOOTH_UART_DEVICE_PORT      "/dev/ttyO1"    /* maguro */
+#endif
+
+/******************************************************************************
+**  Extern variables and functions
+******************************************************************************/
+void userial_vendor_init(void);
+int userial_vendor_open(void);
+void userial_vendor_close(void);
+
+extern bt_vendor_callbacks_t *bt_vendor_cbacks;
+
+#endif /* BT_VENDOR_RTK_H */
+

修改hardware/realtek/bt/libbt-vendor/include/vnd_dalmore.txt、hardware/realtek/bt/libbt-vendor/include/vnd_freescale.txt、hardware/realtek/bt/libbt-vendor/include/vnd_generic.txt、hardware/realtek/bt/libbt-vendor/include/vnd_generic_x86.txt


diff -Npur a/hardware/realtek/bt/libbt-vendor/include/vnd_dalmore.txt b/hardware/realtek/bt/libbt-vendor/include/vnd_dalmore.txt
--- a/hardware/realtek/bt/libbt-vendor/include/vnd_dalmore.txt  1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/include/vnd_dalmore.txt  2016-05-28 16:51:45.000000000 +0800
@@ -0,0 +1,2 @@
+BLUETOOTH_UART_DEVICE_PORT = "/dev/rtk_btusb"
+BTVND_DBG = FALSE
diff -Npur a/hardware/realtek/bt/libbt-vendor/include/vnd_freescale.txt b/hardware/realtek/bt/libbt-vendor/include/vnd_freescale.txt
--- a/hardware/realtek/bt/libbt-vendor/include/vnd_freescale.txt    1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/include/vnd_freescale.txt    2016-05-28 16:52:14.000000000 +0800
@@ -0,0 +1,2 @@
+BLUETOOTH_UART_DEVICE_PORT = "/dev/rtk_btusb"
+BTVND_DBG = FALSE
diff -Npur a/hardware/realtek/bt/libbt-vendor/include/vnd_generic.txt b/hardware/realtek/bt/libbt-vendor/include/vnd_generic.txt
--- a/hardware/realtek/bt/libbt-vendor/include/vnd_generic.txt  1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/include/vnd_generic.txt  2016-05-29 15:12:45.000000000 +0800
@@ -0,0 +1,2 @@
+BLUETOOTH_UART_DEVICE_PORT = "/dev/rtk_btusb"
+BTVND_DBG = FALSE
diff -Npur a/hardware/realtek/bt/libbt-vendor/include/vnd_generic_x86.txt b/hardware/realtek/bt/libbt-vendor/include/vnd_generic_x86.txt
--- a/hardware/realtek/bt/libbt-vendor/include/vnd_generic_x86.txt  1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/include/vnd_generic_x86.txt  2013-07-08 12:28:42.000000000 +0800
@@ -0,0 +1,8 @@
+BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
+FW_PATCHFILE_LOCATION = "/vendor/firmware/"
+LPM_IDLE_TIMEOUT_MULTIPLE = 5
+SCO_USE_I2S_INTERFACE = TRUE
+BTVND_DBG = FALSE
+BTHW_DBG = TRUE
+VNDUSERIAL_DBG = FALSE
+UPIO_DBG = FALSE

修改hardware/realtek/bt/libbt-vendor/src/bt_vendor_rtk.c


diff -Npur a/hardware/realtek/bt/libbt-vendor/src/bt_vendor_rtk.c b/hardware/realtek/bt/libbt-vendor/src/bt_vendor_rtk.c
--- a/hardware/realtek/bt/libbt-vendor/src/bt_vendor_rtk.c  1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/src/bt_vendor_rtk.c  2013-07-08 12:28:42.000000000 +0800
@@ -0,0 +1,240 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2009-2012 Broadcom Corporation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ *  Filename:      bt_vendor_rtk.c
+ *
+ *  Description:   Broadcom vendor specific library implementation
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_vendor"
+
+#include <fcntl.h>
+#include <errno.h>
+#include <utils/Log.h>
+#include "bt_vendor_rtk.h"
+
+#ifndef BTVND_DBG
+#define BTVND_DBG FALSE
+#endif
+
+#if (BTVND_DBG == TRUE)
+#define BTVNDDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
+#else
+#define BTVNDDBG(param, ...) {}
+#endif
+
+/******************************************************************************
+**  Local type definitions
+******************************************************************************/
+#define VND_PORT_NAME_MAXLEN    256
+/* vendor serial control block */
+typedef struct
+{
+    int fd;                     /* fd to Bluetooth device */
+    uint16_t dev_id;
+    char port_name[VND_PORT_NAME_MAXLEN];
+} vnd_userial_cb_t;
+
+/******************************************************************************
+**  Variables
+******************************************************************************/
+
+bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
+uint8_t vnd_local_bd_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static vnd_userial_cb_t vnd_userial;
+
+/*****************************************************************************
+**
+**   BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
+**
+*****************************************************************************/
+
+static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr)
+{
+    ALOGI("init");
+
+    if (p_cb == NULL)
+    {
+        ALOGE("init failed with no user callbacks!");
+        return -1;
+    }
+
+    userial_vendor_init();
+
+    /* store reference to user callbacks */
+    bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
+
+    /* This is handed over from the stack */
+    memcpy(vnd_local_bd_addr, local_bdaddr, 6);
+
+    return 0;
+}
+
+
+/** Requested operations */
+static int op(bt_vendor_opcode_t opcode, void *param)
+{
+    int retval = 0;
+
+    BTVNDDBG("op for %d", opcode);
+
+    switch(opcode)
+    {
+        case BT_VND_OP_POWER_CTRL:
+            {
+                return 0;
+            }
+            break;
+
+        case BT_VND_OP_FW_CFG:
+            {
+               bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
+            }
+            break;
+
+        case BT_VND_OP_SCO_CFG:
+            {
+                retval = -1;
+            }
+            break;
+
+        case BT_VND_OP_USERIAL_OPEN:
+            {
+                int (*fd_array)[] = (int (*)[]) param;
+                int fd, idx;
+                fd = userial_vendor_open();
+                if (fd != -1)
+                {
+                    for (idx=0; idx < CH_MAX; idx++)
+                        (*fd_array)[idx] = fd;
+
+                    retval = 1;
+                }
+                /* retval contains numbers of open fd of HCI channels */
+            }
+            break;
+
+        case BT_VND_OP_USERIAL_CLOSE:
+            {
+                userial_vendor_close();
+            }
+            break;
+
+        case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
+            {
+                uint32_t *timeout_ms = (uint32_t *) param;
+                *timeout_ms = 250;
+            }
+            break;
+
+        case BT_VND_OP_LPM_SET_MODE:
+            {
+               if (bt_vendor_cbacks)
+                   bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_SUCCESS);
+            }
+            break;
+
+        case BT_VND_OP_LPM_WAKE_SET_STATE:
+            break;
+    }
+
+    return retval;
+}
+
+/*******************************************************************************
+**
+** Function        userial_vendor_init
+**
+** Description     Initialize userial vendor-specific control block
+**
+** Returns         None
+**
+*******************************************************************************/
+void userial_vendor_init(void)
+{
+    vnd_userial.fd = -1;
+    vnd_userial.dev_id = 0;
+    snprintf(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, "%s", \
+            BLUETOOTH_UART_DEVICE_PORT);
+}
+
+/*******************************************************************************
+**
+** Function        userial_vendor_open
+**
+** Description     Open the serial port with the given configuration
+**
+** Returns         device fd
+**
+*******************************************************************************/
+int userial_vendor_open(void)
+{
+   ALOGI("userial vendor open: opening %s", vnd_userial.port_name);
+
+   if ((vnd_userial.fd = open(vnd_userial.port_name, O_RDWR)) == -1)
+   {
+       ALOGE("userial vendor open: unable to open %s: %s", vnd_userial.port_name, strerror(errno));
+       return -1;
+   }
+
+   ALOGI("device fd = %d open", vnd_userial.fd);
+
+   return vnd_userial.fd;
+}
+
+/*******************************************************************************
+**
+** Function        userial_vendor_close
+**
+** Description     Conduct vendor-specific close work
+**
+** Returns         None
+**
+*******************************************************************************/
+void userial_vendor_close(void)
+{
+    int result;
+
+    if (vnd_userial.fd == -1)
+        return;
+
+    ALOGI("device fd = %d close", vnd_userial.fd);
+
+    if ((result = close(vnd_userial.fd)) < 0)
+        ALOGE( "close(fd:%d) FAILED result:%d", vnd_userial.fd, result);
+
+    vnd_userial.fd = -1;
+}
+
+/** Closes the interface */
+static void cleanup( void )
+{
+    BTVNDDBG("cleanup");
+    bt_vendor_cbacks = NULL;
+}
+
+// Entry point of DLib
+const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
+    sizeof(bt_vendor_interface_t),
+    init,
+    op,
+    cleanup
+};

修改hardware/realtek/bt/libbt-vendor/vnd_buildcfg.mk


diff -Npur a/hardware/realtek/bt/libbt-vendor/vnd_buildcfg.mk b/hardware/realtek/bt/libbt-vendor/vnd_buildcfg.mk
--- a/hardware/realtek/bt/libbt-vendor/vnd_buildcfg.mk  1970-01-01 08:00:00.000000000 +0800
+++ b/hardware/realtek/bt/libbt-vendor/vnd_buildcfg.mk  2016-05-31 17:28:46.000000000 +0800
@@ -0,0 +1,16 @@
+intermediates := $(local-intermediates-dir)
+
+SRC := $(call my-dir)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE))))
+ifeq (,$(wildcard $(SRC)))
+# configuration file does not exist. Use default one
+SRC := $(call my-dir)/include/vnd_freescale.txt
+endif
+GEN := $(intermediates)/vnd_buildcfg.h
+TOOL := $(TOP_DIR)external/bluetooth/bluedroid/tools/gen-buildcfg.sh
+
+$(GEN): PRIVATE_PATH := $(call my-dir)
+$(GEN): PRIVATE_CUSTOM_TOOL = $(TOOL) $< $@
+$(GEN): $(SRC)  $(TOOL)
+   $(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES += $(GEN)

修改hardware/realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c

diff -Npur a/hardware/realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c b/hardware/realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c
--- a/hardware/realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c  2016-04-20 01:10:31.000000000 +0800
+++ b/hardware/realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c  2013-02-08 14:43:51.000000000 +0800
@@ -681,7 +681,7 @@ int wifi_start_supplicant(int p2p_suppor
         snprintf(supplicant_prop_name, PROPERTY_KEY_MAX, SUPP_PROP_NAME, supplicant_name);
     }

-    wifi_stop_supplicant(p2p_supported);
+    wifi_stop_supplicant();
     wifi_close_supplicant_connection(NULL);
     wifi_close_supplicant_connection("sec");

@@ -767,7 +767,7 @@ int wifi_start_supplicant(int p2p_suppor
     return -1;
 }

-int wifi_stop_supplicant(int p2p_supported)
+int wifi_stop_supplicant()
 {
     char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
     int count = 50; /* wait at most 5 seconds for completion */

生成环境

root@zpzyf:~/b# cat env.sh 
#!/bin/bash

ROOT_DIR=$PWD
export ARCH=arm
export CROSS_COMPILE=${ROOT_DIR}/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_30
export JRE_HOME=$JAVA_HOME/jre  
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH    
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH 
KERNEL_DIR=${ROOT_DIR}/kernel_imx
UBOOT_DIR=${ROOT_DIR}/bootable/bootloader/uboot-imx

root@zpzyf:~/b# source env.sh 

编译
source build/envsetup.sh
lunch sabresd_6dq-user

make -j8

通过以上修改,可以正常访问蓝牙和WIFI。

你可能感兴趣的:(LINUX,Android,IMX6)