ap6212移植

1.ap6212

功能:wifi stationsoftapwifi directbt

接口类型:sdiouart

调试方案:octopus-f1,下面以A83T平台android4.4为例说明ap6212的移植过程

2、软硬件设计部份差异说明

(1) ap6212采用的是26M晶振,A框去掉,即不需要反相器;

(2) ap6212硬件上第29悬空,与ap6210不同

(3)ap6212必须采用bcmhd新驱动1.201.34.x版本,如附件;

(4)ap6212 firmware部分如附件请覆盖至\hardware\broadcom\wlan\bcmdhd\firmware

3内核配置

3.1 .config

.config中需要配置如下选项,将wifi driver编译进内核

CONFIG_BCMDHD = y

CONFIG_BCMDHD_OOB = y

同时把ap6212驱动代码加到/android/hardware/broadcom/wlan/bcmdhd/firmware路径下。

3.2 BoardConfig.mk

BoardConfig.mk文件决定android要加载哪一款wifi模组、是否开启蓝牙和使用哪一款蓝牙模组,要配置成使用ap6212模组并启用wifi和蓝牙功能需要把BoardConfig.mk文件的相关代码修改成如下。

# wifi and bt configuration

# 1. Wifi Configuration

#BOARD_WIFI_VENDOR := realtek

BOARD_WIFI_VENDOR := broadcom

# 1.1 broadcom wifi support

ifeq ($(BOARD_WIFI_VENDOR), broadcom)

    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

    WIFI_DRIVER_FW_PATH_PARAM   := "/sys/module/bcmdhd/parameters/firmware_path"

    BOARD_USR_WIFI := ap6212

    include hardware/broadcom/wlan/bcmdhd/firmware/$(BOARD_USR_WIFI)/device-bcm.mk

endif

# 2. Bluetooth Configuration

# make sure BOARD_HAVE_BLUETOOTH is true for every bt vendor

BOARD_HAVE_BLUETOOTH := true

BOARD_HAVE_BLUETOOTH_BCM := true

#BOARD_HAVE_BLUETOOTH_RTK := true

#BLUETOOTH_HCI_USE_RTK_H5 := true

BOARD_HAVE_BLUETOOTH_NAME := ap6212

BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/softwinner/tulip-t1/bluetooth/

说明:

1、“#”符号起注释作用;

2、“BOARD_USR_WIFI := AP6210”宏指明wifi选用ap6212;

3、“BOARD_HAVE_BLUETOOTH := true”宏指明使用蓝牙;

4、“BOARD_HAVE_BLUETOOTH_BCM := true”宏指定蓝牙厂商为Broadcom

5、“BOARD_HAVE_BLUETOOTH_NAME := ap6212”宏指明蓝牙模组名字;

6、“BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR :=  device/softwinner/tulip-t1/bluetooth/”宏指明配置文件bdroid_buildcfg.h路径;

注意:

1、需注释掉#BOARD_HAVE_BLUETOOTH_RTK := true

2、若不需要蓝牙功能只需要把相关宏注释掉就可以。

3OARD_USR_WIFI的大小写根据你在3.1中命名规则来写。

3.3 init.sun8i.rc

这部分只要注意两点:

注意:

1若init.sun50iw1p1.rc文件无修改后代码,可手动添加;

2、需注释掉realtek wifibluetooth相关内容。

3.3 octopus-f1

octopus-f1.mk文件会在编译时拷贝指定文件到特定目录下,使用ap6212需要确认如下修改:

DEVICE_PACKAGE_OVERLAYS := device/softwinner/octopus-perf/overlay \

                           $(DEVICE_PACKAGE_OVERLAYS)

PRODUCT_PACKAGES += gatord

PRODUCT_PACKAGES += \

    ESFileExplorer \

    VideoPlayer \

    Bluetooth

PRODUCT_PACKAGES += \

    gps.exdroid \

PRODUCT_COPY_FILES += \

        device/softwinner/octopus-perf/configs/gps.conf:system/etc/gps.conf

PRODUCT_COPY_FILES += \

    device/softwinner/octopus-perf/kernel:kernel \

    device/softwinner/octopus-perf/fstab.sun8i:root/fstab.sun8i \

    device/softwinner/octopus-perf/init.sun8i.rc:root/init.sun8i.rc \

    device/softwinner/octopus-perf/init.recovery.sun8i.rc:root/init.recovery.sun8i.rc \

    device/softwinner/octopus-perf/ueventd.sun8i.rc:root/ueventd.sun8i.rc \

    device/softwinner/octopus-perf/recovery.fstab:recovery.fstab \

    device/softwinner/octopus-perf/modules/modules/nand.ko:root/nand.ko \

    device/softwinner/octopus-perf/modules/modules/sunxi_tr.ko:root/sunxi_tr.ko \

    device/softwinner/octopus-perf/modules/modules/disp.ko:root/disp.ko \

    device/softwinner/octopus-perf/modules/modules/sw-device.ko:obj/sw-device.ko \

PRODUCT_COPY_FILES += \

    device/softwinner/octopus-perf/configs/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml

PRODUCT_COPY_FILES += \

    device/softwinner/octopus-perf/configs/camera.cfg:system/etc/camera.cfg \

    device/softwinner/octopus-perf/configs/cfg-Gallery2.xml:system/etc/cfg-Gallery2.xml \

    device/softwinner/octopus-perf/configs/gsensor.cfg:system/usr/gsensor.cfg \

    device/softwinner/octopus-perf/configs/media_profiles.xml:system/etc/media_profiles.xml \

    device/softwinner/octopus-perf/configs/sunxi-keyboard.kl:system/usr/keylayout/sunxi-keyboard.kl \

        device/softwinner/octopus-perf/configs/sunxi-ir.kl:system/usr/keylayout/sunxi-ir.kl \

    device/softwinner/octopus-perf/configs/tp.idc:system/usr/idc/tp.idc

PRODUCT_COPY_FILES += \

    frameworks/native/data/etc/android.hardware.touchscreen.multitouch.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.xml \

    frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \

    frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml

PRODUCT_COPY_FILES += \

    device/softwinner/octopus-perf/bluetooth/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf

PRODUCT_COPY_FILES += \

    device/softwinner/octopus-perf/bluetooth/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf

PRODUCT_COPY_FILES += \

    frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml   \

    frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml

# Low mem(memory <= 512M) device should not copy android.software.managed_users.xml

PRODUCT_COPY_FILES += \

    frameworks/native/data/etc/android.software.managed_users.xml:system/etc/permissions/android.software.managed_users.xml

PRODUCT_COPY_FILES += \

        device/softwinner/octopus-perf/media/bootanimation.zip:system/media/bootanimation.zip \

#camera config for camera detector

PRODUCT_COPY_FILES += \

        device/softwinner/octopus-perf/hawkview/sensor_list_cfg.ini:system/etc/hawkview/sensor_list_cfg.ini

# Radio Packages and Configuration Flie

$(call inherit-product, device/softwinner/common/rild/radio_common.mk)

#$(call inherit-product, device/softwinner/common/ril_modem/huawei/mu509/huawei_mu509.mk)

#$(call inherit-product, device/softwinner/common/ril_modem/Oviphone/em55/oviphone_em55.mk)

#sensor

PRODUCT_COPY_FILES += \

        device/softwinner/octopus-perf/sensor.sh:system/bin/sensor.sh

注意:

1android.hardware.wifi.xml拷贝到指定目录,以使设置界面显示wifi

2android.hardware.wifi.direct.xml是在wifi设备中显示wifi direct选项

3android.hardware.bluetooth.xml是在setting界面中显示蓝牙

4、“PRODUCT_PACKAGES +=  Bluetooth”指定去编译Bluetooth.apk

3.4config.xml

config.xml文件路径:\android5.1\device\softwinner\tulip-t1\overlay\frameworks\base\core\res\res

\values\config.xml

要打开蓝牙功能,需要在config.xml中把蓝牙的bt-pan网口打开,修改的部分代码如下。 

<!-- List of regexpressions describing the interface (if any) that represent tetherable

      Wifi interfaces.  If the device doesn't want to support tethering over Wifi this

         should be empty.  An example would be "softap.*" -->

<!--  default: disable Softap feature -->

<string-array translatable="false" name="config_tether_wifi_regexs">

<item>"wlan0"</item>

</string-array>

-->

<!-- List of regexpressions describing the interface (if any) that represent tetherable

         bluetooth interfaces.  If the device doesn't want to support tethering over bluetooth this

         should be empty. -->

    <!--  default: disable Bluetooth PAN feature -->

    <string-array translatable="false" name="config_tether_bluetooth_regexs">

        <item>"bt-pan"</item>

</string-array>

<!-- List of regexpressions describing the interface (if any) that represent tetherable

注:若相应平台该目录下没config.xml文件,可到其他相应平台对应目录下拷贝一份。

3.5 vnd_<product>.txt

蓝牙配置文件 设置波特率,uart设备文件和firmware路径(初始值),调试信息配置

文件路径: device\softwinner\tulip-t1\bluetooth

创建vnd_$( product).txt文件,如vnd_tulip-t1.txt

#Set baudrate to 1500000

UART_TARGET_BAUD_RATE=1500000

BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyS1"

FW_PATCHFILE_LOCATION = "/system/vendor/modules/"

LPM_IDLE_TIMEOUT_MULTIPLE = 5

#LPM_SLEEP_MODE = FALSE

BT_WAKE_VIA_PROC = TRUE

BTVND_DBG = TRUE

BTHW_DBG = TRUE

VNDUSERIAL_DBG = TRUE

UPIO_DBG = TRUE

3.6 bt_vendor.conf

文件路径:device\softwinner\tulip-t1\bluetooth

# UART device port where Bluetooth controller is attached

UartPort = /dev/ttyS1

# Firmware patch file location

FwPatchFilePath = /system/vendor/modules/

#Firmware name

FwPatchFileName = bcm20710a1.hcd

3.7 bdroid_buildcfg.h

android5.1\device\softwinner\tulip-t1\bluetooth\bdroid_buildcfg.h主要配置打开蓝牙时显示的本机名字。

#ifndef _BDROID_BUILDCFG_H

#define _BDROID_BUILDCFG_H

#define BTM_DEF_LOCAL_NAME "tulip-t1"

#define BTA_DM_COD {0x1A, 0x01, 0x14}

#define BTIF_HF_SERVICES (BTA_HSP_SERVICE_MASK)

#define BTIF_HF_SERVICE_NAMES  { BTIF_HSAG_SERVICE_NAME }

#endif

3.8 引脚配置

  ap6212引脚在lichee\tools\pack\chips\sun8iw6p1\configs\ f1\sys_config.fex中定义,需根据具体的原理图做相应的配置,需要配置的选项有:

;wifi/bt/fm/gps/nfc modules configuration

;module_num:   

;  1- ap6181(wifi) 2- ap6210(wifi+bt) 3- rtl8188eu(wifi)

;  4- rtl8723au(wifi+bt)  5- rtl8723bs(wifi+bt) 6- esp8089(wifi)

;  7- ap6476(wifi+bt+fm+gps)

;  8- ap6330(wifi+bt+fm) gb9663(wifi+bt+fm) ap6212(wifi+bt+fm)

;module_power1: ""- bat, "axp_dldo1"- axp dldo1

;module_power1_vol: power1 voltage, mv; not used for module_power1 is ""

;module_power2: ""- bat, "axp_dldo2"- axp dldo2

;module_power2_vol: power2 voltage, mv; not used for module_power2 is ""

;module_power3: ""- bat, "axp_dldo2"- axp dldo2

;module_power3_vol: power3 voltage, mv; not used for module_power3 is ""

;power_switch:  module power switch io when bat supply

;chip_en:       enable chip io

;lpo_use_apclk: ""- not use, "losc_out"- a23/33, "ac10032k1""ac10032k2""ac10032k3"- a80/a83 

;--------------------------------------------------------------------------------

[rf_para]

module_num          = 2

module_power1       = "vcc-wifi-io"

module_power1_vol   = 3300000

module_power2       = ""

module_power2_vol   = 

module_power3       = ""

module_power3_vol   = 

power_switch        =

chip_en             = 

lpo_use_apclk       = "ac10032k2"

说明:

1、“;”符号起注释作用

2、“module_num” 宏表示选用哪一款wifi模组;

3、“module_power1”宏表示给模组供电的是axp的哪路ldo,一般选vcc-wifi-io(参见[pmu1_regu]);

4、“module_power1_vol”宏设置ldo的供电电压,ap6212供电电压为3.3V

5、“lpo_use_apclk”选择32k时钟源,根据原理图配置,一般选ac10032k2。

Wifi部分

;wifi configuration

;wifi_used:      0-not use, 1- use

;wifi_sdc_id:    0- SDC0, 1- SDC1, 2- SDC2, 3- SDC3

;wifi_usbc_id:   0- USB0, 1- USB1, 2- USB2

;wifi_usbc_type: 1- EHCI(speed 2.0), 2- OHCI(speed 1.0)

;wl_reg_on:      wifi function enable io

;wl_host_wake:   wifi device wake-up host

;wl_host_wake_invert: whether wl_host_wake use inverter between ap and module

;                     0: not used, 1: used   

;--------------------------------------------------------------------------------

[wifi_para]

wifi_used             = 1

wifi_sdc_id           = 1

wifi_usbc_id          = 1

wifi_usbc_type        = 1

wl_reg_on             = port:PL02<1><default><default><0>

wl_host_wake          = port:PL03<4><default><default><0>

wl_host_wake_invert   = 0

说明:

1、“;”符号起注释作用

2、“wifi_used”宏赋值为1表示使用wifi,为0表示不使用;

3、“wifi_sdc_id”宏表示SDIO接口wifi使用哪个MMC 控制器 ;

4、“wl_reg_on”宏表示wifi使能脚,打开wifi的过程,会拉高,根据原理图配置;

5、“wl_host_wake”宏表示wifi唤醒主控功能(WL-WAKE-AP),根据实际原理图配置。

蓝牙部份

;bluetooth configuration

;bt_used:       0- no used, 1- used

;bt_uard_id: 0- uart0, 1- uart1, 2- uart2

;bt_rst_n:      bt function enable io

;bt_wake:       host wake-up bluetooth device

;bt_wak_host:   bt device wake-up host 

;bt_host_wake_invert: whether bt_host_wake use inverter between ap and module

;                     0: not used, 1: used

;--------------------------------------------------------------------------------

[bt_para]

bt_used               = 1

bt_uart_id            = 1  

bt_rst_n              = port:PL04<1><default><default><0>

bt_wake               = port:PH10<1><default><default><0>

bt_host_wake          = port:PL05<4><default><default><0>

bt_host_wake_invert   = 0

说明:

1、“bt_used”宏赋值为1表示使用蓝牙,为0表示不使用;

2、“bt_uart_id”宏表示蓝牙所使用的是哪个uart

3、“bt_rst_n”宏表示蓝牙使能脚,蓝牙打开时会拉高,根据实际原理图配置;

4、“bt_wake”宏表示主控唤醒蓝牙(AP-WAKE-BT,根据实际原理图配置;

5、“bt_host_wake”宏表示蓝牙唤醒主控(BT-WAKE-AP,根据实际原理图配置。

4. 常见问题

硬件checklist

1. 26M晶振电路不需要接反相器,XTAL_IN/XTAL_OUT直接接模块Pin 10 /Pin 11;

2. 32K时钟波形正常输出;

3. Pin 22 VDDIO 电压(3.3V)

4. Pin 9 VBAT接电池有电压;

5. Pin 29 VDD_TCXO需要悬空;

软件checklist

1. Wifi和蓝牙都打不开?
请确认确认/system/vendor/modules/是否有以下文件,名字是否正确?
bcmhd.ko
fw_bcm43438a0.bin
fw_bcm43438a0_apsta.bin
fw_bcm43438a0_p2p.bin
nvram.txt
如果没有这些文件,说明编译的时候没有编到,请检查是否BoardConfig.mk大小写以及hardware\broadcom\wlan\bcmdhd\firmware\firmware-bcm.mk是否有加ap6212

2. 蓝牙打不开?
先确认4.1.5有加,再确认4.1.7波特率是否设置正确,另外改了Boardconfig.mk需要make clean

3. 蓝牙打开后搜不到设备?
先确认是否加天线,再确认确认4.1.5的FwPatchFileName是否正确;

其他:

1. 搜不到5G 信号? 搜不到某些蓝牙设备?某些路由器连接不上?
晶振存在频偏,请尝试从小到大更换26M晶振起振电路上的两个谐振电容。

你可能感兴趣的:(ap6212移植)