Android 4.4,Linux 3.10
lichee/tools/pack/chips/sun8iw11p1/configs/magton-perf/sys_config.fex
中
;--------------------------------------------------------------------------------
;wlan configuration
;wlan_used: 0-not use, 1- use
;wlan_busnum: sdio/usb index
;clocks: external low power clock input (32.768KHz)
;wlan_power: input supply voltage
;wlan_io_regulator: wlan/sdio I/O voltage
;wlan_regon: power up/down internal regulators used by wifi section
;wlan_hostwake: wlan to wake-up host
;wlan_clk_gpio: wlan low power clock output pin
;--------------------------------------------------------------------------------
[wlan]
wlan_used = 1
compatible = "allwinner,sunxi-wlan"
clocks = "outa"
wlan_busnum = 1
wlan_power = "vcc-wifi"
wlan_io_regulator = "vcc-io-wifi"
wlan_regon = port:PH08<1><1><1><0>
wlan_hostwake = port:PH09<0><default><default><default>
;wlan_clk_gpio = port:PI12<4><default><default><0>
wlan_clk_gpio =
;--------------------------------------------------------------------------------
;bluetooth configuration
;bt_used: 0- no used, 1- used
;clocks: external low power clock input (32.768KHz)
;bt_power: input supply voltage
;bt_io_regulator: bluetooth I/O voltage
;bt_rst_n: power up/down internal regulators used by BT section
;--------------------------------------------------------------------------------
[bt]
bt_used = 1
bt_uart_id = 3
bt_uart_baud = 1500000
compatible = "allwinner,sunxi-bt"
clocks = "outa"
pinctrl-names = "default"
;;clock_io = port:PI12<4><0><0><default>
bt_power = "vcc-wifi-2"
bt_io_regulator = "vcc-io-wifi"
bt_rst_n = port:PG10<1><1><1><0>
;--------------------------------------------------------------------------------
;bluetooth lpm configuration
;btlpm_used: 0- no used, 1- used
;uart_index: 0- uart0, 1- uart1, 2- uart2
;bt_wake: host wake-up bluetooth device
;bt_hostwake: bt device wake-up host
;--------------------------------------------------------------------------------
[btlpm]
btlpm_used = 1
compatible = "allwinner,sunxi-btlpm"
uart_index = 3
bt_wake = port:PG11<1><1><1><1>
bt_hostwake = port:PH10<0><0><0><1>
内核配置中
CONFIG_RTL8723BS=m
android/hardware/broadcom/wlan/bcmdhd/Android.mk
中注释
#include $(call all-subdir-makefiles)
android/device/softwinner/magton-perf/magton_perf.mk
中注释broadcom WiFi 编译,增加realtek WiFi编译
$(call inherit-product-if-exists, device/softwinner/common/hardware/realtek/Android.mk)
# ap6181/6210/6330 sdio wifi fw and nvram
#$(call inherit-product-if-exists, hardware/broadcom/wlan/firmware/ap6181/device-bcm.mk)
#$(call inherit-product-if-exists, hardware/broadcom/wlan/bcmdhd/firmware/ap6212/device-bcm.mk)
#$(call inherit-product-if-exists, hardware/broadcom/wlan/firmware/ap6330/device-bcm.mk)
android/device/softwinner/magton-perf/init.rc
中修改 蓝牙、WiFi 的服务
# bluetooth
chmod 0660 /dev/ttyS3
chown bluetooth net_bt_stack /dev/ttyS3
mkdir /data/misc/bluedroid 770 bluetooth net_bt_stack
# power up/down interface
chmod 0660 /sys/class/rfkill/rfkill0/state
chmod 0660 /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
write /sys/class/rfkill/rfkill0/state 0
# bluetooth LPM
chmod 0220 /proc/bluetooth/sleep/lpm
chmod 0220 /proc/bluetooth/sleep/btwrite
chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm
chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite
# 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"
service btuartservice /system/bin/btuartservice
class core
user root
group root
disabled
oneshot
on property:persist.service.bdroid.uart=*
start btuartservice
on property:persist.service.bdroid.sleep=bcm
insmod /system/vendor/modules/bcm_btlpm.ko
chmod 0220 /proc/bluetooth/sleep/lpm
chmod 0220 /proc/bluetooth/sleep/btwrite
chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm
chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite
# 1. realtek & eagle wifi service
# 1.1 realtek & eagle wifi sta service
service wpa_supplicant /system/bin/logwrapper /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
# we will start as root and wpa_supplicant will switch to user wifi
# after setting up the capabilities required for WEXT
# user wifi
# group wifi inet keystore
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
# 1.2 realtek & eagle wifi sta p2p concurrent service
service p2p_supplicant /system/bin/logwrapper /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 \
-O/data/misc/wifi/sockets \
-g@android:wpa_wlan0
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
#end
android/device/softwinner/magton-perf/BoardConfig.mk
中内容
# BoardConfig.mk
#
# Product-specific compile-time definitions.
#
include device/softwinner/magton-common/BoardConfigCommon.mk
# image related
TARGET_NO_BOOTLOADER := true
TARGET_NO_RECOVERY := false
TARGET_NO_KERNEL := false
INSTALLED_KERNEL_TARGET := kernel
BOARD_KERNEL_BASE := 0x40000000
BOARD_KERNEL_CMDLINE :=
TARGET_USERIMAGES_USE_EXT4 := true
BOARD_FLASH_BLOCK_SIZE := 4096
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 805306368
#BOARD_USERDATAIMAGE_PARTITION_SIZE :=
BOARD_WIFI_VENDOR := realtek
WIFI_DRIVER_MODULE_PATH :="/system/vendor/modules/"
WIFI_DRIVER_MODULE_NAME :="8723bs"
WIFI_DRIVER_MODULE_ARG :="ifname=wlan0 if2name=p2p0"
# wifi and bt configuration
# 1. wifi Configuration
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
SW_BOARD_USR_WIFI := rtl8723bs
BOARD_WLAN_DEVICE := rtl8723bs
#include device/softwinner/common/hardware/realtek/wlan/Android.mk
# 2. Bluetooth Configuration
# make sure BOARD_HAVE_BLUETOOTH is true for every bt vendor
include device/softwinner/common/hardware/realtek/bluetooth/rtl8723bs/firmware/rtlbtfw_cfg.mk
BOARD_HAVE_BLUETOOTH := true
BOARD_HAVE_BLUETOOTH_RTK := true
BLUETOOTH_HCI_USE_RTK_H5 := true
BOARD_HAVE_BLUETOOTH_NAME := rtl8723bs
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/softwinner/magton-perf/bluetooth/
# 3. Sensor HAL Configuration
SW_BOARD_USES_SENSORS_TYPE = aw_sensors
android/hardware/libhardware_legacy/wifi/wifi.c
无修改
android/hardware/libhardware_legacy/wifi_hardware_info/wifi_hardware_info.c
中注意:
{
.device_id = 0x1b723,
.module_name = "rtl8723bs",
.driver_name = "8723bs",
.vendor_name = "realtek",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
static const struct wifi_hardware_info wifi_list[] = {
{
.device_id = 0x00179,
.module_name = "rtl8188eu",
.driver_name = "8188eu",
.vendor_name = "realtek",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x08179,
.module_name = "rtl8188etv",
.driver_name = "8188eu",
.vendor_name = "realtek",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x18179,
.module_name = "rtl8189es",
.driver_name = "8189es",
.vendor_name = "realtek",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x1f179,
.module_name = "rtl8189fs",
.driver_name = "8189fs",
.vendor_name = "realtek",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x1b723,
.module_name = "rtl8723bs",
.driver_name = "8723bs",
.vendor_name = "realtek",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x1a9a6,
.module_name = "ap6212",
.driver_name = "bcmdhd",
.vendor_name = "broadcom",
.fw_path_sta = "/system/vendor/modules/fw_bcm43438a0.bin",
.fw_path_ap = "/system/vendor/modules/fw_bcm43438a0_apsta.bin",
.fw_path_p2p = "/system/vendor/modules/fw_bcm43438a0_p2p.bin",
},
{
.device_id = 0x1a962,
.module_name = "ap6210",
.driver_name = "bcmdhd",
.vendor_name = "broadcom",
.fw_path_sta = "/system/vendor/modules/fw_bcm40181a2.bin",
.fw_path_ap = "/system/vendor/modules/fw_bcm40181a2_apsta.bin",
.fw_path_p2p = "/system/vendor/modules/fw_bcm40181a2_p2p.bin",
},
{
.device_id = 0x14330,
.module_name = "ap6330",
.driver_name = "bcmdhd",
.vendor_name = "broadcom",
.fw_path_sta = "/system/vendor/modules/fw_bcm40183b2_ag.bin",
.fw_path_ap = "/system/vendor/modules/fw_bcm40183b2_ag_apsta.bin",
.fw_path_p2p = "/system/vendor/modules/fw_bcm40183b2_ag_p2p.bin",
},
{
.device_id = 0x14335,
.module_name = "ap6335",
.driver_name = "bcmdhd",
.vendor_name = "broadcom",
.fw_path_sta = "/system/vendor/modules/fw_bcm4339a0_ag.bin",
.fw_path_ap = "/system/vendor/modules/fw_bcm4339a0_ag_apsta.bin",
.fw_path_p2p = "/system/vendor/modules/fw_bcm4339a0_ag_p2p.bin",
},
{
.device_id = 0x13030,
.module_name = "ssv6051",
.driver_name = "ssv6051",
.vendor_name = "southsv",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x11111,
.module_name = "esp8089",
.driver_name = "esp8089",
.vendor_name = "eagle",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
{
.device_id = 0x12281,
.module_name = "xr819",
.driver_name = "xradio_wlan",
.vendor_name = "xradio",
.fw_path_sta = "STA",
.fw_path_ap = "AP",
.fw_path_p2p = "P2P",
},
};
android/device/softwinner/common/hardware/realtek/bluetooth/rtl8723bs/libbt-vendor/Android.mk
注意:LOCAL_MODULE := libbt-vendor-rtk
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 \
src/hardware.c \
src/userial_vendor.c \
src/upio.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(BDROID_DIR)/hci/include
LOCAL_SHARED_LIBRARIES := \
libcutils
LOCAL_MODULE := libbt-vendor-rtk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_OWNER := realtek
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
LOCAL_REQUIRED_MODULES := btuartservice
include $(LOCAL_PATH)/vnd_buildcfg.mk
include $(BUILD_SHARED_LIBRARY)
#endif # BOARD_HAVE_BLUETOOTH_RTK
android/device/softwinner/common/hardware/realtek/bluetooth/rtl8723bs/libbt-vendor/src/bt_vendor_rtk.c
注意:int uart_id = 3;
使用了串口3
/******************************************************************************
*
* Filename: bt_vendor_rtk.c
*
* Description: Realtek vendor specific library implementation
*
******************************************************************************/
#undef NDEBUG
#define LOG_TAG "bt_vendor"
#include
#include
#include
#include "bt_vendor_rtk.h"
#include "upio.h"
#include "userial_vendor.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
/******************************************************************************
** Externs
******************************************************************************/
void hw_config_start(void);
#if (HW_END_WITH_HCI_RESET == TRUE)
void hw_epilog_process(void);
#endif
/******************************************************************************
** Variables
******************************************************************************/
bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
uint8_t vnd_local_bd_addr[6]={
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int uart_id = 3;
int baud_rate = 1500000;
#define PROC_BLUETOOTH_VENDOR_ID "/proc/bluetooth/vendor_id"
/******************************************************************************
** Local type definitions
******************************************************************************/
/******************************************************************************
** Static Variables
******************************************************************************/
static const tUSERIAL_CFG userial_init_cfg =
{
(USERIAL_DATABITS_8 | USERIAL_PARITY_EVEN | USERIAL_STOPBITS_1),
USERIAL_BAUD_115200,
USERIAL_HW_FLOW_CTRL_OFF
};
/******************************************************************************
** Functions
******************************************************************************/
#define PROC_BLUETOOTH_UART_ID_PATH "/proc/bluetooth/uart_id"
#define PROC_BLUETOOTH_BAUD_RATE_PATH "/proc/bluetooth/baud_rate"
static void read_proc_bluetooth_info()
{
char buf[50];
int fd;
fd = open(PROC_BLUETOOTH_UART_ID_PATH, O_RDONLY);
if (fd < 0)
{
ALOGE("can not open %s\n", PROC_BLUETOOTH_UART_ID_PATH);
return;
}
read(fd, &buf, sizeof(buf));
close(fd);
uart_id = strtol(buf, 0, 10);
ALOGI("uart id = %d\n", uart_id);
fd = open(PROC_BLUETOOTH_BAUD_RATE_PATH, O_RDONLY);
if (fd < 0)
{
ALOGE("can not open %s\n", PROC_BLUETOOTH_BAUD_RATE_PATH);
return;
}
read(fd, &buf, sizeof(buf));
close(fd);
baud_rate = strtol(buf, 0, 10);
ALOGI("baud rate = %d\n", baud_rate);
}
/*****************************************************************************
**
** 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;
}
read_proc_bluetooth_info();
upio_write_proc(PROC_BLUETOOTH_VENDOR_ID, 1);
userial_vendor_init();
upio_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:
{
int *state = (int *) param;
if (*state == BT_VND_PWR_OFF)
{
upio_set_bluetooth_power(UPIO_BT_POWER_OFF);
usleep(200000);
BTVNDDBG("set power off and delay 200ms");
}
else if (*state == BT_VND_PWR_ON)
{
upio_set_bluetooth_power(UPIO_BT_POWER_ON);
usleep(500000);
BTVNDDBG("set power on and delay 500ms");
}
}
break;
case BT_VND_OP_FW_CFG:
{
hw_config_start();
}
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((tUSERIAL_CFG *) &userial_init_cfg);
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:
{
}
break;
case BT_VND_OP_LPM_SET_MODE:
{
uint8_t *mode = (uint8_t *) param;
rtl_hw_lpm_enable(*mode);
}
break;
case BT_VND_OP_LPM_WAKE_SET_STATE:
{
}
break;
case BT_VND_OP_EPILOG:
{
#if (HW_END_WITH_HCI_RESET == FALSE)
if (bt_vendor_cbacks)
{
bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
}
#else
hw_epilog_process();
#endif
}
break;
}
return retval;
}
/** Closes the interface */
static void cleanup( void )
{
BTVNDDBG("cleanup");
upio_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
};