-
-
Notifications
You must be signed in to change notification settings - Fork 70
Get bluetooth working in Linux kernel with mt7630e
For kernel 4.15.X, this answer works: (https://askubuntu.com/a/1043219)
- Recompile
btusb.c
with the patch and generate thebtusb.ko
file (this is what you actually need). - Copy the
btusb.ko
file in/lib/modules/$(uname -r)/kernel/drivers/bluetooth
- Restart bluetooth
sudo service bluetooth stop #Stop the bluetooth
sudo apt-get install build-essential linux-headers-$(uname -r)
cd to your prefered build dir
apt-get source linux-image-$(uname -r) # Get the kernel source code
sudo apt-get build-dep linux-image-$(uname -r) # Build kernel dependencies
cd to the created source dir
cp "/boot/config-$(uname -r)" .config
cp "/usr/src/linux-headers-$(uname -r)/Module.symvers" .
Inside the linux kernel source this is where this file resides: drivers/bluetooth/btusb.c
Open this file and apply the following patch (from sipertruk comment):
--- drivers/bluetooth/btusb.c 2015-08-30 20:34:09.000000000 +0200
+++ ../linux-4.2.0/drivers/bluetooth/btusb.c 2016-03-13 21:06:23.393727580 +0100
@@ -60,6 +60,7 @@
#define BTUSB_QCA_ROME 0x8000
#define BTUSB_BCM_APPLE 0x10000
#define BTUSB_REALTEK 0x20000
+#define BTUSB_MEDIATEK 0x40000
static const struct usb_device_id btusb_table[] = {
/* Generic Bluetooth USB device */
@@ -73,7 +74,7 @@
.driver_info = BTUSB_BCM_APPLE },
/* MediaTek MT76x0E */
- { USB_DEVICE(0x0e8d, 0x763f) },
+ { USB_DEVICE(0x0e8d, 0x763f), .driver_info = BTUSB_MEDIATEK },
/* Broadcom SoftSailing reporting vendor specific */
{ USB_DEVICE(0x0a5c, 0x21e1) },
@@ -2796,6 +2803,10 @@
set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks);
}
+ if (id->driver_info & BTUSB_MEDIATEK) {
+ set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks);
+ }
+
if (id->driver_info & BTUSB_INTEL_BOOT)
set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
You can get the device id by running lsusb |grep -i mediatek
, then change USB_DEVICE(0x0e8d, 0x763f)
accordingly in the above patch.
Do not rely on line numbers. Line numbers are different for different kernel versions and flavour. Make the line number an optional parameter to look for the preceding or following lines. Use a text editor to search exact lines then look at line numbers, if it is close enough then it's the place where you add your patch.
#define BTUSB_MEDIATEK 0x40000
may defer flavour to flavour. If there is already an entry for 0x40000
, then don't add it with the same value, and do not replace the existing #define
with this one to get the same as the patch, instead change it to a value that is unique. For example, In xubuntu 16.04 LTS there already exists:
#define BTUSB_REALTEK 0x20000
#define BTUSB_BCM2045 0x40000
#define BTUSB_IFNUM_2 0x80000
Therefore, you should do:
#define BTUSB_REALTEK 0x20000
#define BTUSB_BCM2045 0x40000
#define BTUSB_IFNUM_2 0x80000
#define BTUSB_MEDIATEK 0x100000
And also remember that these values (0x80000
, 0x100000
) are not random.
It may be a bit difficult for you to understand what's going on with these values if you don't know about hex and binary and hex-binary conversion and how bitwise operation works in C. But I am going to show you a easy way how you can make this work correctly:
- Remember the sequence 1,2,4,8
- After 8 comes 1 but the the number increases
Examples,
- For a sequence
0x40000, 0x80000
the next is0x100000
- For a sequence
0x00001, 0x00002, 0x00004, 0x00008
the next is0x00010
make prepare
make modules_prepare
make M=scripts/mod
make M=drivers/bluetooth/ modules
sudo cp drivers/bluetooth/btusb.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth
sudo service bluetooth start
This patch is being discussed in https://github.com/neurobin/MT7630E/issues/6