How to fix bluetooth in Android 7.1 with kernel 4.16?

1,296 views
Skip to first unread message

tristin....@gmail.com

unread,
Apr 23, 2018, 10:03:04 PM4/23/18
to Android-x86
I am trying to use Android 7.1 with an updated kernel (4.16) on a Dell Venue Pro 7140. The tablet has an Intel .... The appropriate driver for the hardware is loaded, but I can not enable Bluetooth though the UI.

I can program, and want to try to fix the problem myself, but I don't know which submodule to begin exploring to fix the issue. Based on slides here[1], I believe there are 4 places to possibly check. Am I moving in the right direction, or should I look for files elsewhere?:

external/bluetooth/bluedroid
pacakges/app/Bluetooth/jni
hardware/<vendor> - not sure what the Androidx86 equivalent of this is
external/bluedroid/main

I believe these are the relevant lines from logcat the indicate the problem.


04-19 20:38:51.157  5648  5675 I bt_hci_h4: hal_open
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_op op 3
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_open
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_open returning 72
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_op op 3 retval 1
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_op op 1
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_fw_cfg
04-19 20:38:51.157  5648  5675 I bt_vendor: bt_vendor_wait_hcidev
04-19 20:38:51.157  5648  5675 E bt_vendor: socket bind error Operation not permitted
04-19 20:38:51.157  5648  5675 E bt_vendor: Hardware Config Error

...

04-19 20:38:51.158  5648  5676 I bt_core_module: module_init Initialized module "bte_logmsg_module"
04-19 20:38:51.159  5648  5677 W bt_osi_thread: run_thread: thread id 5677, thread name module_wrapper started
04-19 20:38:51.159  5648  5677 I bt_core_module: module_start_up Starting module "controller_module"
04-19 20:38:51.159  5648  5675 E bt_hci_h4: In transmit_data, error writing to the uart serial port: File descriptor in bad state
04-19 20:38:59.158  5648  5669 E bt_hci  : command_timed_out hci layer timeout waiting for response to a command. opcode: 0xc03
04-19 20:38:59.158  5648  5669 E %s restarting the bluetooth process.: command_timed_out
04-19 20:38:59.158  5648  5669 I bt_vendor: ssr_cleanup
04-19 20:38:59.159  5648  5669 E bt_hci  : hci_cmd_timeout: SOC Status is reset



[1] https://www.slideshare.net/nanik/android-bluetooth-stack

zhongtian xie

unread,
Apr 23, 2018, 10:58:48 PM4/23/18
to andro...@googlegroups.com
put your bluetooth chip info here;

also need dmesg and lsmod output log;

method get dmesg is go into cmdline and click cmd:

 dmesg >dmesg.log

 lsmod >lsmod.log



--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-x86+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-x86.
For more options, visit https://groups.google.com/d/optout.

tristin....@gmail.com

unread,
Apr 23, 2018, 11:20:21 PM4/23/18
to Android-x86
Ah yeah, I did forget to mention the chip. Bluetooth is provided by the Intel 8260 chipset.

Attached are the dmesg and lsmod logs.
lsmod.log
dmesg.log

youling 257

unread,
Apr 23, 2018, 11:32:03 PM4/23/18
to Android-x86

Chih-Wei Huang

unread,
Apr 24, 2018, 4:18:01 AM4/24/18
to Android-x86
2018-04-24 10:03 GMT+08:00 <tristin....@gmail.com>:
This document is a little out of date.
Android 7 doesn't use Bluedroid anymore.
It has switched to Fluoride Bluetooth stack.
The code is under system/bt/.
That's where you should check.

BTW, do you see any hci interface by hciconfig?


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

zhongtian xie

unread,
Apr 24, 2018, 4:23:28 AM4/24/18
to andro...@googlegroups.com
Can't find useful information;

did you try kernel 4.9 or 4.14 ?



--

tristin....@gmail.com

unread,
Apr 24, 2018, 8:10:52 AM4/24/18
to Android-x86


On Monday, 23 April 2018 22:03:04 UTC-4, tristin....@gmail.com wrote:


Thank you for the direction. I'll start looking in system/bt.

 I can indeed see the hci device via hciconfig:

hci0:    Type: Primary  Bus: USB
    BD Address: A4:34:D9:4C:24:A7  ACL MTU: 1021:4  SCO MTU: 96:6
    DOWN
    RX bytes:15095 acl:0 sco:0 events:2441 errors:0
    TX bytes:603292 acl:0 sco:0 commands:2439 errors:0

And yes, the device does work with kernel 4.9; I can turn on bluetooth, scan for devices, connect, etc.

youling 257

unread,
Apr 24, 2018, 9:16:35 AM4/24/18
to Android-x86
no,it workd on android-4.9,not work on vanilla kernel 4.9.
did you try android-4.14 android-4.15 android-4.16?


在 2018年4月24日星期二 UTC+8下午8:10:52,tristin....@gmail.com写道:

tristin....@gmail.com

unread,
Apr 29, 2018, 11:05:15 PM4/29/18
to Android-x86
I'm pretty sure it is a permission issue like youling257 mentioned.

These two lines:


04-19 20:38:51.157  5648  5675 E bt_vendor: socket bind error Operation not permitted
04-19 20:38:51.157  5648  5675 E bt_vendor: Hardware Config Error


are a consequence of the following bind call failing, on line 332 in system/bt/vendor_libs/linux/bt_vendor_linux.c:

  if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
    LOG_ERROR(LOG_TAG, "socket bind error %s", strerror(errno));
    goto failure;
  }

Since it can't bind, it can't configure the hardware. Probably, later errors are a result of that.

It looks like a permission issue, just like youling257 alluded to in the stackoverflow link. I'm also more confident of that because I can use hciconfig and hcitool commands as root to bring up hci0 scan for devices.

I saw youling257 mentioned the CONFIG_ANDROID_PARANOID_NETWORK kernel option, but that option is not available in the androidx86 x86/kernel-4.14 branch, nor is it in any of the maurossi kernels that I tried.

I considered rebasing the experimental/android-mainline-tracking branch onto the x86/kernel-4.14 branch, but I stopped when I noticed there were a lot of conflicts that I didn't want to try to resolve until I knew it would lead somewhere. The experimental/android-mainline-tracking branch does include the CONFIG_ANDROID_PARANOID_NETWORK option.

I have four questions:

Is it right to say that it is the Android Bluetooth system service that lacks the permissions to bind to the fd?
What does the kernel option CONFIG_ANDROID_PARANOID_NETWORK do?
Why is CONFIG_ANDROID_PARANOID_NETWORK is available in the x86/kernel-4.9 branch, but not in the x86/kernel-4.14 branch?
Are there things that I could only find in the x86/kernel-4.9 or 4-14 branches that I wouldn't find in the experimental/android-mainline-tracking branch?




On Monday, 23 April 2018 22:03:04 UTC-4, tristin....@gmail.com wrote:

Chih-Wei Huang

unread,
Apr 29, 2018, 11:25:04 PM4/29/18
to Android-x86
Why did you say that?
Either your checkout was broken,
or you checked out the wrong branch.

Mauro Rossi

unread,
Apr 30, 2018, 9:22:37 PM4/30/18
to Android-x86


Il giorno lunedì 30 aprile 2018 05:05:15 UTC+2, tristin....@gmail.com ha scritto:
I'm pretty sure it is a permission issue like youling257 mentioned.

These two lines:

04-19 20:38:51.157  5648  5675 E bt_vendor: socket bind error Operation not permitted
04-19 20:38:51.157  5648  5675 E bt_vendor: Hardware Config Error


are a consequence of the following bind call failing, on line 332 in system/bt/vendor_libs/linux/bt_vendor_linux.c:

  if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
    LOG_ERROR(LOG_TAG, "socket bind error %s", strerror(errno));
    goto failure;
  }

Since it can't bind, it can't configure the hardware. Probably, later errors are a result of that.

It looks like a permission issue, just like youling257 alluded to in the stackoverflow link. I'm also more confident of that because I can use hciconfig and hcitool commands as root to bring up hci0 scan for devices.

I saw youling257 mentioned the CONFIG_ANDROID_PARANOID_NETWORK kernel option, but that option is not available in the androidx86 x86/kernel-4.14 branch, nor is it in any of the maurossi kernels that I tried.

I considered rebasing the experimental/android-mainline-tracking branch onto the x86/kernel-4.14 branch, but I stopped when I noticed there were a lot of conflicts that I didn't want to try to resolve until I knew it would lead somewhere. The experimental/android-mainline-tracking branch does include the CONFIG_ANDROID_PARANOID_NETWORK option.

I have four questions:

Is it right to say that it is the Android Bluetooth system service that lacks the permissions to bind to the fd?
What does the kernel option CONFIG_ANDROID_PARANOID_NETWORK do?

Special treatments for Android networking permissions to restrict access to specific users
 
Why is CONFIG_ANDROID_PARANOID_NETWORK is available in the x86/kernel-4.9 branch, but not in the x86/kernel-4.14 branch?

It is still available with x86/kernel-4.14 branch,  [1] was added to cope with more recent kernels (kernel 4.15 and later) where 'paranoid' was dropped and explicit permissions became necessary


Better check permissions if you are using a 4.16 kernel
M.

zhongtian xie

unread,
Apr 30, 2018, 9:48:42 PM4/30/18
to andro...@googlegroups.com
I Think you should check what  the kernel driver module was load  on kernel-4.9 by lsmod, and then check kernel-4.16 lsmod(maybe it was not load corretly) ; 


youling 257

unread,
Apr 30, 2018, 10:08:12 PM4/30/18
to Android-x86
it's not about CAP_NET_RAW and CAP_NET_ADMIN,it's about NET_BT_ADMIN 

https://android.googlesource.com/kernel/common/+/afbf0af890dcefb2f90159d14b9d6ea5974e9185%5E%21/#F2

在 2018年5月1日星期二 UTC+8上午9:22:37,Mauro Rossi写道:

tristin....@gmail.com

unread,
May 5, 2018, 9:17:41 PM5/5/18
to Android-x86
Thank you for the advice. I've managed to compile a 4.16 kernel with working Bluetooth in Android 7.1.

I used https://android.googlesource.com/kernel/common as my upstream. I check out the experimental-android-4.16 tag and merged the Android x86 patches that Mauro has been merging into his trees. Enabling the CONFIG_ANDROID_PARANOID_NETWORK option was required to allow Android applications to enable and disable the Bluetooth radio.
Reply all
Reply to author
Forward
0 new messages