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:

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


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
全志R16平台的android6.0.1系统下的RTL8188EU的配置V1.0 2017/5/31 10:30 1、R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\overlay\frameworks\base\core\res\res\values\config.xml <!-- 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.*" --> <string-array translatable="false" name="config_tether_wifi_regexs"> <item>"wlan0"</item> </string-array> RTL8188EU没有BT,需要干掉BT的配置(不要显示): <!-- 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、 R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\astar_evb30.mk PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml \ frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \ frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \ (干掉BT部分)frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml 开启ADB,方便调试: PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mtp \ ro.adb.secure=1 \ ro.sys.mutedrm=true \ rw.logger=0 修改为: PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mass_storage,adb \ ro.adb.secure=0 \ ro.sys.mutedrm=true \ rw.logger=0 3、 R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\BoardConfig.mk # wifi and bt configuration # 1. Wifi Configuration # 1.1 realtek wifi support # 1.1 realtek wifi configuration # BOARD_USR_WIFI: rtl8188eu/rtl8723bs/rtl8723bs_vq0/rtl8723cs (打开realtek这个开关,并配置为rtl8188eu,默认为:rtl8723bs_vq0) 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 #BOARD_USR_WIFI := rtl8723bs_vq0 BOARD_USR_WIFI := rtl8188eu BOARD_WLAN_DEVICE := rtl8188eu include hardware/realtek/wlan/config/config.mk 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" 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_NAME := ap6212 #BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/softwinner/astar-evb30/bluetooth 4、 R:\wyb\rtl8188eu_r16m_20161208\android\device\softwinner\astar-evb30\init.sun8i.rc # network (关闭博通:AP6212,打开realtek) #insmod /system/vendor/modules/bcmdhd.ko #insmod /system/vendor/modules/bcm_btlpm.ko insmod /system/vendor/modules/8188eu.ko insmod /system/vendor/modules/usbnet.ko insmod /system/vendor/modules/asix.ko insmod /system/vendor/modules/qf9700.ko insmod /system/vendor/modules/mcs7830.ko insmod /system/vendor/modules/smsc95xx.ko insmod /system/vendor/modules/rtl8150.ko insmod /system/vendor/modules/cdc_ether.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 # # # 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" # # # 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 (关闭博通的部分:AP6212) ## broadcom wifi service ## 1 broadcom wifi sta service #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 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 (增加rtl8188eu部分) # realtek wifi 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 class main socket wpa_wlan0 dgram 660 wifi wifi disabled oneshot # 1.2 realtek 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 5、 R:\wyb\rtl8188eu_r16m_20161208\android\hardware\realtek\bluetooth\firmware\rtlbtfw_cfg.mk $(LOCAL_PATH)/rtl8703b_config:system/etc/firmware/rtl8703bs_config (关闭realtek的BT,否则会编译出错:) #$(TOP_DIR)device/softwinner/$(basename $(TARGET_DEVICE))/bluetooth/rtkbt.conf:system/etc/bluetooth/rtkbt.conf \ make: *** 没有规则可以创建“out/target/product/astar-evb30/system/etc/bluetooth/rtkbt.conf”需要的目标“device/softwinner/astar-evb30/bluetooth/rtkbt.conf”。 停止。 Export includes file: external/sqlite/dist/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/sqlite3_intermediates/export_includes Notice file: external/sqlite/dist/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/sqlite3.txt Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/strace_intermediates/import_includes Export includes file: external/strace/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/strace_intermediates/export_includes Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/su_intermediates/import_includes Export includes file: system/extras/su/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/su_intermediates/export_includes Notice file: system/extras/su/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/su.txt Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/taskstats_intermediates/import_includes Export includes file: system/extras/taskstats/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/taskstats_intermediates/export_includes Notice file: system/extras/taskstats/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/taskstats.txt Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/tcpdump_intermediates/import_includes Export includes file: external/tcpdump/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/tcpdump_intermediates/export_includes Import includes file: out/target/product/astar-evb30/obj/EXECUTABLES/timeinfo_intermediates/import_includes Export includes file: system/extras/timeinfo/Android.mk -- out/target/product/astar-evb30/obj/EXECUTABLES/timeinfo_intermediates/export_includes Notice file: system/extras/timeinfo/NOTICE -- out/target/product/astar-evb30/obj/NOTICE_FILES/src//system/xbin/timeinfo.txt make: *** 没有规则可以创建“out/target/product/astar-evb30/system/etc/bluetooth/rtkbt.conf”需要的目标“device/softwinner/astar-evb30/bluetooth/rtkbt.conf”。 停止。 make: *** 正在等待未完成的任务.... 12585 unique nodes, 42861 total 注: 某些输入文件使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 注: 某些输入文件使用了未经检查或不安全的操作。 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。 12585 unique nodes, 42861 total 21515 unique nodes, 102669 total #### make failed to build some targets (01:21 (mm:ss)) #### rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/android$ grep rtkbt.conf . -R Z:\home\rediron\r16m\rtl8188eu_r16m_20161208\android\hardware\realtek\bluetooth\firmware\rtlbtfw_cfg.mk 6、 R:\wyb\rtl8188eu_r16m_20161208\lichee\tools\pack\chips\sun8iw5p1\configs\evb-30\sys_config.fex (关闭BT) ;-------------------------------------------------------------------------------- ;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 = 0 bt_uart_id = 1 bt_rst_n = port:PL08<1><default><default><0> bt_wake = port:PL10<1><default><default><0> bt_host_wake = port:PL09<4><default><default><0> bt_host_wake_invert = 0 7、配置USB1(接RTL8188EU) rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208$ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208$ cd lichee/ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/lichee$ cd linux-3.4/ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/lichee/linux-3.4$ rootroot@cm-System-Product-Name:/home/rediron/r16m/rtl8188eu_r16m_20161208/lichee/linux-3.4$ make ARCH=arm menuconfig Device Drivers ---> [*] USB support ---> <*> SoftWinner SUNXI USB Host Controller support <*> SoftWinner SUNXI USB Host Controller0 <*> SoftWinner SUNXI USB HCI <*> SoftWinner SUNXI USB EHCI0 < > SoftWinner SUNXI USB EHCI1 修改为: <*> SoftWinner SUNXI USB EHCI1 <*> SoftWinner SUNXI USB OHCI0 < > SoftWinner SUNXI USB OHCI1 修改为: <*> SoftWinner SUNXI USB OHCI1 < > SoftWinner SUNXI USB EHCI2 < > SoftWinner SUNXI USB OHCI2 < > SoftWinner SUNXI USB EHCI3 < > SoftWinner SUNXI USB OHCI3 < > SoftWinner SUNXI USB HSIC 不加这里内核报错,但是不影响上网! shell@astar-evb30:/ $ shell@astar-evb30:/ $ [ 30.993687] hci: ERR: not support sunxi_usb_enable_ehci [ 30.999650] hci: ERR: not support sunxi_usb_enable_ohci shell@astar-evb30:/ $ shell@astar-evb30:/ $

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值