2 2
data

OrangePi Lite2 & 3 Bluetooth

Recommended Posts

hciattach is not necessary, the kernel does that automatically if configured like this:

 

https://megous.com/git/linux/commit/?h=opi3-5.2&id=0c27ac4b4586bc2c0dded85b5bf82f78531d01c3

 

Sorry, I don't have guide to make BT work, because there's shouldn't be much to configure. All you need is a kernel with the support and then you just need to configure BT address (btmgmt public-addr) for your device. Kernel part is something armbian should figure out.

 

Share this post


Link to post
Share on other sites

Also without kernel's H6 RTC patches, you'll not make this work, because BT will not have clock enabled.

Share this post


Link to post
Share on other sites

Do you know if these patches are included in the current lite2 built?

Share this post


Link to post
Share on other sites
15 hours ago, megi said:

hciattach is not necessary, the kernel does that automatically if configured like this:

 

 

Allright, so I just wait for 5.2 Kernel and hope for the best. Thanks for your answer though!

 

And even if it did not work, it was kinda fun to try to figure out how that works. Even though everything with drivers (firmware) is still insane complicated on Linux :)

Share this post


Link to post
Share on other sites
On 5/27/2019 at 8:37 PM, data said:

Do you know if these patches are included in the current lite2 built?

I don't see them in armbian. Anyway, I only have Opi 3 working, and lite2 may have a different bluetooth chip.

Share this post


Link to post
Share on other sites
On 5/30/2019 at 3:50 AM, megi said:

I don't see them in armbian. Anyway, I only have Opi 3 working, and lite2 may have a different bluetooth chip.

If I convert DTB to DTS (and back) and add this:

 

/* There's the BT part of the AP6256 connected to that UART */ &uart1 { pinctrl-names = "default"; pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>; uart-has-rtscts; status = "okay"; bluetooth { compatible = "brcm,bcm4345c5"; clocks = <&rtc 1>; clock-names = "lpo"; device-wakeup-gpios = <&r_pio 1 2 GPIO_ACTIVE_HIGH>; /* PM2 */ host-wakeup-gpios = <&r_pio 1 1 GPIO_ACTIVE_HIGH>; /* PM1 */ shutdown-gpios = <&r_pio 1 4 GPIO_ACTIVE_HIGH>; /* PM4 */ max-speed = <1500000>; }; };

 

And copy https://github.com/orangepi-xunlong/OrangePiH6_external/tree/master/ap6256 to:

/lib/firmware/brcm/(BCM4345C5.hcd)

 

Am I correct that it will it work then? (I'm using a OPi3)

Share this post


Link to post
Share on other sites

Seems i found some workaround for OPi Lite2 board under  latest armbian image for OPi lite2 (Linux orangepilite2 5.2.5-sunxi64 #5.92).

 

uart1 is configured properly by board DTB (no loaded uart1 overlay!) but bt chip on ttyS1 not answered.

 

Board schematics (OrangePi_Lite2_Schematics_v2.0.pdf) is strange: BT-RST-N pulled up to vcc (R139 on schematics) and pulled down to GND (R147).

 

After boot pin PM4 (BT-REG-ON -> BT-RST-N) is unclaimed and seems BT-RST-N actually has low level.

cat /sys/kernel/debug/pinctrl/*/pinmux-pins

pin 388 (PM4): UNCLAIMED

 

1. Try pull up this pin:

echo 388 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio388/direction
echo 1 >/sys/class/gpio/gpio388/value
 

2. load hci_uart module and do attach to uart1:

modprobe hci_uart

hciattach /dev/ttyS1 any
 

3. now i see two hci devices:

root@orangepilite2:~# hciconfig
hci1:   Type: Primary  Bus: UART
        BD Address: AA:AA:AA:AA:AA:AA  ACL MTU: 1021:8  SCO MTU: 64:1
        DOWN
        RX bytes:712 acl:0 sco:0 events:38 errors:0
        TX bytes:464 acl:0 sco:0 commands:44 errors:0

hci0:   Type: Primary  Bus: SDIO
        BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
        DOWN
        RX bytes:0 acl:0 sco:0 events:0 errors:0
        TX bytes:0 acl:0 sco:0 commands:0 errors:0

 

4.  try to up hci1:

hciconfig hci1 up

 

5. hci1 up and running now.

root@orangepilite2:~# hciconfig hci1
hci1:   Type: Primary  Bus: UART
        BD Address: AA:AA:AA:AA:AA:AA  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING
        RX bytes:1410 acl:0 sco:0 events:74 errors:0
        TX bytes:895 acl:0 sco:0 commands:80 errors:0
 

root@orangepilite2:~# hciconfig hci1 version
hci1:   Type: Primary  Bus: UART
        BD Address: AA:AA:AA:AA:AA:AA  ACL MTU: 1021:8  SCO MTU: 64:1
        HCI Version: 4.1 (0x7)  Revision: 0x0
        LMP Version: 4.1 (0x7)  Subversion: 0x6119
        Manufacturer: Broadcom Corporation (15)
 

 

Share this post


Link to post
Share on other sites

You can always give 5.3-rcX kernel a shot if you haven't already.

You can find some prebuild debs and images following the link below.

Share this post


Link to post
Share on other sites

Still the BT shows:

 

hci1:   Type: Primary  Bus: SDIO
        BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
        DOWN
        RX bytes:0 acl:0 sco:0 events:0 errors:0
        TX bytes:0 acl:0 sco:0 commands:0 errors:0
 

 

Running 5.3.0 RC8

Share this post


Link to post
Share on other sites

Do you need only the first file or all the others too?

 

BCM4345C5.hcd add ap6256 firmware8 months ago

config.txt add ap6256 firmware8 months ago

fw_bcm43456c5_ag.bin add ap6256 firmware8 months ago

fw_bcm43456c5_ag_apsta.bin add ap6256 firmware8 months ago

nvram.txt

 

well, I got them to the directory, but they show up in green, does that mean anything. If it look at it with lsattr it looks the same:

 

--------------e---- ./BCM4345C5.hcd
 

and with hciconfig it still show the BT device as 0000000 and not working

files.png

Share this post


Link to post
Share on other sites
19 hours ago, SchmuseTigger said:

Do you need only the first file or all the others too?

 

I do not own this board so no idea.

Share this post


Link to post
Share on other sites
On 9/13/2019 at 3:50 PM, Werner said:

I do not own this board so no idea.

thanks anyhow. I feel I'm so close with the description stating that the file need to be there and that is it. And I have the file there and it is not working but showing up in a different color. 

Share this post


Link to post
Share on other sites

@rawaaw

Good job. Have you tried if it is actually working? I don't get any results from hcitool scan

And there is an error in dmesg when the device is initialized as described by you above:

[ 3068.025249] Bluetooth: hci1: command 0x1003 tx timeout

 

 But I have the feeling we are almost there, at least for the OPi Lite2

 

When I try specific parameters for hciattach, I get the following:

 

root@orangepilite2:~# hciattach /dev/ttyS1 bcm43xx 921600 noflow -
bcm43xx_init
Patch not found, continue anyway
Set Controller UART speed to 921600 bit/s
Device setup complete
root@orangepilite2:~# hciconfig hci1 up
Can't init device hci1: Connection timed out (110)

Share this post


Link to post
Share on other sites

>>Have you tried if it is actually working?

actually :) I use this board for working with BLE devices.

 

i use armbian:

Linux orangepilite2 5.2.5-sunxi64 #5.92 SMP Fri Aug 2 07:51:38 CEST 2019 aarch64 aarch64 aarch64 GNU/Linux

Ubuntu 18.04.3 LTS \n \l
 

also check user 'data' post at april 27  

cd /lib/firmware/brcm
cp brcmfmac43455-sdio.txt brcmfmac43455-sdio.xunlong,orangepi-lite2.txt
 

also i compilted brcm_patchram_plus for change mac address.

https://github.com/phelum/CT_Bluetooth/blob/master/brcm_patchram_plus.c

  gcc -o brcm_patchram_plus brcm_patchram_plus.c

 

#/bin/sh
echo 388 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio388/direction
echo 1 >/sys/class/gpio/gpio388/value

sleep 1
/root/brcm_patchram_plus --bd_addr 11:22:33:44:55:66 /dev/ttyS1
sleep 1

hciattach /dev/ttyS1 any

hciconfig hci1 up
hciconfig hci1

exit 0

 

root@orangepilite2:~# ./hci.sh
Device setup complete
hci1:   Type: Primary  Bus: UART
        BD Address: 11:22:33:44:55:66  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING
        RX bytes:668 acl:0 sco:0 events:34 errors:0
        TX bytes:423 acl:0 sco:0 commands:34 errors:0
 

BLE actually working:

 

root@orangepilite2:~# hcitool -i hci1 lescan
LE Scan ...
EB:98:F8:C0:XX:XX (unknown)
EB:98:F8:C0:XX:XX Mi Band 3
EE:1A:6E:72:YY:YY (unknown)
EE:1A:6E:72:YY:YY Mi Smart Band 4
 

root@orangepilite2:~# gatttool -t random -i hci1 -b EB:98:F8:C0:XX:XX -I
[EB:98:F8:C0:XX:XX][LE]> connect
Attempting to connect to EB:98:F8:C0:XX:XX
Connection successful
[EB:98:F8:C0:XX:XX][LE]> char-desc
handle: 0x0001, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x0002, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
.....
 

 

 

Share this post


Link to post
Share on other sites

>>root@orangepilite2:~# hciattach /dev/ttyS1 bcm43xx 921600 noflow -

 

When i tried attach 6255 by this way BT adapter hangs up.

So i set mac address with brcm_patchram_plus and  do attach adapter as generic hci device with 

hciattach /dev/ttyS1 any

 

see my previous post for detailes  

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
2 2