Jump to content

Finally.... got Bluetooth working on Pine64 H64 model-B


__Dirk__

Recommended Posts

All,

 

Don´t know if anybody else did it... but I got Bluetooth running by modifying the device tree and adding support for communication between the RTL8723BS and UART1 and loading the needed RTL8723B firmware.

 

Distro: Armbian Buster

Kernel version: 5.4.30-sunxi64 

 

This is how I did it:

 

1) Create a patch (xx.patch) with the next content and place it in  ~/build/userpatches/kernel/sunxi-current/

 

--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts    2020-04-06 12:37:45.584912094 +0200
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts    2020-04-06 12:37:45.584912094 +0200
@@ -498,6 +498,21 @@
     status = "okay";
 };
 
+/* On Wifi/BT connector, with RTS/CTS */
+&uart1 {
+    pinctrl-names = "default";
+    pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
+    status = "okay";
+
+    bluetooth {
+        compatible = "realtek,rtl8723bs-bt";
+        device-wake-gpios = <&r_pio 1 1 GPIO_ACTIVE_HIGH>; /* PM1 */
+        host-wake-gpios = <&r_pio 1 2 GPIO_ACTIVE_HIGH>; /* PM2 */
+        reset-gpios = <&r_pio 1 4 GPIO_ACTIVE_LOW>; /* PM4 */
+        post-power-on-delay-ms = <200>;
+    };
+};
+
 &usb2otg {
     dr_mode = "host";
     status = "okay";

 

2) Run sudo ./compile with your favorite  config (Desktop/server/blablabla)

3) Flash the image to an SD card or eMMC module.

4) Start your Pine64 H64 model-B

4) Connect to a network and run the firmware update/upgrades (armbian-config) and install the Bluetooth tools.

5) DO NOT ENABLE SERIAL 1 !!!! in armbian-config

6) Download the next git repo to your board:  https://github.com/lwfinger/rtl8723bs_bt.git

7) Unpack the archive, run make

8) Copy the next firmware files to /lib/firmwares/rtl_bt:

  1.   sudo cp rtlbt_fw_new /lib/firmware/rtl_bt/rtl8723bs_fw.bin
  2. sudo cp rtlbt_config /lib/firmware/rtl_bt/rtl8723bs_config.bin

9) Reboot

 

Expected dmesg output:

 

[   45.107273] Bluetooth: HCI UART driver ver 2.3
[   45.107279] Bluetooth: HCI UART protocol H4 registered
[   45.107281] Bluetooth: HCI UART protocol BCSP registered
[   45.107329] Bluetooth: HCI UART protocol LL registered
[   45.107331] Bluetooth: HCI UART protocol ATH3K registered
[   45.107375] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   45.107509] Bluetooth: HCI UART protocol Intel registered
[   45.107592] Bluetooth: HCI UART protocol Broadcom registered
[   45.107614] Bluetooth: HCI UART protocol QCA registered
[   45.107616] Bluetooth: HCI UART protocol AG6XX registered
[   45.107642] Bluetooth: HCI UART protocol Marvell registered

[   45.845446] Bluetooth: hci0: RTL: examining hci_ver=06 hci_rev=000b lmp_ver=06 lmp_subver=8723
[   45.849521] Bluetooth: hci0: RTL: rom_version status=0 version=1
[   45.849529] Bluetooth: hci0: RTL: loading rtl_bt/rtl8723bs_fw.bin
[   46.055000] Bluetooth: hci0: RTL: loading rtl_bt/rtl8723bs_config.bin

[   46.096579] Bluetooth: hci0: RTL: cfg_sz 55, total sz 23699

 

[   46.929071] Bluetooth: hci0: RTL: fw version 0x373e6962

 

 

'hciconfig list' output:

 

hci0:    Type: Primary  Bus: UART
    BD Address: 48:46:C1:3A:6B:5F  ACL MTU: 820:8  SCO MTU: 255:16
    UP RUNNING PSCAN ISCAN 
    RX bytes:1982677 acl:3028 sco:0 events:491 errors:0
    TX bytes:91688 acl:232 sco:0 commands:225 errors:0

 

File transfer from Pine to Samsung is working... haven't tested anything else..

 

Regards,

 

__Dirk__ 

Pine64_H64_model-b_running_bluetooth.jpg

Link to comment
Share on other sites

On the A64+ with the official WiFi/BT card, I'm seeing this:

 

ruce@pine64:~$ hciconfig list
hci0:    Type: Primary  Bus: UART
    BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
    DOWN 
    RX bytes:151 acl:0 sco:0 events:4 errors:0
    TX bytes:130 acl:0 sco:0 commands:4 errors:0

bruce@pine64:~$ 
 

I'm probably not as Debian-literate as I should be, but doesn't that mean the bluetooth device is already present in the official build I downloaded from the armbian website?  I'm running buster 5.4.28 and nothing else seems to be able to find the bluetooth device.

 

BTW, I'm an experienced software developer but not strong on Linux internals, so your patience is appreciated.

 

Link to comment
Share on other sites

37 minutes ago, ko4xl said:

On the A64+ with the official WiFi/BT card, I'm seeing this:


Pine H64 has different SoC and different (kernel) configuration. Sometimes even different wireless chip (version / revision) which is enough to complicate things ... :)

Link to comment
Share on other sites

On 4/25/2020 at 5:01 PM, Igor said:


Pine H64 has different SoC and different (kernel) configuration. Sometimes even different wireless chip (version / revision) which is enough to complicate things ... :)

The A64+ add-on module for WiFi and BT has the same RTL8723BS chip with the BT connected via UART1, just like the H64.  I can see where the kernel configuration would be different in other respects due to the SoC differences, but wouldn't the bluetooth driver be essentially the same?  Installing BT support using armbian-config gave me bluez and its utilities, so I'm thinking all that's missing is the actual driver.  Instead of rebuilding the kernel, I wonder if the drivers could be built as a module (using the correct kernel headers of course) and loaded during startup?  That's how I've seen this chip added to raspbian on a pi 0,1 or 2.

Link to comment
Share on other sites

1 minute ago, ko4xl said:

but wouldn't the bluetooth driver be essentially the same?


All those bluetooth dongles has some hacky way of firmware loading ... this is usually the problem. Not sure how this is here since I haven't dug in yet.

 

2 minutes ago, ko4xl said:

I wonder if the drivers could be built as a module


You can build a module separate, but IHMO this is not needed in this case. Probably its just a problem of seting proper UART paramters with proper firmware loading mechanism like 

https://github.com/armbian/build/blob/master/packages/bsp/lime-a64/lime-a64-bluetooth.service

Link to comment
Share on other sites

On 4/27/2020 at 4:36 PM, Igor said:


All those bluetooth dongles has some hacky way of firmware loading ... this is usually the problem. Not sure how this is here since I haven't dug in yet.

 


You can build a module separate, but IHMO this is not needed in this case. Probably its just a problem of seting proper UART paramters with proper firmware loading mechanism like 

https://github.com/armbian/build/blob/master/packages/bsp/lime-a64/lime-a64-bluetooth.service

As I said previously, I am not a kernel expert.  Where would those configuration lines go?

 

Also, there is no /dev entry for ttyS1 even though the hardware obviously exists.  Could that be indicative of an additional issue with the 5.4.28 build?

 

Link to comment
Share on other sites

5 hours ago, ko4xl said:

As I said previously, I am not a kernel expert.  Where would those configuration lines go?

 

I don't know much without research.

 

5 hours ago, ko4xl said:

Also, there is no /dev entry for ttyS1 even though the hardware obviously exists.


By default, only minimum of board functions are enabled. Only ttyS0 since its used for serial console, ttyS1 if someone sorted out BT that is attached there, USB ports that are actually wired on particular board, audio if wired ... etc. 

 

5 hours ago, ko4xl said:

Could that be indicative of an additional issue with the 5.4.28 build?


No. Kernel is a work of thousands of people - we don't accept kernel bugs since even filing them is a job we can't afford - this is amateur backed project. We listen to you and choose what we think is generally important and possible to fix in a time we have. Sorting out bluetooth generally is a task that is postponed and postponed ... sometimes users fix it on their own, but if they don't push the fix upstream ... we can't catch and integrate everything that community produces on the way and forget to implement.

Link to comment
Share on other sites

1 hour ago, Igor said:

sometimes users fix it on their own, but if they don't push the fix upstream

 

I cannot push anything for the H64 board device tree as the H64 model-B uses the model-A dts with some modifications. 

 

I asked for a model-B specific device file but got no answer.

 

April 7

@martinayotte

 

Can the Pine64 H64 model-b get it's own device tree in the repo ?

 

At the moment it includes the model-a and does some small changes on the model-a device tree. 

 

Regards,

 

__Dirk__

 

Link to comment
Share on other sites

24 minutes ago, __Dirk__ said:

Can the Pine64 H64 model-b get it's own device tree in the repo ?

 

If your rework is consistent with the way mainstream is going, I support, if we go away from that ... we need to have a good reason. 


Perhaps adding UART1 bits to this patch:

https://github.com/armbian/build/blob/master/patch/kernel/sunxi-current/xxx-pineh64-model-b.patch#L51-L73

should IMO do (and the same for DEV branch)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines