voodik / android_kernel_voodik_odroidg12

Other
1 stars 0 forks source link

driver:bluetooth:btrtl: Backport support for RTL8761BU? #1

Closed multiple1 closed 1 year ago

multiple1 commented 1 year ago

Hello! I wanted to use the RTL8761BU on your [ROM][LineageOS 20.0][Android 13][voodik] for the ODROID-N2/N2L image.

But sadly this image uses the old 4.* Kernel which does not support this chip.

CoreELEC19 did a simple backport to support this chip, e.g. my usb dongle works with coreelec19: https://github.com/CoreELEC/linux-amlogic/commit/30c6f28ea5cb497daa11fab92d6ec7d3bca8d33c The matching firmware must be also installed into the /lib/firmware folder https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rtl_bt

This are the official RTL8761* support patches (supported since v5.8). See also rtl8761bu_fw (USB mode) vs rtl8761b_fw (UART mode) https://github.com/torvalds/linux/commit/04896832c94aae4842100cafb8d3a73e1bed3a45 https://github.com/torvalds/linux/commit/9fd2e2949b43dea869f7fce0f8f51df44f635d59

CoreELEC20 uses the newer Kernel which supports the chip out of the box: https://github.com/CoreELEC/CoreELEC/blob/coreelec-20/packages/linux/package.mk

voodik commented 1 year ago

I add Backport for RTL8761B/RTL8761BU https://github.com/voodik/android_kernel_voodik_odroidg12/commit/d78677a96d50d1a3b84758b3412646c77065bdea

Here is test image with this backport https://drive.google.com/file/d/11u160FC3mlbLns-u8X_XcJkVwgnkRN2M/view?usp=sharing

You can put rtl8761bu_fw.bin and rtl8761bu_config.bin to /odm/etc/firmware/rtl_bt folder.

No plans for now for newer kernel.

multiple1 commented 1 year ago

Thank you! What kind of image is this? The other images from you are self-install images. May I ask how to install this image, because it is not a single img file?

voodik commented 1 year ago

Install Lineage-20.0 with latest selfinstall image https://oph.mdrjr.net/voodik/S922X/ODROID-N2/Android/LineageOTA-20.0/builds/selfinstall/

Then put this update to internal storage of your Odroid and update via Odroid Settings https://youtu.be/QwJNYuDVat4

multiple1 commented 1 year ago

After adding the firmware binaries, the bluetooth dongle shows up in the android settings. I can pair bluetooth le devices e.g. Logitech MX Master 2s and also some bluetooth remotes. But sadly any paired input device does not show any reactions. It also looks like the devices are connected after pairing, but still no actions.

Already tries the Realtek Fixes in Odroid settings + reboot => no change

[  827.997825] usb 1-1.2: new full-speed USB device number 6 using xhci-hcd
[  828.135115] Bluetooth: RealTek module detected
[  828.137062] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761
[  828.138041] Bluetooth: hci0: RTL: rom_version status=0 version=1
[  828.138051] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_fw.bin
[  828.138367] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_config.bin
[  828.138541] Bluetooth: hci0: RTL: cfg_sz 6, total sz 27814
[  828.278035] Bluetooth: hci0: RTL: fw version 0x09a98a6b
[  828.342947] binder: 3128:3128 transaction failed 29189/-22, size 60-0 line 3094
[  828.343254] binder: 3128:3128 transaction failed 29189/0, size 4-0 line 3026
[  828.343262] binder: send failed reply for transaction 20859, target dead
[  828.344595] binder: 3128:3128 transaction failed 29189/0, size 204-40 line 3026
[  828.344603] binder: send failed reply for transaction 29267, target dead
voodik commented 1 year ago

Try to Find another firmware, maybe older. In case of RTL8821CU which uses same driver only old/first firmware work.

multiple1 commented 1 year ago

ok, I took the newest firmware file. Now I will try older firmware versions: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/log/rtl_bt

But i don't see any errors in dmesg.

Other people also having still issues? https://forum.odroid.com/viewtopic.php?p=362075#p362075

multiple1 commented 1 year ago

All firmware binaries showed same behavior. => Should I try [ROM][LineageOS 19.1][Android 12.1][voodik] for the ODROID-N2 But i would also need an image with the kernel patch for the rtl8761 support

voodik commented 1 year ago

Other people also having still issues? https://forum.odroid.com/viewtopic.php?p=362075#p362075

This is other issue, there cannot pair.

From developer options enable Bluetooth HCI snoop log. remove all paired devices, reboot odroid then try to pair and after make some mouse moves and clicks, then adb pull /data/misc/bluetooth/logs/btsnoop_hci.log

and attach it here

multiple1 commented 1 year ago

some random china bt remote btsnoop_hci.log

mx master 2s btsnoop_hci.log

voodik commented 1 year ago

Your adapter is using LE EXTENDED features, i don't have any adapter with this features supported. So lets try to disable LE Extended support and use standard features.

Patched lib. https://drive.google.com/open?id=12WNNXkpQ4uzW3I7yDVnVvf-a8e9CbSTE&authuser=voodik.am%40gmail.com&usp=drive_fs

unpair all then

adb remount
adb push libbluetooth_jni.so /system/apex/com.android.btservices/lib64/
adb reboot

pair and check

multiple1 commented 1 year ago

I had time to test, but sadly it did not change anything. I made sure that the lib is changed after the reboot:

odroidn2:/system/apex/com.android.btservices/lib64 # md5sum libbluetooth_jni.so
5a5d5cbd3bf058cee2709f559d543361  libbluetooth_jni.so

Pairing still works, device shows up unter "Connected Devices | Other devices". But no input is recognized. So maybe it is an Android issue? Should I try an older release? Do you also have a e.g. lineage-19.1 image with the patched RTL8761 kernel?

voodik commented 1 year ago

Here is Lineage-19.1 with backport https://drive.google.com/open?id=12aRwyAOEuhDvyBk2V5_YwzUW_NSF_wG0&authuser=voodik.am%40gmail.com&usp=drive_fs

Some debug info may be helpful

incrase logcat buffer size and reboot

setprop persist.logd.size 8388608
reboot

list input devices getevent -lp

listen input events (make some mouse moves and clicks) getevent -l

dump logcat and dmesg logcat -d > /sdcard/logcat.txt dmesg > /sdcard/dmesg.txt

multiple1 commented 1 year ago

Here is Lineage-19.1 with backport

=> bluetooth remote is successfully connected and input works

getevent -lp

no bluetooth input device shows up with the v20 image

Some debug info may be helpful

I will try to collect more info with the v20 image when there is some time left.

For now I am fine with the v19 image. Could you also offer the patched kernel for the v19 Android TV image? :)

voodik commented 1 year ago

Here is patched ATV 19.1 https://drive.google.com/file/d/1_6Ky7kDe39JYuvcx1NtODHptKkqfwM3k/view?usp=share_link