Get bluetooth working in Linux kernel with mt7630e

Md Jahidul Hamid edited this page Aug 13, 2017 · 7 revisions

What you need to do:

  1. Recompile btusb.c with the patch and generate the btusb.ko file (this is what you actually need).
  2. Copy the btusb.ko file in /lib/modules/$(uname -r)/kernel/drivers/bluetooth
  3. Restart bluetooth


Get the kernel source code ready for the patch:

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" .

Apply the patch:

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);


Device id:

You can get the device id by running lsusb |grep -i mediatek, then change USB_DEVICE(0x0e8d, 0x763f) accordingly in the above patch.

Line number:

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:

  1. Remember the sequence 1,2,4,8
  2. After 8 comes 1 but the the number increases


  1. For a sequence 0x40000, 0x80000 the next is 0x100000
  2. For a sequence 0x00001, 0x00002, 0x00004, 0x00008 the next is 0x00010

Finally build the module:

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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.