RTL8723BS Bluetooth


Raffa
 Share

1 1

Recommended Posts

If someone is interested I found the way to have BT working on orange pi Prime.

 

Unfortunately default kernel config is missing the following options and need to be manually recompiled:

 

CONFIG_SERIAL_DEV_BUS=m
CONFIG_BT_HCIUART_SERDEV=y
CONFIG_BT_HCIUART_3WIRE=y

 

With these changes and adding "uart1" to the overlays in armbianEnv.txt  it's possible to use the driver in:

 

https://github.com/lwfinger/rtl8723bs_bt.git

 

and start manually with:

 

./rtk_hciattach -n -s 115200 /dev/ttyS1 rtk_h5

 

to have bluetooth working.

 

Alternatively it's possible to use a modified driver and some startup scripts originally developed by NextThings C.H.I.P.  that i have modified to run on Orange pi Prime board.

 

https://www.dropbox.com/s/swv2ylw6lnhljxk/rtl8723bs_bt.tar.gz?dl=0

 

 What about to add these kernel options to default next sunxi64  kernel config ?

 

Link to post
Share on other sites

Armbian is a community driven open source project. Do you like to contribute your code?

2 hours ago, vlad59 said:

then rtk_hciattach fail after 99 tries.

 

For the Tinker Board myself, @Myy, and someone else on GitHub (bad memory) worked out a user-space solution to toggle the reset line on the module.  This is the issue you are experiencing, if I had to guess, that the Bluetooth is not reset on boot.  

Link to post
Share on other sites

It's in our build system, I'll post links after bit, I simplified somewhat.  You'll need to find your gpio's that correspond to the ones used on tinker

 

https://github.com/armbian/build/blob/master/packages/bsp/rockchip/start_bt.sh

https://github.com/armbian/build/blob/master/packages/bsp/rockchip/tinker-bluetooth.service

PineA64 has those GPIO's here:

 

image.png.2eb539ccdaa359d8c3df0f980b2a9242.png

 

Link to post
Share on other sites

On 12/14/2018 at 1:54 PM, vlad59 said:

@Raffa

As I said your method works fine on my Pine64 but only after the first poweron -> if I reboot (typing reboot on the console) then rtk_hciattach fail after 99 tries.

 

Do you have the same problem with your Orange Pi Prime ?

 

Yes as I said on the first post I use the scripts originally developed for C.H.I.P. board with the reset pin changed:

 

Quote

 

#!/bin/sh

BT_RST_N=80

 

failed () {

        status=$2

 

        echo ${1}

        echo ${BT_RST_N} > /sys/class/gpio/unexport

        exit ${status}

}

 

# Make sure this is a Crumb

[ "$(cat /proc/device-tree/model)" = "Xunlong Orange Pi Prime" -o \

  "$(cat /proc/device-tree/model)" = "Xunlong Orange Pi Prime" ] || \

        failed "This is not a Crumb ... exiting" $?

 

# Make the BT_RST_N GPIO available to userspace

if [ ! -e /sys/class/gpio/gpio${BT_RST_N} ]; then

        echo ${BT_RST_N} > /sys/class/gpio/export || \

                failed "Failed to export BT_RST_N" $?

fi

 

# Set BT_RST_N to be an output

echo out > /sys/class/gpio/gpio${BT_RST_N}/direction || \

        failed "Failed to set BT_RST_N direction = out" $?

 

# Toggle BT_RST_N to reset Bluetooth

{

        echo 1 > /sys/class/gpio/gpio${BT_RST_N}/value;

        sleep 0.1;

        echo 0 > /sys/class/gpio/gpio${BT_RST_N}/value;

        sleep 0.1;

        echo 1 > /sys/class/gpio/gpio${BT_RST_N}/value;

} || failed "Failed to toggle Bluetooth reset" $?

 

# Cleanup BT_RST_N direction and unexport it

echo in > /sys/class/gpio/gpio${BT_RST_N}/direction || \

        failed "Failed to set BT_RST_N direction = in" $?

 

echo ${BT_RST_N} > /sys/class/gpio/unexport || \

        failed "Failed to unexport BT_RST_N" $?

 

echo "Bluetooth reset successfully!"

 

 

 

 

The script use GPIO to generate a reset pulse on the line and it is necessary if you try to reconfigure the bluetooth module after each initial configuration.

 

Link to post
Share on other sites

I can confirm that running theses lines make bluetooth work even after a reboot :

 

root@pine64:~# echo 356 > /sys/class/gpio/export
root@pine64:~# echo high > /sys/class/gpio/gpio356/direction
root@pine64:~# echo 0 > /sys/class/gpio/gpio356/value && sleep 1
root@pine64:~# echo 1 > /sys/class/gpio/gpio356/value

I'll clean that up and do a PR

Link to post
Share on other sites

Guest
This topic is now closed to further replies.
 Share

1 1