android4.0.3 bluetooth

android:android4.0.3
kernel:linux3.0.8

五一放假之前,这个蓝牙可以收发数据了,身上一下子轻松了好多。
1.kernel :
[*] Networking support  ---> 
               <*>   Bluetooth subsystem support  --->
                              [*]   L2CAP protocol support                                                   
                              [*]   SCO links support                                                       
                              <*>   RFCOMM protocol support                                                
                             [*]     RFCOMM TTY support                                                   
                             <*>   BNEP protocol support                                                     
                             [ ]     Multicast filter support                                               
                             [ ]     Protocol filter support                                                 
                             <*>   HIDP protocol support                                                   
                             Bluetooth device drivers  --->   
                     <*> HCI USB driver                                                             
                     < > HCI SDIO driver                                                            
                     < > HCI UART driver                                                            
                     < > HCI BCM203x USB driver                                                   
                     < > HCI BPA10x USB driver                                                      
                     < > HCI BlueFRITZ! USB driver                                                 
                     < > HCI VHCI (Virtual HCI device) driver                                      
                     < > Marvell Bluetooth driver support                                            
                     <*> Atheros firmware download driver
          <*>   RF switch subsystem support  --->
                        [*]   Power off on suspend                                                   
                        [*]   RF switch input support                                                  
                        <*>   Generic rfkill regulator driver                                          
                        <*>   GPIO RFKILL driver

2.android
a. init.smdkv210.rc 添加:
      chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
     chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
     chmod 0660                /sys/class/rfkill/rfkill0/state


b. 在init.rc中添加:
service hciattach /system/bin/hciattach -n -s 115200 /dev/ttySAC1  bcsp  115200
        class main
        disabled
        oneshot

到了这里编译烧写后,蓝牙能正常使用了。

问题1:
打开蓝牙—系统休眠—唤醒—蓝牙自动关闭再也打不开。
但是在系统休眠或是USB蓝牙设备热插拔后蓝牙设备的节点名就会被重新分配,也就是驱动被重新加载了。这样驱动注册
时所创建的文件夹rfkill0就会变成rfkill1、rfkill2、rfkill3……这就会导致android上层找不到设备文件。
解决:
把设备名定死为rfkill0,这样设备起来的时候就不会因找不到设备了。
修改:
kernel\net\rfkill\core.c
在函数rfkill_register(struct rfkill *rfkill)中:
     //rfkill_no=0;  //方法1:强制置0
     rfkill->idx = rfkill_no;
     dev_set_name(dev, "rfkill%lu", rfkill_no);
      //rfkill_no++;  //方法2:注释掉设备名自加


问题2:
修改上述问题后,系统休眠后唤醒或者热插拔,设备名就一直是rfkill0了。
但是蓝牙还是打不开,提示对rfkill0/state没有写权限,logcat提示:
E/bluedroid( 161): open(/sys/class/rfkill/rfkill0/state) for write failed: Permission denied (13)
E/BluetoothAdapterStateMachine( 161): failed to prepare bluetooth, abort turning on
D/BluetoothAdapterStateMachine( 161): Bluetooth state 11 -> 10
解决:
给state权限。
 在源码中给权限,即在注册时给设备节点读写权限:
kernel\net\rfkill\core.c
在rfkill_dev_attrs 结构体中将 state 中S_IWUSR改为S_IWUGO
__ATTR(state, S_IRUGO| S_IWUGO, rfkill_state_show, rfkill_state_store),//S_IWUSR, rfkill_state_show, rfkill_state_store),

说明:#define S_IWUGO          (S_IWUSR|S_IWGRP|S_IWOTH)
S_IWUSR:用户写权限
S_IWGRP:用户组写权限
S_IWOTH:其他写权限

或者可先在终端给权限,chmod 0666 state

问题3:
修改权限后,唤醒后打开打开蓝牙—系统休眠—唤醒—android会重启,但是kernel没有重启,即屏幕上会回到android
闪动的那个画面,待系统起来后,bluetooth又能正常工作了。但过会系统休眠后又会重复上述情况。logcat提示:
D/BluetoothEventLoop( 2636): Property Changed: Pairable : true
D/BluetoothAdapterStateMachine( 2636): BluetoothOn process message: 54
E/BluetoothAdapterStateMachine( 2636): Get unexpected power on event, reset with: 1
D/BluetoothAdapterStateMachine( 2636): HotOff process message: 102

解决:追踪到 android\frameworks\base\core\java\android\server\BluetoothA2dpService.java 550行
 private class BluetoothOn extends State {中
case POWER_STATE_CHANGED:
                    if ((Boolean) message.obj) {
                        // reset the state machine and send it TURN_ON_CONTINUE message
                        // recoverStateMachine(USER_TURN_ON, false);  //注释掉此句
                    }
                    break;
                default:

编译烧写后,唤醒后打开打开蓝牙—系统休眠—唤醒,蓝牙还能继续正常工作,再关闭打开也正常。


全志A33平台调通AP6181 大文实验室/大文哥 壹捌陆捌零陆捌捌陆捌贰 wb4916 AT qq.com 完成时间:2017/6/22 20:15 版本:V1.0 1、(可选,在设置中不显示:蓝牙) Z:\home\rediron\a33\ap6181_bb16v3_sina33\android\device\softwinner\astar-y3\overlay\frameworks\base\core\res\res\values\config.xml (直接去掉) <!-- 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> 2、去掉蓝牙: Z:\home\rediron\a33\ap6181_bb16v3_sina33\android\device\softwinner\astar-y3\astar_y3.mk # wifi features PRODUCT_COPY_FILES += \ 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 #frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml \ #frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml # 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/firmware/ap6210/device-bcm.mk) #$(call inherit-product-if-exists, hardware/broadcom/wlan/firmware/ap6330/device-bcm.mk) #rtl8723bs bt fw and config #$(call inherit-product, hardware/realtek/bluetooth/rtl8723bs/firmware/rtlbtfw_cfg.mk) #PRODUCT_PACKAGES += Bluetooth #PRODUCT_PROPERTY_OVERRIDES += \ # ro.product.8723b_bt.used=true PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mass_storage,adb \ ro.adb.secure=0 ro.udisk.lable=Polaris \ ro.font.scale=1.0 \ ro.hwa.force=false \ rw.logger=0 \ ro.sys.bootfast=true \ debug.hwc.showfps=0 \ debug.hwui.render_dirty_regions=false #ro.sys.storage_type = emulated \ #for gms #PRODUCT_PROPERTY_OVERRIDES += \ # ro.sys.mutedrm=true \ # ro.adb.secure=1 PRODUCT_PROPERTY_OVERRIDES += \ ro.sf.lcd_density=213 \ ro.product.firmware=v2.0 #include device/softwinner/polaris-common/prebuild/google/products/gms_base.mk 3、关闭rtl8188eu,打开AP6181: Z:\home\rediron\a33\ap6181_bb16v3_sina33\android\device\softwinner\astar-y3\BoardConfig.mk # wifi and bt configuration # 1. Wifi Configuration # 1.1 realtek wifi support # 1.1 realtek wifi configuration #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 SW_BOARD_USR_WIFI := rtl8188eu BOARD_WLAN_DEVICE := rtl8188eu #SW_BOARD_USR_WIFI := rtl8723au #BOARD_WLAN_DEVICE := rtl8723au #SW_BOARD_USR_WIFI := rtl8723bs #BOARD_WLAN_DEVICE := rtl8723bs endif # 1.2 broadcom wifi support BOARD_WIFI_VENDOR := broadcom 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" #SW_BOARD_USR_WIFI := AP6181 SW_BOARD_USR_WIFI := AP6210 WIFI_DRIVER_FW_PATH_STA := "/system/vendor/modules/fw_bcm40181a2.bin" WIFI_DRIVER_FW_PATH_P2P := "/system/vendor/modules/fw_bcm40181a2_p2p.bin" WIFI_DRIVER_FW_PATH_AP := "/system/vendor/modules/fw_bcm40181a2_apsta.bin" #SW_BOARD_USR_WIFI := AP6330 #WIFI_DRIVER_FW_PATH_STA := "/system/vendor/modules/fw_bcm40183b2_ag.bin" #WIFI_DRIVER_FW_PATH_P2P := "/system/vendor/modules/fw_bcm40183b2_ag_p2p.bin" #WIFI_DRIVER_FW_PATH_AP := "/system/vendor/modules/fw_bcm40183b2_ag_apsta.bin" endif #1.3 eag wifi config #BOARD_WIFI_VENDOR := eagle ifeq ($(BOARD_WIFI_VENDOR), eagle) WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WPA_SUPPLICANT_DRIVER := NL80211 BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_eagle BOARD_HOSTAPD_DRIVER := NL80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_eagle SW_BOARD_USR_WIFI := esp8089 BOARD_WLAN_DEVICE := esp8089 endif # 2. Bluetooth Configuration # make sure BOARD_HAVE_BLUETOOTH is true for every bt vendor #BOARD_HAVE_BLUETOOTH := true #BOARD_HAVE_BLUETOOTH_BCM := true #SW_BOARD_HAVE_BLUETOOTH_NAME := ap6210 #SW_BOARD_HAVE_BLUETOOTH_NAME := ap6330 #BOARD_HAVE_BLUETOOTH_RTK := true #BLUETOOTH_HCI_USE_RTK_H5 := true #SW_BOARD_HAVE_BLUETOOTH_NAME := rtl8723bs 4、关闭BT: Z:\home\rediron\a33\ap6181_bb16v3_sina33\android\device\softwinner\astar-y3\init.sun8i.rc on early-fs mount_all /fstab.sun8i setprop ro.crypto.fuse_sdcard true insmod /system/vendor/modules/disp.ko insmod /system/vendor/modules/lcd.ko insmod /system/vendor/modules/mali.ko insmod /system/vendor/modules/leds-sunxi.ko insmod /system/vendor/modules/bcmdhd.ko ## bluetooth # # UART device # chmod 0660 /dev/ttyS1 # chown bluetooth net_bt_stack /dev/ttyS1 # # # 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 # write /proc/bluetooth/sleep/lpm 1 #2G or 3G init.rc # import init.sunxi.3gdongle.rc ## 1. realtek & eagle wifi service ## 1.1 realtek & eagle wifi sta service #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 # # 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/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 # 2. broadcom wifi service # 2.1 broadcom wifi station and softap 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 # 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 # 2.2 broadcom wifi sta p2p concurrent service service p2p_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 -N \ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ -I/system/etc/wifi/p2p_supplicant_overlay.conf \ -puse_p2p_group_interface=1 -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 5、(可选配置:) Z:\home\rediron\a33\ap6181_bb16v3_sina33\android\frameworks\base\packages\SettingsProvider\res\values\defaults.xml <integer name="def_screen_off_timeout">1800000</integer> <bool name="def_lockscreen_disabled">true</bool> 6、(可选配置:) Z:\home\rediron\a33\ap6181_bb16v3_sina33\lichee\tools\pack\chips\sun8iw5p1\configs\default\env.cfg bootdelay=3 loglevel=8 7、修改配置文件: Z:\home\rediron\a33\ap6181_bb16v3_sina33\lichee\tools\pack\chips\sun8iw5p1\configs\y3\sys_config.fex aldo1_vol = 3300 aldo2_vol = 2500 aldo3_vol = 3000 dldo1_vol = 3300 dldo2_vol = 3300 dldo3_vol = 2800 ;gpio0_vol = 2800 ldoio0_vol = 2800 [card2_boot_para] card_ctrl = 2 card_high_speed = 1 card_line = 8 sdc_2xmode = 1 sdc_ddrmode = 1 sdc_clk = port:PC05<3><1><2><default> sdc_cmd = port:PC06<3><1><2><default> sdc_d0 = port:PC08<3><1><2><default> sdc_d1 = port:PC09<3><1><2><default> sdc_d2 = port:PC10<3><1><2><default> sdc_d3 = port:PC11<3><1><2><default> sdc_d4 = port:PC12<3><1><2><default> sdc_d5 = port:PC13<3><1><2><default> sdc_d6 = port:PC14<3><1><2><default> sdc_d7 = port:PC15<3><1><2><default> [wakeup_src_para] cpu_en = 0 cpu_freq = 48 ; (cpu:apb:ahb) pll_ratio = 0x111 dram_selfresh_en= 1 dram_freq = 36 wakeup_src_wl = port:PL07<4><default><default><0> ;wakeup_src_bt = port:PL09<4><default><default><0> ;bb_wake_ap = port:PL02<4><default><default><0> ;---------------------------------------------------------------------------------- ;uart configuration ;uart_used = uart x enable ;uart_type = 2:2 wire,4:4 wire,8:8 wire, full function ;---------------------------------------------------------------------------------- [uart0] uart_used = 1 uart_port = 0 uart_type = 2 uart_tx = port:PF02<3><1><default><default> uart_rx = port:PF04<3><1><default><default> ;-------------------------------------------------------------------------------- ;wifi configuration ;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) ;wifi_mod_sel: 0- none, 1- ap6181, 2- ap6210(wifi+bt), ; 3 - rtl8188eu, 4- rtl8723au(wifi+bt), ; 5 - rtl8723bs, 6- esp8089 ;-------------------------------------------------------------------------------- [wifi_para] wifi_used = 1 wifi_sdc_id = 1 wifi_usbc_id = 1 wifi_usbc_type = 1 wifi_mod_sel = 1 wifi_power = "axp22_aldo1" wifi_power_ext1 = "" wifi_power_ext2 = "" wifi_power_switch = ;wifi_power_switch = port:power0<1><0><default><0> ; 1 - ap6181 sdio wifi gpio config ap6xxx_wl_regon = port:PL06<1><default><default><0> ap6xxx_wl_host_wake = port:PL07<4><default><default><0> ap6xxx_lpo_use_apclk = 1 ; 2 - ap6210 sdio wifi gpio config ;ap6xxx_wl_regon = port:PL06<1><default><default><0> ;ap6xxx_wl_host_wake = port:PL07<4><default><default><0> ;ap6xxx_bt_regon = port:PL08<1><default><default><0> ;ap6xxx_bt_wake = port:PL10<1><default><default><0> ;ap6xxx_bt_host_wake = port:PL09<4><default><default><0> ;ap6xxx_lpo_use_apclk = 1 [bt_para] bt_used = 0 bt_uart_id = 1
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值