ubuntu18.04 rtl8761a bluetooth driver
?最近想給我的臺式機上加個藍牙適配器,藍牙5.0那種,支持BLE設備,這樣我就可以基于我的手環以及手機之類的BLE設備做一些東西玩玩。不幸的是,藍牙適配器買回來后沒法驅動,dmesg | tail -f 可以看到加載/lib/firmware/rtl_bt/下面的firmware失敗了,我進目錄看了下,并沒有現成的firmware。Google了一下,在linux git repo中找到了需要的文件,然后就是下載解壓復制,重新插拔usb藍牙適配器,提示加載firmware成功了,hciconfig -a也可以看到hci0設備了,但是執行部分指令的時候失敗,blueman也無法操作藍牙適配器。
藍牙適配器型號是:
uGreen Bluetooth 5.0 USB Adapter CM390
(base) ? ~ dmesg | tail -f [ 406.634801] usb 1-12.4.2: Product: Bluetooth Radio [ 406.634802] usb 1-12.4.2: Manufacturer: Realtek [ 406.634803] usb 1-12.4.2: SerialNumber: 00E04C239987 [ 406.646215] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761 [ 406.647209] Bluetooth: hci0: RTL: rom_version status=0 version=1 [ 406.647212] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761a_fw.bin [ 406.647312] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761a_config.bin [ 406.647339] Bluetooth: hci0: RTL: cfg_sz 44, total sz 14808 [ 408.725601] Bluetooth: hci0: command 0xfc20 tx timeout [ 416.789322] Bluetooth: hci0: RTL: download fw command failed (-110) (base) ? ~ hciconfig -a hci0: Type: Primary Bus: USBBD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0DOWN RX bytes:427 acl:0 sco:0 events:60 errors:0TX bytes:15050 acl:0 sco:0 commands:61 errors:0Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00Packet type: DM1 DH1 HV1 Link policy: Link mode: SLAVE ACCEPT雖然log中顯示的型號是rtl8761a,但是不知道識別得是否正確,這個型號信息有可能不是它的真實型號。網上查不到關于這個cm390的更多的芯片信息。
百般查找,發現這個藍牙適配器芯片的型號為:rtl8761buv!!!
嘗試了一種取巧的辦法,就是將找到的rtl8761bu的firmware改名,改成rtl8761a,但是加載的時候報錯“unknow project id 14”,使用hcitool操作的時候也報錯,顯然這種辦法也是不行的。
[ 1185.809177] Bluetooth: hci0: RTL: rom_version status=0 version=1 [ 1185.809197] Bluetooth: hci0: RTL: rtl: loading rtl_bt/rtl8761a_fw.bin [ 1185.809911] Bluetooth: hci0: RTL: rtl: loading rtl_bt/rtl8761a_config.bin [ 1185.810051] Bluetooth: hci0: RTL: unknown project id 14 [ 1186.430001] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 1186.430016] Bluetooth: BNEP filters: protocol multicast [ 1186.430046] Bluetooth: BNEP socket layer initialized“hci0: RTL: unknown project id 14”所以,log中顯示出來加載rtl8761a的firmware明顯是不對的。之所以識別不正確,從網上可以查到的信息來看,是因為kernel的驅動btusb.c中有bug,需要修改后重新編譯安裝。
接下來下載我的kernel版本對應的源碼。
uname -a 5.4.0-80-generic #90~18.04.1-Ubuntu git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.gitcheckout與我的內核版本一致的tag,然后主要參照下面兩篇文章,問題搞定。
https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btrtl.c
https://gist.github.com/rometsch/dfd24fb09c85c1ad2f25223dc1481aaa
在第二個地址中,它解決的是rtl8761b芯片的驅動,直接照著改還是不行的,因為我的芯片是rtl8761bu,所以將firmware改正確就好了,然后編譯,替換,重啟,藍牙適配器插上
(base) ? ~ dmesg|grep "Bluetooth"[ 43.647082] usb 1-12.4.2: Product: Bluetooth Radio [ 43.677827] Bluetooth: Core ver 2.22 [ 43.677845] Bluetooth: HCI device and connection manager initialized [ 43.677847] Bluetooth: HCI socket layer initialized [ 43.677848] Bluetooth: L2CAP socket layer initialized [ 43.677849] Bluetooth: SCO socket layer initialized [ 43.685124] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761 [ 43.686127] Bluetooth: hci0: RTL: rom_version status=0 version=1 [ 43.686128] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_fw.bin [ 43.686487] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_config.bin [ 43.686560] Bluetooth: hci0: RTL: cfg_sz 6, total sz 20522 [ 43.721049] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 43.721050] Bluetooth: BNEP filters: protocol multicast [ 43.721052] Bluetooth: BNEP socket layer initialized [ 43.797228] Bluetooth: hci0: RTL: fw version 0x0999646b [ 43.869262] Bluetooth: RFCOMM TTY layer initialized [ 43.869267] Bluetooth: RFCOMM socket layer initialized [ 43.869269] Bluetooth: RFCOMM ver 1.11 [ 1202.463538] Bluetooth: hci0: hardware error 0x33可以看到藍牙適配器正常驅動起來了,使用Bluetooth Manager程序搜索一下,成功發現N多藍牙設備,試了一下與我的手環鏈接,都是正常的。到此結束。
總結
以上是生活随笔為你收集整理的ubuntu18.04 rtl8761a bluetooth driver的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ACM CPC2017 Naning
- 下一篇: ORA-00313 ORA-00312