Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix for CSR Dongle 0a12:0001 ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
#!/usr/bin/env sh
set -e
function info {
GREEN="\033[1;32m"
RESET="\033[0m"
echo -e "$GREEN==> $@$RESET"
}
version="${1:-$(uname -r | cut -d'-' -f1)}"
extra="${2:-$(uname -r | cut -d'-' -f2-)}"
fullversion="$version-$extra"
modules=(
'drivers/bluetooth:btusb'
'net/bluetooth:bluetooth'
)
info Making patch for kernel $fullversion
name="linux-$version"
archive="$name.tar.xz"
info Downloading kernel $name
wget -c https://cdn.kernel.org/pub/linux/kernel/v5.x/$archive -O $archive
info Extracting $archive
tar -xJf $archive
info Setting up kernel config
make -C $name mrproper
cp /usr/lib/modules/$fullversion/build/.config $name/
cp /usr/lib/modules/$fullversion/build/Module.symvers $name/
make -C $name oldconfig
info Applying CSR dongle fix
patch -p1 -d $name < fix_csr_dongle.patch
info Preparing kernel modules
make -C $name EXTRAVERSION=-$extra modules_prepare
for module in "${modules[@]}" ; do
module_path=${module%%:*}
module_name=${module#*:}
info Making $module_name kernel module
make -C $name M=$module_path
info Compressing $module_path/$module_name.ko kernel module
xz $name/$module_path/$module_name.ko
done
info Installing
sudo mkdir -p /usr/lib/modules/$fullversion/updates
for module in "${modules[@]}" ; do
module_path=${module%%:*}
module_name=${module#*:}
info Installing $module_name kernel module
sudo cp -f $name/$module_path/$module_name.ko.xz /usr/lib/modules/$fullversion/updates/$module_name.ko.xz
done
info Copying csr-bluetoothdongle.conf to /etc/modprobe.d/ with contents:
cat csr-bluetoothdongle.conf
sudo cp -f csr-bluetoothdongle.conf /etc/modprobe.d/99-csr-bluetoothdongle.conf
info Running 'mkinitcpio'
sudo mkinitcpio -p linux
info Removing temp files
rm -f $archive
rm -rf $name
info Now you can reboot to load patched kernel modules
options btusb reset=1 enable_autosuspend=0
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5f022e9cf..5b8cf9ba9 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1720,6 +1720,7 @@ static int btusb_setup_csr(struct hci_dev *hdev)
{
struct hci_rp_read_local_version *rp;
struct sk_buff *skb;
+ bool is_fake = false;
BT_DBG("%s", hdev->name);
@@ -1739,18 +1740,69 @@ static int btusb_setup_csr(struct hci_dev *hdev)
rp = (struct hci_rp_read_local_version *)skb->data;
- /* Detect controllers which aren't real CSR ones. */
+ /* Detect a wide host of Chinese controllers that aren't CSR.
+ *
+ * Known fake bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891
+ *
+ * The main thing they have in common is that these are really popular low-cost
+ * options that support newer Bluetooth versions but rely on heavy VID/PID
+ * squatting of this poor old Bluetooth 1.1 device. Even sold as such.
+ *
+ * We detect actual CSR devices by checking that the HCI manufacturer code
+ * is Cambridge Silicon Radio (10) and ensuring that LMP sub-version and
+ * HCI rev values always match. As they both store the firmware number.
+ */
if (le16_to_cpu(rp->manufacturer) != 10 ||
- le16_to_cpu(rp->lmp_subver) == 0x0c5c) {
+ le16_to_cpu(rp->hci_rev) != le16_to_cpu(rp->lmp_subver))
+ is_fake = true;
+
+ /* Known legit CSR firmware build numbers and their supported BT versions:
+ * - 1.1 (0x1) -> 0x0073, 0x020d, 0x033c, 0x034e
+ * - 1.2 (0x2) -> 0x04d9, 0x0529
+ * - 2.0 (0x3) -> 0x07a6, 0x07ad, 0x0c5c
+ * - 2.1 (0x4) -> 0x149c, 0x1735, 0x1899 (0x1899 is a BlueCore4-External)
+ * - 4.0 (0x6) -> 0x1d86, 0x2031, 0x22bb
+ *
+ * e.g. Real CSR dongles with LMP subversion 0x73 are old enough that
+ * support BT 1.1 only; so it's a dead giveaway when some
+ * third-party BT 4.0 dongle reuses it.
+ */
+ else if (le16_to_cpu(rp->lmp_subver) <= 0x034e &&
+ le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_1)
+ is_fake = true;
+
+ else if (le16_to_cpu(rp->lmp_subver) <= 0x0529 &&
+ le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_2)
+ is_fake = true;
+
+ else if (le16_to_cpu(rp->lmp_subver) <= 0x0c5c &&
+ le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_0)
+ is_fake = true;
+
+ else if (le16_to_cpu(rp->lmp_subver) <= 0x1899 &&
+ le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_1)
+ is_fake = true;
+
+ else if (le16_to_cpu(rp->lmp_subver) <= 0x22bb &&
+ le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_4_0)
+ is_fake = true;
+
+ if (is_fake) {
+ bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; adding workarounds...");
+
+ /* Generally these clones have big discrepancies between
+ * advertised features and what's actually supported.
+ * Probably will need to be expanded in the future;
+ * without these the controller will lock up.
+ */
+ set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
+ set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks);
+
/* Clear the reset quirk since this is not an actual
* early Bluetooth 1.1 device from CSR.
*/
clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
-
- /* These fake CSR controllers have all a broken
- * stored link key handling and so just disable it.
- */
- set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
+ clear_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
}
kfree_skb(skb);
@@ -4001,11 +4053,13 @@ static int btusb_probe(struct usb_interface *intf,
if (bcdDevice < 0x117)
set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+ /* This must be set first in case we disable it for fakes */
+ set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+
/* Fake CSR devices with broken commands */
- if (bcdDevice <= 0x100 || bcdDevice == 0x134)
+ if (le16_to_cpu(udev->descriptor.idVendor) == 0x0a12 &&
+ le16_to_cpu(udev->descriptor.idProduct) == 0x0001)
hdev->setup = btusb_setup_csr;
-
- set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
}
if (id->driver_info & BTUSB_SNIFFER) {
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 181900553..155019220 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -41,6 +41,8 @@
#define BLUETOOTH_VER_1_1 1
#define BLUETOOTH_VER_1_2 2
#define BLUETOOTH_VER_2_0 3
+#define BLUETOOTH_VER_2_1 4
+#define BLUETOOTH_VER_4_0 6
/* Reserv for core and drivers use */
#define BT_SKB_RESERVE 8
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 16ab6ce87..1c321b6d1 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -227,6 +227,17 @@ enum {
* supported.
*/
HCI_QUIRK_VALID_LE_STATES,
+
+ /* When this quirk is set, then erroneous data reporting
+ * is ignored. This is mainly due to the fact that the HCI
+ * Read Default Erroneous Data Reporting command is advertised,
+ * but not supported; these controllers often reply with unknown
+ * command and tend to lock up randomly. Needing a hard reset.
+ *
+ * This quirk can be set before hci_register_dev is called or
+ * during the hdev->setup vendor callback.
+ */
+ HCI_QUIRK_BROKEN_ERR_DATA_REPORTING,
};
/* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index dbe2d79f2..48d7c7e23 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -606,7 +606,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
if (hdev->commands[8] & 0x01)
hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL);
- if (hdev->commands[18] & 0x04)
+ if (hdev->commands[18] & 0x04 &&
+ !test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks))
hci_req_add(req, HCI_OP_READ_DEF_ERR_DATA_REPORTING, 0, NULL);
/* Some older Broadcom based Bluetooth 1.2 controllers do not
@@ -851,7 +852,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt)
/* Set erroneous data reporting if supported to the wideband speech
* setting value
*/
- if (hdev->commands[18] & 0x08) {
+ if (hdev->commands[18] & 0x08 &&
+ !test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) {
bool enabled = hci_dev_test_flag(hdev,
HCI_WIDEBAND_SPEECH_ENABLED);
@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Apr 9, 2020

Put csr-bluetoothbongle.conf at /etc/modprobe.d/

@akiftariq

This comment has been minimized.

Copy link

@akiftariq akiftariq commented Jul 13, 2020

Shouldn't the modeprobe be modprobe in create_btusb_patch.sh

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 13, 2020

Shouldn't the modeprobe be modprobe in create_btusb_patch.sh

You're right, fixed the gist. Thanks!

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 13, 2020

Updated the patch for Linux 5.7.7
Added set -e to fail fast

@gustavolinux

This comment has been minimized.

Copy link

@gustavolinux gustavolinux commented Jul 13, 2020

I don't understand. I tried this and that one on https://www.reddit.com/r/AnnePro/comments/e76ij8/csr_40_bluetooth_dongle_on_linux/ but my adapter doesn't work, which is strange cause it works when I try linux mint 18.04 on my VM.
lsusb shows:
Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

dmesg shows:
[ 829.155117] usb 1-2: new full-speed USB device number 6 using xhci_hcd [ 829.297170] usb 1-2: New USB device found, idVendor=0a12, idProduct=0001, bcdDevice=25.20 [ 829.297175] usb 1-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 829.297179] usb 1-2: Product: CSR8510 A10

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 13, 2020

I don't understand. I tried this and that one on https://www.reddit.com/r/AnnePro/comments/e76ij8/csr_40_bluetooth_dongle_on_linux/ but my adapter doesn't work, which is strange cause it works when I try linux mint 18.04 on my VM.
lsusb shows:
Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

dmesg shows:
[ 829.155117] usb 1-2: new full-speed USB device number 6 using xhci_hcd [ 829.297170] usb 1-2: New USB device found, idVendor=0a12, idProduct=0001, bcdDevice=25.20 [ 829.297175] usb 1-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 829.297179] usb 1-2: Product: CSR8510 A10

According to https://bugzilla.kernel.org/show_bug.cgi?id=60824
Another patch was submitted https://patchwork.kernel.org/patch/11644615/

You can download patch https://patchwork.kernel.org/patch/11644615/raw , rename it to fix_btusb.patch and run my script.
Give it a try and tell us if it works, I'll update this Gist accordingly.
I cannot test this patch right now, sorry.

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 13, 2020

And update your /etc/modprobe.d/csr-bluetoothdongle.conf to:

options btusb reset=1 enable_autosuspend=0
@gustavolinux

This comment has been minimized.

Copy link

@gustavolinux gustavolinux commented Jul 13, 2020

I don't understand. I tried this and that one on https://www.reddit.com/r/AnnePro/comments/e76ij8/csr_40_bluetooth_dongle_on_linux/ but my adapter doesn't work, which is strange cause it works when I try linux mint 18.04 on my VM.
lsusb shows:
Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
dmesg shows:
[ 829.155117] usb 1-2: new full-speed USB device number 6 using xhci_hcd [ 829.297170] usb 1-2: New USB device found, idVendor=0a12, idProduct=0001, bcdDevice=25.20 [ 829.297175] usb 1-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 829.297179] usb 1-2: Product: CSR8510 A10

According to https://bugzilla.kernel.org/show_bug.cgi?id=60824
Another patch was submitted https://patchwork.kernel.org/patch/11644615/

You can download patch https://patchwork.kernel.org/patch/11644615/raw , rename it to fix_btusb.patch and run my script.
Give it a try and tell us if it works, I'll update this Gist accordingly.
I cannot test this patch right now, sorry.

And update your /etc/modprobe.d/csr-bluetoothdongle.conf to:

options btusb reset=1 enable_autosuspend=0

tried it, unfortunately it didn't work. It's strange since looks pretty much like the chip discussed here. If on Linux Mint 18.04 it works, should We try to look what driver was preinstalled on it?

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 13, 2020

tried it, unfortunately it didn't work. It's strange since looks pretty much like the chip discussed here. If on Linux Mint 18.04 it works, should We try to look what driver was preinstalled on it?

It's possible, that Linux Mint maintainers adopted some patch for this device in their kernel tree. Ask them directly at forums or mailing lists.

@gustavolinux

This comment has been minimized.

Copy link

@gustavolinux gustavolinux commented Jul 13, 2020

tried it, unfortunately it didn't work. It's strange since looks pretty much like the chip discussed here. If on Linux Mint 18.04 it works, should We try to look what driver was preinstalled on it?

It's possible, that Linux Mint maintainers adopted some patch for this device in their kernel tree. Ask them directly at forums or mailing lists.

But it works just on older versions of linux mint, I think I will try on some older version of antergos or manjaro,.

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 13, 2020

I will try on some older version of antergos or manjaro,.

https://wiki.archlinux.org/index.php/Bluetooth#CSR_Dongle_0a12:0001

You need a really old kernel for that.

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Jul 18, 2020

The patch from https://patchwork.kernel.org/patch/11644615/ is working with my setup.
Updated this gist.

@ZReC

This comment has been minimized.

Copy link

@ZReC ZReC commented Jul 26, 2020

Hi guys, I've tried this in Arch Linux 5.7.10-arch1-1 and unfortunately it doesn't work. Any ideas?
By the way, I've tried and It does work in Linux Mint out of the box, it's at least curious.

@khoishady

This comment has been minimized.

Copy link

@khoishady khoishady commented Aug 2, 2020

Help. I got an error while execute the file

~/Downloads/a$ ./create_btusb_patch.sh
./create_btusb_patch.sh: 4: function: not found

Ubuntu 20.04.1 LTS

@irawanhd

This comment has been minimized.

Copy link

@irawanhd irawanhd commented Aug 2, 2020

Help. I got an error while execute the file

~/Downloads/a$ ./create_btusb_patch.sh
./create_btusb_patch.sh: 4: function: not found

Ubuntu 20.04.1 LTS

try run it with
bash ./create_btusb_patch.sh

@khoishady

This comment has been minimized.

Copy link

@khoishady khoishady commented Aug 3, 2020

Help. I got an error while execute the file
~/Downloads/a$ ./create_btusb_patch.sh
./create_btusb_patch.sh: 4: function: not found
Ubuntu 20.04.1 LTS

try run it with
bash ./create_btusb_patch.sh

I got another error :(
:~/Downloads/a$ bash ./create_btusb_patch.sh
==> Making patch for kernel 5.4.0-42-generic
==> Downloading kernel linux-5.4.0
--2020-08-03 09:30:14-- https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.0.tar.xz
Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.77.176, 2a04:4e42:12::432
Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.77.176|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2020-08-03 09:30:15 ERROR 404: Not Found.

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Aug 4, 2020

I got another error :(
Can't find sources for 5.4.0 at https://cdn.kernel.org/pub/linux/kernel/v5.x/
I've never tested this fix with ubuntu, sorry.

I think 5.4.0-42-generic corresponds to https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.42/

You can modify the script to support ubuntu's kernel versioning scheme

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Aug 4, 2020

Updated the gist with v4 patch https://patchwork.kernel.org/patch/11686157/

Original patch was accepted by kernel team, as stated in this comment https://bugzilla.kernel.org/show_bug.cgi?id=60824#c116

All bugs related with the patch, but not with create_patch.sh, must be reported in official bug tracker https://bugzilla.kernel.org/show_bug.cgi?id=60824

@uhugu

This comment has been minimized.

Copy link

@uhugu uhugu commented Aug 4, 2020

Hi there,

figured out the 404 error, solution below:

add line: ' namecdn=linux-"${3:-$(uname -r | cut -c"1,2,3,4,7,8")}".tar.xz '
change line: 'wget -cd https://cdn.kernel.org/pub/linux/kernel/v5.x/$archive -O $archive
to: ' wget -c https://cdn.kernel.org/pub/linux/kernel/v5.x/$namecdn -O $archive

however when I run it the following message:
"
==> Setting up kernel config
make: *** linux-5.4.0: No such file or directory. Stop.
"
or should I be executing in a particular directory?

uname -a : 'Linux uhugu-desktop 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux '

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Aug 10, 2020

Hi there. As @nevack said, the patch should be part of whatever comes after Linux 5.8, if they don't backport it first.

There are as many fake dongles as colors in the rainbow, and they are often good at hiding their fakeness, so any HCI dumps [see the Bugzilla thread for instructions] help. :)

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Aug 10, 2020

Also, this was just the first stab at mainlining stuff after being fed up with it, and fixing my dongle. Any patches refining the detection checks or adding more quirks when detected should be easy-ish to do when building onto what's already there, anyone knowing a bit of C can submit them. It should be a few diff lines!

@gnulux

This comment has been minimized.

Copy link

@gnulux gnulux commented Aug 12, 2020

Linux 5.8.1-050801-generic on Ubuntu , the device is detected but i cannot set it up (device 00:1A:7D:DA:71:10 ):

hciconfig 
hci0:	Type: Primary  Bus: USB
	BD Address: 00:1A:7D:DA:71:10  ACL MTU: 640:4  SCO MTU: 64:8
	DOWN 
	RX bytes:1002 acl:0 sco:0 events:44 errors:0
	TX bytes:658 acl:0 sco:0 commands:44 errors:0

hci1:	Type: Primary  Bus: USB
	BD Address: 4C:1D:96:6D:CB:48  ACL MTU: 1021:4  SCO MTU: 96:6
	UP RUNNING 
	RX bytes:4691 acl:0 sco:0 events:187 errors:0
	TX bytes:10581 acl:0 sco:0 commands:178 errors:0

hci1 is my laptop internal bluetooth device which works well .

hciconfig hci0 up 
Can't init device hci0: Invalid request code (56)
lsusb 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 8087:0029 Intel Corp. 
Bus 001 Device 004: ID 13d3:56cb IMC Networks USB2.0 HD IR UVC WebCam
Bus 001 Device 008: ID 046d:c534 Logitech, Inc. Unifying Receiver
Bus 001 Device 007: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Any idea ?

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Aug 13, 2020

Search for the CSR: Unbranded CSR clone detected; adding workarounds... string in dmesg.
Otherwise your thingie doesn't pass the checks yet.

Attach the output of btmon -w my.log (or alternatively hcidump -X) to the Bugzilla thread. As shown here:
https://bugzilla.kernel.org/show_bug.cgi?id=60824#c123

We also need to know your bcdDevice from your lsusb -vvd 0a12:0001. As that's the special number.

@gnulux

This comment has been minimized.

@yoshibz

This comment has been minimized.

Copy link

@yoshibz yoshibz commented Aug 21, 2020

[root@cloud patchblue]# sh create_btusb_patch.sh
==> Making patch for kernel 5.4.58-1-lts
==> Downloading kernel linux-5.4.58
--2020-08-21 20:42:16-- https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.58.tar.xz
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.113.176, 2a04:4e42:1b::432
Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.113.176|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 109570484 (104M) [application/x-xz]
Saving to: ‘linux-5.4.58.tar.xz’

linux-5.4.58.tar.xz 100%[==================================>] 104.49M 2.37MB/s in 45s

2020-08-21 20:43:02 (2.33 MB/s) - ‘linux-5.4.58.tar.xz’ saved [109570484/109570484]

==> Extracting linux-5.4.58.tar.xz
==> Setting up kernel config
make: Entering directory '/root/patchblue/linux-5.4.58'
make: Leaving directory '/root/patchblue/linux-5.4.58'
make: Entering directory '/root/patchblue/linux-5.4.58'
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --oldconfig Kconfig
make: Leaving directory '/root/patchblue/linux-5.4.58'
==> Applying CSR dongle fix
patching file drivers/bluetooth/btusb.c
Hunk #1 succeeded at 1621 (offset -99 lines).
Hunk #2 succeeded at 1641 (offset -99 lines).
Hunk #3 succeeded at 3910 (offset -143 lines).
patching file include/net/bluetooth/bluetooth.h
patching file include/net/bluetooth/hci.h
Hunk #1 FAILED at 227.
1 out of 1 hunk FAILED -- saving rejects to file include/net/bluetooth/hci.h.rej
patching file net/bluetooth/hci_core.c
Hunk #1 FAILED at 606.
Hunk #2 FAILED at 851.
2 out of 2 hunks FAILED -- saving rejects to file net/bluetooth/hci_core.c.rej

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Aug 21, 2020

Hi. That is an old kernel version; to backport the patch to older Linux versions remove the HCI_QUIRK_BROKEN_ERR_DATA_REPORTING line from btusb.c and ignore the hci.h / hci_core.c changes, as none of that had been implemented by then. After that it should work fine.

@mmd2020

This comment has been minimized.

Copy link

@mmd2020 mmd2020 commented Aug 23, 2020

Hi tried this script, but it gives below error
cp: cannot stat '/usr/lib/modules/5.8.2-050802-generic/build/.config': No such file or director

I checked there is no such directory and file.

I have Ubuntu 20.04 LTS with Kernel 5.4.0-42-generic. Then updated kernel to hoping that 5.8.2-050802-generic hoping by Bluetooth device will work with this .(As you mentioned this script is accepted in 5.7 and 5.8 version of kernel)
With new kernel 5.8.2-050802-generic, it detects logitech M337 mouse , but not able to configure. Then I tried above script and got error
cp: cannot stat '/usr/lib/modules/5.8.2-050802-generic/build/.config': No such file or director

Here is the output of some commands

lsusb -vvd 0a12:0001... gives bcdDevice 25.20

dmesg |grep 'CSR clone detected'
[ 75.420911] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds...
[ 4880.814947] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds...
[22664.573526] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds...
[23268.855461] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds...

btmon -w my.log
Bluetooth monitor ver 5.54
= Note: Linux version 5.8.2-050802-generic (x86_64) 0.574027
= Note: Bluetooth subsystem version 2.22 0.574029
= New Index: 00:1A:7D:DA:71:10 (Primary,USB,hci0) [hci0] 0.574030
@ MGMT Open: bluetoothd (privileged) version 1.17 {0x0001} 0.574031
@ MGMT Open: btmon (privileged) version 1.17

hcidump -X
HCI sniffer - Bluetooth packet analyzer ver 5.53
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff

@oscarr-reyes

This comment has been minimized.

Copy link

@oscarr-reyes oscarr-reyes commented Aug 23, 2020

I've also executed this script on Ubuntu 20 with latest update at the moment and exited with an error

==> Applying CSR dongle fix
patching file drivers/bluetooth/btusb.c
Hunk #1 succeeded at 1630 (offset -90 lines).
Hunk #2 succeeded at 1650 (offset -90 lines).
Hunk #3 succeeded at 3942 (offset -111 lines).
patching file include/net/bluetooth/bluetooth.h
patching file include/net/bluetooth/hci.h
Hunk #1 FAILED at 227.
1 out of 1 hunk FAILED -- saving rejects to file include/net/bluetooth/hci.h.rej
patching file net/bluetooth/hci_core.c
Hunk #1 succeeded at 605 (offset -1 lines).
Hunk #2 succeeded at 847 (offset -5 lines).
@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Aug 23, 2020

I've also executed this script on Ubuntu 20 with latest update at the moment and exited with an error

==> Applying CSR dongle fix
patching file drivers/bluetooth/btusb.c
Hunk #1 succeeded at 1630 (offset -90 lines).
Hunk #2 succeeded at 1650 (offset -90 lines).
Hunk #3 succeeded at 3942 (offset -111 lines).
patching file include/net/bluetooth/bluetooth.h
patching file include/net/bluetooth/hci.h
Hunk #1 FAILED at 227.
1 out of 1 hunk FAILED -- saving rejects to file include/net/bluetooth/hci.h.rej
patching file net/bluetooth/hci_core.c
Hunk #1 succeeded at 605 (offset -1 lines).
Hunk #2 succeeded at 847 (offset -5 lines).

Read https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07#gistcomment-3426618

@gnulux

This comment has been minimized.

Copy link

@gnulux gnulux commented Aug 24, 2020

I'm on Unbuntu 20 too. But i moved on official kernel 5.8.1-050801-generic with the patch . it works fine for me

@mmd2020

This comment has been minimized.

Copy link

@mmd2020 mmd2020 commented Aug 25, 2020

Yes...finally it is working...
I installed kernel 5.8.3 and ran above script
And it is working...
Thank you very much....

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Sep 3, 2020

Hi. That is an old kernel version; to backport the patch to older Linux versions remove the HCI_QUIRK_BROKEN_ERR_DATA_REPORTING line from btusb.c and ignore the hci.h / hci_core.c changes, as none of that had been implemented by then. After that it should work fine.

FYI, patch no longer works for at with kernel versions 5.8.3 and up (currently 5.8.5 on Arch).

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Sep 3, 2020

FYI, patch no longer works for at with kernel versions 5.8.3 and up (currently 5.8.5 on Arch).

Well, Marcel merged the v4 of my patch and it got mainlined starting with the 5.8.2 stable kernel, and probably 5.9.

Take a look at the Bugzilla thread, I give progress updates.

There's a weird Bluetooth regression on my end when testing mainline 5.8.2+ where connections are buggy, not sure if other people can reproduce it. Kernel 5.7 with the same patch worked fine, so something must have been added in between that needs another workaround.

So yeah, any help helps.

@lucassmacedo

This comment has been minimized.

Copy link

@lucassmacedo lucassmacedo commented Sep 8, 2020

Hi! Work with me only when i upgrade kernel to 5.8.3 from Ubuntu 20.04 LTS.
I Use mainline to upgrade the Kernel.
For Brazilians: https://medium.com/@lucasmacedo/instalando-usb-bluetooth-dongle-no-ubuntu-23c3378f83c3

@monte-monte

This comment has been minimized.

Copy link

@monte-monte monte-monte commented Sep 9, 2020

Hi! I've patched the module for current ubuntu's kernel. I have two different dongles one of them works even without patch, other works only with enable_autosuspend=1 for some reason. Both of them work okay with my bluetooth speaker while there is some sound. But when sound ends and transmission stops, they seems to disconnect, and have trouble to connect automatically again when sound resumes. Is there any possible fix, or is that just bad dongles. Or maybe it has something to do with pulseaudio? I just want to know in what direction to look, because almost no information is found on this particular issue on google.

@vractal

This comment has been minimized.

Copy link

@vractal vractal commented Sep 9, 2020

Hi! Work with me only when i upgrade kernel to 5.8.3 from Ubuntu 20.04 LTS.
I Use mainline to upgrade the Kernel.
For Brazilians: https://medium.com/@lucasmacedo/instalando-usb-bluetooth-dongle-no-ubuntu-23c3378f83c3

Did you also install the patch? or just updated the kernel? I tried just the kernel update but didnt work (perguntando porque é o que você disse no texto do medium)

@lucassmacedo

This comment has been minimized.

Copy link

@lucassmacedo lucassmacedo commented Sep 9, 2020

Hi! Work with me only when i upgrade kernel to 5.8.3 from Ubuntu 20.04 LTS.
I Use mainline to upgrade the Kernel.
For Brazilians: https://medium.com/@lucasmacedo/instalando-usb-bluetooth-dongle-no-ubuntu-23c3378f83c3

Did you also install the patch? or just updated the kernel? I tried just the kernel update but didnt work (perguntando porque é o que você disse no texto do medium)

Hello! I Just update the kernel, nothing else.

@mmd2020

This comment has been minimized.

Copy link

@mmd2020 mmd2020 commented Sep 10, 2020

I am using Kernel 5.8.5. Bluetooth mouse is working fine, but some times it starts lagging and becomes very slow.Especially, when I start downloading files on Telegram, mouse becomes very slow. I tried some solutions , but problem is not solved.

Anybody know solution for this ?

@monte-monte

This comment has been minimized.

Copy link

@monte-monte monte-monte commented Sep 12, 2020

Can confirm, 5.8.3 doesn't work properly, though patch is present. Kernel 5.8.8, on the other hand works correctly, also there is no disconnects. LED on a dongle keeps flashing all the time, so it seems they've added some fix to always transmit data to avoid disconnects.

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Sep 12, 2020

The patch was the same. I guess our fake dongles are extremely finicky to little changes or new functionality they may be adding in BlueZ.

I don't have enough time to track down any Bluetooth issues anytime soon. So if anyone else rises to the challenge, it would be neat to get the other half working. Even narrowing down possible culprits may be helpful. You don't need to be a programmer.

@DaveHigs

This comment has been minimized.

Copy link

@DaveHigs DaveHigs commented Sep 16, 2020

sorry a newb here, where do I need to put this file in order to run the script?? do I use patch command?

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Sep 16, 2020

sorry a newb here, where do I need to put this file in order to run the script?? do I use patch command?

Download all three files, and place them together.
Make .sh file executable and run it.
It's preferably to impicitly declare kernel version and extra as arguments.

For example, for kernel 5.8.9-arch1-1

./create_btusb_patch.sh 5.8.9 arch1-1

For kernel versions above 5.8.4 you don't need this patch, it's already included.

@DaveHigs

This comment has been minimized.

Copy link

@DaveHigs DaveHigs commented Sep 16, 2020

sorry a newb here, where do I need to put this file in order to run the script?? do I use patch command?

Download all three files, and place them together.
Make .sh file executable and run it.
It's preferably to impicitly declare kernel version and extra as arguments.

For example, for kernel 5.8.9-arch1-1

./create_btusb_patch.sh 5.8.9 arch1-1

For kernel versions above 5.8.4 you don't need this patch, it's already included.

Im running kernel 5.8.6 still cant use the btusb adapter properly it gets stuck scanning eternally. im still gonna try this fix thank you for answering!! I'll let you know what happens

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Sep 16, 2020

Again, third time. I'm the patch author, this has been mainlined since Linux 5.8.2. If the kernel is newer you don't need this. The patch was a good first step back in Linux 5.7. But something they added after that has caused it to be insufficient.

We need more patches on top and I don't have time for that right now. So I'm asking for help.

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Sep 16, 2020

Anyone with enough time can bisect and find the exact point where it stopped working. You don't need to be a developer to help, and it would help a lot.

@walidahmed860

This comment has been minimized.

Copy link

@walidahmed860 walidahmed860 commented Sep 18, 2020

guys it worked, i read something about usb 2 and usb 3, and i just swapped the ports and it worked, but very bad performance i have to say. thanks anyway, and my comment history got my journey.

@khoishady

This comment has been minimized.

Copy link

@khoishady khoishady commented Sep 22, 2020

How to run these codes in details? Every time I tried to run nothing happened :(

@DKrepsky

This comment has been minimized.

Copy link

@DKrepsky DKrepsky commented Oct 4, 2020

Got mine working on Mint 20 with kernel 5.7.19-050719-generic (from ubuntu mainline), patch is already applied, just download the .debs and install from: https://kernel.ubuntu.com/~kernel-ppa/mainline/

Btw, great job @Swyter and @nevack!

Bluetooth dongle:
Class: 0x0005a0
Service Classes: Unspecified
Device Class: Peripheral, Pointing device/(reserved)
HCI Version: 4.0 (0x6) Revision: 0x3120
LMP Version: 4.0 (0x6) Subversion: 0x22bb
Manufacturer: Cambridge Silicon Radio (10)

@luisito-36

This comment has been minimized.

Copy link

@luisito-36 luisito-36 commented Oct 12, 2020

I typed on the terminal to apply on Ubuntu 20.04.1 with the Kernel: 5.8.2-050802-generic.

patch -p1 < fix_csr_dongle.patch, I got the following code:

 can't find file to patch at input line 5
 Perhaps you used the wrong -p or --strip option?
 The text leading up to this was:
 --------------------------
 |diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
 |index 5f022e9cf..5b8cf9ba9 100644
 |--- a/drivers/bluetooth/btusb.c
 |+++ b/drivers/bluetooth/btusb.c
 --------------------------
 File to patch: 
 Skip this patch? [y] y
 Skipping patch.
 3 out of 3 hunks ignored
 can't find file to patch at input line 111
 Perhaps you used the wrong -p or --strip option?
 The text leading up to this was:
 --------------------------
 |diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
 |index 181900553..155019220 100644
 |--- a/include/net/bluetooth/bluetooth.h
 |+++ b/include/net/bluetooth/bluetooth.h
 --------------------------
 File to patch: 
 Skip this patch? [y] y
 Skipping patch.
 1 out of 1 hunk ignored
 can't find file to patch at input line 124
 Perhaps you used the wrong -p or --strip option?
 The text leading up to this was:
 --------------------------
 |diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
 |index 16ab6ce87..1c321b6d1 100644
 |--- a/include/net/bluetooth/hci.h
 |+++ b/include/net/bluetooth/hci.h
 --------------------------
 File to patch: 
 Skip this patch? [y] y
 Skipping patch.
 1 out of 1 hunk ignored
 can't find file to patch at input line 146
 Perhaps you used the wrong -p or --strip option?
 The text leading up to this was:
 --------------------------
 |diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
 |index dbe2d79f2..48d7c7e23 100644
 |--- a/net/bluetooth/hci_core.c
 |+++ b/net/bluetooth/hci_core.c
 --------------------------
 File to patch: 
 Skip this patch? [y] y
 Skipping patch.
 2 out of 2 hunks ignored

I got the similar problem about fix_btusb.patch. I need some helps to solve this problem.

@luisito-36

This comment has been minimized.

Copy link

@luisito-36 luisito-36 commented Oct 12, 2020

I got the same problem on Kernel 5.8.1-050801-generic

@dandansoysauce

This comment has been minimized.

Copy link

@dandansoysauce dandansoysauce commented Oct 16, 2020

I have this dongle and I am using 5.8.11 with Manjaro. The device gets detected but the problem is I can't search for any nearby devices, it's just empty. Also, my phone can detect the dongle but couldn't pair.

Edit: I think I have the 5.0 one with bcdDevice 25.20

@jaum20

This comment has been minimized.

Copy link

@jaum20 jaum20 commented Oct 30, 2020

I'm using v5.9.0 and my device is no more no being detectable. It was when using v5.4.0 and I was able to use it with my readmi airdots but not with my dualshock 4

btmon -w my.log
Bluetooth monitor ver 5.54
= Note: Linux version 5.9.0 (armv7l) 0.389794
= Note: Bluetooth subsystem version 2.22 0.389809
@ MGMT Open: bluetoothd (privileged) version 1.18 {0x0001} 0.389816
@ MGMT Open: btmon (privileged) version 1.18 {0x0002} 0.389977
@ RAW Open: hcitool (privileged) version 2.22 {0x0003} 29.538239
@ RAW Close: hcitool {0x0003} 29.538398
@ RAW Open: hcitool (privileged) version 2.22 {0x0003} 29.538529
@ RAW Close: hcitool {0x0003} 29.538556

lsusb -vvd 0a12:0001...| grep bcdDevice
bcdDevice 25.20

dmesg |grep 'CSR clone detected' returns nothing

hcidump -X
HCI sniffer - Bluetooth packet analyzer ver 5.54
Can't attach to device hci0. No such device(19)

@marcosabb

This comment has been minimized.

Copy link

@marcosabb marcosabb commented Nov 2, 2020

sudo: mkinitcpio: command not found

@pintoXD

This comment has been minimized.

Copy link

@pintoXD pintoXD commented Nov 9, 2020

For Brazilians, or anybody else, who bought a CSR 4.0 Dongle and Ubuntu users, the solution, based on the previous comments, was the following (at least for me):

First of all, identify your dongle id, by entering lsusb | egrep -i cambridge. If the output is Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode), check the ID field. In this case, it is 0a12:0001.

Next, check your bcdDevice number by entering with lsusb -vvd 0a12:0001 | egrep -i bcdDevice. The output may be the number 25.20. If yes, nice, probably the next steps will work like a charm, if not, try it anyway, maybe could work.

  1. Updated the Kernel from 5.4.0-52 to 5.8.7 via offical Ubuntu kernel-ppa
  2. Installed blueman (and its dependencies)
  3. Tried to pair my bluetooth JBL T500BT sometimes, but without success... The workaround was to put the phone in pairing mode, search for it via blueman tool, click on "Configure", follow the wizard through pair step, after that, select "Headset" on connection step.
  4. Download the files attached on this gist, copy the .conf file to /etc/modprobe.d/ renaming the file from xxxx.conf to 99-xxx.conf.
@marcosabb

This comment has been minimized.

Copy link

@marcosabb marcosabb commented Nov 9, 2020

@pintoXD

Blueman says "No adapters found".

@pintoXD

This comment has been minimized.

Copy link

@pintoXD pintoXD commented Nov 10, 2020

@pintoXD

Blueman says "No adapters found".

What is your output for the lsusb command?

@marcosabb

This comment has been minimized.

Copy link

@marcosabb marcosabb commented Nov 10, 2020

@pintoXD
Blueman says "No adapters found".

What is your output for the lsusb command?

lsusb | egrep -i cambridge
Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

and:

lsusb -vvd 0a12:0001 | egrep -i bcdDevice
Couldn't open device, some information will be missing bcdDevice 88.91

@pintoXD

This comment has been minimized.

Copy link

@pintoXD pintoXD commented Nov 11, 2020

@pintoXD
Blueman says "No adapters found".

What is your output for the lsusb command?

lsusb | egrep -i cambridge
Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

and:

lsusb -vvd 0a12:0001 | egrep -i bcdDevice
Couldn't open device, some information will be missing bcdDevice 88.91

Well, that's weird... When it happens to me, I just unplug and plug again the dongle. What is your Kernel version?

Have you already took a look on the Arch Wiki's Bluetooth page? Maybe something there could help you.

Check it out : https://wiki.archlinux.org/index.php/Bluetooth#Bluetooth_USB_Dongle

@supersjimmie

This comment has been minimized.

Copy link

@supersjimmie supersjimmie commented Nov 17, 2020

I'm feeling stupid...

I managed to fix the script for working with namecdn=linux-"${3:-$(uname -r | cut -c"1,2,3,4,7,8")}".tar.xz and then another line a bit further to get make -C working with the correct name. So I passed that part.

Then I found that I had a bit older kernel 5.4.0-54-generic for which I needed to remove the HCI_QUIRK_BROKEN_ERR_DATA_REPORTING line from btusb.c and ignore the hci.h / hci_core.c patches.

I also had to install a dozen of packages, like make, gcc, flex, libssl-dev and probably some more.

But I am totally stuck on a very final part:
mkinitcpio: command not found
Nowhere can I find how or where to get mkinitcpio on my ubuntu machine.

@bennehcarvalho

This comment has been minimized.

Copy link

@bennehcarvalho bennehcarvalho commented Nov 19, 2020

IMPORTANT!!!
Before run the script (create_btusb_patch.sh) you may install the following dependencies:
sudo apt install flex bison

and be happy!

@bennehcarvalho

This comment has been minimized.

Copy link

@bennehcarvalho bennehcarvalho commented Nov 19, 2020

Yes...finally it is working...
I installed kernel 5.8.3 and ran above script
And it is working...
Thank you very much....

Thanks! It is working in my Kubuntu 20.04. I installed kernel 5.8.3 and the following dependencies:
sudo apt install flex bison
and after that the script (create_btusb_patch.sh) ran like a charm!

@phlbrz

This comment has been minimized.

Copy link

@phlbrz phlbrz commented Dec 1, 2020

Hi,

Is it patched in kernel 5.9.9 - Linux Machine 5.9.0-3-amd64 #1 SMP Debian 5.9.9-1 (2020-11-19) x86_64 GNU/Linux ?

sudo bash ./create_btusb_patch.sh 
==> Making patch for kernel 5.9.9
==> Removing temp files
==> Downloading kernel linux-5.9.9
--2020-11-30 22:25:36--  https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.9.9.tar.xz
Resolving cdn.kernel.org (cdn.kernel.org)... 2a04:4e42:46::432, 199.232.37.176
Connecting to cdn.kernel.org (cdn.kernel.org)|2a04:4e42:46::432|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 115546864 (110M) [application/x-xz]
Saving to: ‘linux-5.9.9.tar.xz’

linux-5.9.9.tar.xz                      100%[============================================================================>] 110.19M  11.7MB/s    in 9.6s    

2020-11-30 22:25:46 (11.4 MB/s) - ‘linux-5.9.9.tar.xz’ saved [115546864/115546864]

==> Extracting linux-5.9.9.tar.xz
==> Setting up kernel config
make: Entering directory '/home/user/Downloads/usb/linux-5.9.9'
make: Leaving directory '/home/user/Downloads/usb/linux-5.9.9'
make: Entering directory '/home/user/Downloads/usb/linux-5.9.9'
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --oldconfig Kconfig
.config:7627:warning: symbol value 'm' invalid for ASHMEM
.config:8398:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
*
* Restart config...
*
*
* Camera sensor devices
*
Hynix Hi-556 sensor support (VIDEO_HI556) [N/m/?] n
Sony IMX214 sensor support (VIDEO_IMX214) [N/m/?] n
Sony IMX219 sensor support (VIDEO_IMX219) [N/m/?] n
Sony IMX258 sensor support (VIDEO_IMX258) [N/m/?] n
Sony IMX274 sensor support (VIDEO_IMX274) [N/m/?] n
Sony IMX290 sensor support (VIDEO_IMX290) [N/m/?] n
Sony IMX319 sensor support (VIDEO_IMX319) [N/m/?] n
Sony IMX355 sensor support (VIDEO_IMX355) [N/m/?] n
OmniVision OV2640 sensor support (VIDEO_OV2640) [M/?] m
OmniVision OV2659 sensor support (VIDEO_OV2659) [N/m/?] n
OmniVision OV2680 sensor support (VIDEO_OV2680) [N/m/?] n
OmniVision OV2685 sensor support (VIDEO_OV2685) [N/m/?] n
OmniVision OV2740 sensor support (VIDEO_OV2740) [N/m/?] n
OmniVision OV5647 sensor support (VIDEO_OV5647) [N/m/?] n
OmniVision OV6650 sensor support (VIDEO_OV6650) [N/m/?] n
OmniVision OV5670 sensor support (VIDEO_OV5670) [N/m/?] n
OmniVision OV5675 sensor support (VIDEO_OV5675) [N/m/?] n
OmniVision OV5695 sensor support (VIDEO_OV5695) [N/m/?] n
OmniVision OV7251 sensor support (VIDEO_OV7251) [N/m/?] n
OmniVision OV772x sensor support (VIDEO_OV772X) [N/m/?] n
OmniVision OV7640 sensor support (VIDEO_OV7640) [N/m/?] n
OmniVision OV7670 sensor support (VIDEO_OV7670) [M/?] m
OmniVision OV7740 sensor support (VIDEO_OV7740) [N/m/?] n
OmniVision OV8856 sensor support (VIDEO_OV8856) [N/m/?] n
OmniVision OV9640 sensor support (VIDEO_OV9640) [N/m/?] n
OmniVision OV9650/OV9652 sensor support (VIDEO_OV9650) [N/m/?] n
OmniVision OV13858 sensor support (VIDEO_OV13858) [N/m/?] n
ST VS6624 sensor support (VIDEO_VS6624) [N/m/?] (NEW) n
mt9m001 support (VIDEO_MT9M001) [N/m/?] n
MT9M032 camera sensor support (VIDEO_MT9M032) [N/m/?] n
mt9m111, mt9m112 and mt9m131 support (VIDEO_MT9M111) [N/m/?] n
Aptina MT9P031 support (VIDEO_MT9P031) [N/m/?] n
Aptina MT9T001 support (VIDEO_MT9T001) [N/m/?] n
Aptina MT9T111/MT9T112 support (VIDEO_MT9T112) [N/m/?] n
Micron mt9v011 sensor support (VIDEO_MT9V011) [M/?] m
Micron MT9V032 sensor support (VIDEO_MT9V032) [N/m/?] n
Aptina MT9V111 sensor support (VIDEO_MT9V111) [N/m/?] n
Siliconfile SR030PC30 sensor support (VIDEO_SR030PC30) [M/n/?] m
Siliconfile NOON010PC30 sensor support (VIDEO_NOON010PC30) [M/n/?] m
Fujitsu M-5MOLS 8MP sensor support (VIDEO_M5MOLS) [N/m/?] n
IMI RDACM20 camera support (VIDEO_RDACM20) [N/m/?] n
Sharp RJ54N1CB0C sensor support (VIDEO_RJ54N1) [N/m/?] n
Samsung S5K6AAFX sensor support (VIDEO_S5K6AA) [N/m/?] n
Samsung S5K6A3 sensor support (VIDEO_S5K6A3) [N/m/?] n
Samsung S5K4ECGX sensor support (VIDEO_S5K4ECGX) [N/m/?] n
Samsung S5K5BAF sensor support (VIDEO_S5K5BAF) [N/m/?] n
SMIA++/SMIA sensor support (VIDEO_SMIAPP) [N/m/?] n
ET8EK8 camera sensor support (VIDEO_ET8EK8) [N/m/?] n
Samsung S5C73M3 sensor support (VIDEO_S5C73M3) [N/m/?] n
*
* Support for frame buffer devices
*
Support for frame buffer devices (FB) [Y/m/?] y
  Enable firmware EDID (FIRMWARE_EDID) [Y/n/?] y
  Enable Video Mode Handling Helpers (FB_MODE_HELPERS) [Y/?] y
  Enable Tile Blitting Support (FB_TILEBLITTING) [Y/?] y
  *
  * Frame buffer hardware drivers
  *
  Cirrus Logic support (FB_CIRRUS) [M/n/y/?] m
  Permedia2 support (FB_PM2) [M/n/y/?] m
    enable FIFO disconnect feature (FB_PM2_FIFO_DISCONNECT) [Y/n/?] y
  CyberPro 2000/2010/5000 support (FB_CYBER2000) [M/n/y/?] m
    DDC for CyberPro support (FB_CYBER2000_DDC) [Y/n/?] y
  Arc Monochrome LCD board support (FB_ARC) [M/n/y/?] m
  Asiliant (Chips) 69000 display support (FB_ASILIANT) [N/y/?] n
  IMS Twin Turbo display support (FB_IMSTT) [N/y/?] n
  VGA 16-color graphics support (FB_VGA16) [M/n/y/?] m
  Userspace VESA VGA graphics support (FB_UVESA) [M/n/y/?] m
  VESA VGA graphics support (FB_VESA) [Y/n/?] y
  EFI-based Framebuffer Support (FB_EFI) [Y/n/?] y
  N411 Apollo/Hecuba devkit support (FB_N411) [M/n/y/?] m
  Hercules mono graphics support (FB_HGA) [M/n/y/?] m
  OpenCores VGA/LCD core 2.0 framebuffer support (FB_OPENCORES) [N/m/y/?] n
  Epson S1D13XXX framebuffer support (FB_S1D13XXX) [N/m/y/?] n
  nVidia Framebuffer Support (FB_NVIDIA) [N/m/y/?] (NEW) n
  nVidia Riva support (FB_RIVA) [N/m/y/?] (NEW) n
  Intel740 support (FB_I740) [N/m/y/?] n
  Intel LE80578 (Vermilion) support (FB_LE80578) [M/n/y/?] m
    Intel Carillo Ranch support (FB_CARILLO_RANCH) [M/n/?] m
  Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (FB_INTEL) [N/m/?] n
  Matrox acceleration (FB_MATROX) [M/n/y/?] m
    Millennium I/II support (FB_MATROX_MILLENIUM) [Y/n/?] y
    Mystique support (FB_MATROX_MYSTIQUE) [Y/n/?] y
    G100/G200/G400/G450/G550 support (FB_MATROX_G) [Y/n/?] y
    Matrox I2C support (FB_MATROX_I2C) [M/n/?] m
      G400 second head support (FB_MATROX_MAVEN) [M/n/?] m
  ATI Radeon display support (FB_RADEON) [M/n/y/?] m
    DDC/I2C for ATI Radeon support (FB_RADEON_I2C) [Y/n/?] y
    Support for backlight control (FB_RADEON_BACKLIGHT) [Y/n/?] y
    Lots of debug output from Radeon driver (FB_RADEON_DEBUG) [N/y/?] n
  ATI Rage128 display support (FB_ATY128) [M/n/y/?] m
    Support for backlight control (FB_ATY128_BACKLIGHT) [Y/n/?] y
  ATI Mach64 display support (FB_ATY) [M/n/y/?] m
    Mach64 CT/VT/GT/LT (incl. 3D RAGE) support (FB_ATY_CT) [Y/n/?] y
      Mach64 generic LCD support (FB_ATY_GENERIC_LCD) [N/y/?] n
    Mach64 GX support (FB_ATY_GX) [Y/n/?] y
    Support for backlight control (FB_ATY_BACKLIGHT) [Y/n/?] y
  S3 Trio/Virge support (FB_S3) [M/n/y/?] m
    DDC for S3 support (FB_S3_DDC) [Y/n/?] y
  S3 Savage support (FB_SAVAGE) [M/n/y/?] m
    Enable DDC2 Support (FB_SAVAGE_I2C) [N/y/?] n
    Enable Console Acceleration (FB_SAVAGE_ACCEL) [N/y/?] n
  SiS/XGI display support (FB_SIS) [M/n/y/?] m
    SiS 300 series support (FB_SIS_300) [Y/n/?] y
    SiS 315/330/340 series and XGI support (FB_SIS_315) [Y/n/?] y
  VIA UniChrome (Pro) and Chrome9 display support (FB_VIA) [M/n/y/?] m
    direct hardware access via procfs (DEPRECATED)(DANGEROUS) (FB_VIA_DIRECT_PROCFS) [N/y/?] n
    X server compatibility (FB_VIA_X_COMPATIBILITY) [Y/n/?] y
  NeoMagic display support (FB_NEOMAGIC) [M/n/y/?] m
  IMG Kyro support (FB_KYRO) [M/n/y/?] m
  3Dfx Banshee/Voodoo3/Voodoo5 display support (FB_3DFX) [M/n/y/?] m
    3Dfx Acceleration functions (FB_3DFX_ACCEL) [N/y/?] n
    Enable DDC/I2C support (FB_3DFX_I2C) [Y/n/?] y
  3Dfx Voodoo Graphics (sst1) support (FB_VOODOO1) [M/n/y/?] m
  VIA VT8623 support (FB_VT8623) [M/n/y/?] m
  Trident/CyberXXX/CyberBlade support (FB_TRIDENT) [M/n/y/?] m
  ARK 2000PV support (FB_ARK) [M/n/y/?] m
  Permedia3 support (FB_PM3) [M/n/y/?] m
  Fujitsu carmine frame buffer support (FB_CARMINE) [N/m/y/?] n
  SMSC UFX6000/7000 USB Framebuffer support (FB_SMSCUFX) [M/n/?] m
  Displaylink USB Framebuffer support (FB_UDL) [M/n/?] m
  Framebuffer support for IBM GXT4000P/4500P/6000P/6500P adaptors (FB_IBM_GXT4500) [N/m/y/?] n
  Virtual Frame Buffer support (ONLY FOR TESTING!) (FB_VIRTUAL) [M/n/y/?] m
  Xen virtual frame buffer support (XEN_FBDEV_FRONTEND) [Y/n/m/?] y
  E-Ink Metronome/8track controller support (FB_METRONOME) [N/m/y/?] n
  Fujitsu MB862xx GDC support (FB_MB862XX) [M/n/y/?] m
    GDC variant
    > 1. Carmine/Coral-P(A) GDC (FB_MB862XX_PCI_GDC)
    choice[1]: 1
    Support I2C bus on MB862XX GDC (FB_MB862XX_I2C) [Y/n/?] y
  Microsoft Hyper-V Synthetic Video support (FB_HYPERV) [M/n/?] m
  Simple framebuffer support (FB_SIMPLE) [N/y/?] n
  Silicon Motion SM712 framebuffer support (FB_SM712) [N/m/y/?] n
*
* Android
*
Enable the Anonymous Shared Memory Subsystem (ASHMEM) [N/y/?] (NEW) n
*
* Android
*
Android Drivers (ANDROID) [Y/n/?] y
  Android Binder IPC Driver (ANDROID_BINDER_IPC) [N/y/?] (NEW) n
*
* DOS/FAT/EXFAT/NT Filesystems
*
MSDOS fs support (MSDOS_FS) [M/n/y/?] m
VFAT (Windows-95) fs support (VFAT_FS) [M/n/y/?] m
  Default codepage for FAT (FAT_DEFAULT_CODEPAGE) [437] 437
  Default iocharset for FAT (FAT_DEFAULT_IOCHARSET) [ascii] ascii
  Enable FAT UTF-8 option by default (FAT_DEFAULT_UTF8) [Y/n/?] y
exFAT filesystem support (EXFAT_FS) [M/n/y/?] m
  Default iocharset for exFAT (EXFAT_DEFAULT_IOCHARSET) [utf8] utf8
NTFS file system support (NTFS_FS) [N/m/y/?] (NEW) n
#
# configuration written to .config
#
make: Leaving directory '/home/user/Downloads/usb/linux-5.9.9'
==> Applying CSR dongle fix
patching file drivers/bluetooth/btusb.c
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file drivers/bluetooth/btusb.c.rej
patching file include/net/bluetooth/bluetooth.h
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file include/net/bluetooth/bluetooth.h.rej
patching file include/net/bluetooth/hci.h
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file include/net/bluetooth/hci.h.rej
patching file net/bluetooth/hci_core.c
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file net/bluetooth/hci_core.c.rej

Any clue?

@phlbrz

This comment has been minimized.

Copy link

@phlbrz phlbrz commented Dec 1, 2020

Yeah, it's included already, no need to patch kernel 5.9.9 - Linux Machine 5.9.0-3-amd64 #1 SMP Debian 5.9.9-1 (2020-11-19) x86_64 GNU/Linux
I had a look at source code and it's applied, but, for me, it's not working yet.
If I use only for listening, it works.
I have to use just one ear bud.
If I pair both ear buds it stops working and don't show me error in sudo btmon, or I couldn't find.

  • btmon
btmon
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                       #713 [hci0] 1080.881629
        Status: Success (0x00)
        Handle: 0
        Reason: Connection Terminated By Local Host (0x16)
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                       #714 [hci0] 1080.882621
        Status: Success (0x00)
        Handle: 48
        Reason: Connection Terminated By Local Host (0x16)

  • hcidump
> HCI Event: Connect Complete (0x03) plen 11
    status 0x04 handle 0 bdaddr FF:FF:FF:FF:FF:FF type ACL encrypt 0x00
    Error: Page Timeout
> HCI Event: Extended Inquiry Result (0x2f) plen 255
    bdaddr 20:06:12:10:A9:BD mode 0 clkoffset 0x8349 class 0x240404 rssi -53
    Complete local name: 'Mpow M9'

  • dmesg
dmesg | grep Blue
[ 1204.318177] Bluetooth: hci0: command 0x041f tx timeout
[ 1206.334081] Bluetooth: hci0: command 0x0406 tx timeout
[94549.483072] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds...
[94663.370221] Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds...

My mic not working yet with this dongle.

@Swyter

This comment has been minimized.

Copy link

@Swyter Swyter commented Dec 1, 2020

Hi, I'm the patch author. Please take a look at my previous comments in this thread:
https://gist.github.com/nevack/6b36b82d715dc025163d9e9124840a07#gistcomment-3456854

The patch is mainlined, but it was just a first step to get a bunch of these clones recognized and not a final solution. Unfortunately I've been busy since then and I'll probably won't be able to track this problem down and upstream the fix in a while.

So I recommend other people to give it a go and at least track down the Linux 5.7 regression. You won't see any fixes from official companies, Qualcomm is not interested in counterfeit dongles from what originally were CSR-branded chips that don't work that well with BlueZ.

The trick here is to find out what is Linux doing wrong here protocol-wise when on Windows they work normally.

@phlbrz

This comment has been minimized.

Copy link

@phlbrz phlbrz commented Dec 1, 2020

Thank you Swyter, I appreciate your work!
I'm don't know how to debug yet, if you have some clue how to start I can try to help more.

@phlbrz

This comment has been minimized.

Copy link

@phlbrz phlbrz commented Dec 1, 2020

Some info about BlueZ 5 support (A2DP only)

https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/5.0/

Dropped HSP HFP support:

The support for BlueZ 5 has been gradually added in various applications, and this is the first PulseAudio version that supports BlueZ 5. This means that everything is great, right? Not so. The BlueZ project also decided to drop support for the HSP and HFP profiles, which were the profiles responsible for handling telephony audio. If you have a headset, its microphone won't work with BlueZ 5, because the microphone is only supported by the HSP and HFP profiles.

There are distributions that have migrated to BlueZ 5 without providing users the alternative of staying with BlueZ 4. Some of those distributions probably made the transition without understanding the consequences - they now have a serious regression in functionality, because their users' Bluetooth headsets have stopped working (well, the headsets can still be used for listening to music, but they're useless for VoIP applications).

GNOME made also a decision, possibly misinformed one, to drop support for BlueZ 4 in their last release, which means that upgrading to the current GNOME version (3.10) has one of two problems depending on the BlueZ version in the system: with BlueZ 4, the GNOME UI for managing Bluetooth won't work, and with BlueZ 5 the headset audio functionality will be crippled.

So what's the way forward with getting the HSP and HFP profiles work with BlueZ 5? There is partial support for those in oFono (a telephony daemon), which will hopefully be completed soon, and the next PulseAudio release will then hopefully support HSP/HFP through oFono. This pulls in a telephony stack as a dependency for using your Bluetooth headset, which might be considered overkill. This issue is yet to be resolved with the BlueZ developers.

So, or I try again (downgrade kernel / debian is not possible, so I need to reinstall everything) or wait.

@serlou

This comment has been minimized.

Copy link

@serlou serlou commented Dec 2, 2020

I was in ubuntu 20.04. After updating to 20.10 and manually updating the kernel to the 5.8.3, I could run the script :-)
However, fails when trying to use

sudo mkinitcpio -p linux

Which is the alternative to this line on Ubuntu?
Thank you very much!

@nevack

This comment has been minimized.

Copy link
Owner Author

@nevack nevack commented Dec 2, 2020

I was in ubuntu 20.04. After updating to 20.10 and manually updating the kernel to the 5.8.3, I could run the script :-)
However, fails when trying to use

sudo mkinitcpio -p linux

Which is the alternative to this line on Ubuntu?
Thank you very much!

maybe update-initramfs -u ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.