-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluetooth is not autodetected with device tree (bcm2837-rpi-3-b.dtb) on Raspberry Pi 3 #3675
Comments
I'm happy with how Bluetooth is configured in our kernel for now, but I will give any Pull Request consideration. |
cross-referencing #3459 |
It turned out that I was missing |
The Bluetooth device under the serial device in the device tree is registered by |
Very interesting indeed. |
You might want to check that your BDADDR is correct. |
How can I check that, given that /dev/ttyAMA0 is missing when it's attached to Bluetooth using device tree?
I'm planning to test A2DP (it will be my use case), but for now I still haven't, I'm missing other required things such as alsa. The autodetection works (that's what this ticket is about), and basic stuff like pairing works too.
Interesting. Is it also the case when I attach Bluetooth with hciattach? Is Pi4 free of these issues?
It looks correct and matches the one that |
Dunno how you may check baudrate, but wonders if automated firmware load would not set default baud rate to 115200 which may not be sufficient for A2DP...
Yes indeed. see this with rev 1.2 (KO) vs rev 1.3 (OK) Pi3 board differences.
Pi4 , Pi3b+, Pi3 rev 1.3, and PiZeroW have RTS: you may check this and work from @lategoodbye |
Thanks for useful links!
That is a correct concern. I added some debug prints to
So, it looks promising, but I haven't tested A2DP yet. |
Tested A2DP (Raspberry Pi was the sink), the sound goes smoothly, so I suppose the baud rate is indeed set correctly (and the debug prints above confirm it). There are a few instabilities, though. I got such bursts once or twice (the sound disappeared for less than a second):
Sometimes Bluetooth doesn't come up on boot:
Could it be caused by the missing hardware flow control? I.e. if I upgrade to Pi4, will those timeouts disappear? P.S. I have never tested it with hciattach yet, I'll probably also compile it and check whether it also suffers from "command tx timeout". |
Without flow control, 2Mbaud is very ambitious. With hciattach we run it at 921600 baud, and even then some users have to reduce it to 460800 for reliability over throughput. |
Tried 460800 — sound got choppy, but these tx timeout errors still happen sometimes on boot, making Bluetooth unusable:
|
Disclaimer: i'm not that Bluetooth expert AFAIR the problem with btbcm driver was that it operates with H4 protocol, which requires hardware flow control. So a better solution would be to make the driver use H5 protocol for Raspberry Pi 3 B rev 1.2. Edit: According to BCM43340 datasheet page 52 (table 11) the baud rates 921600 and 460800 are not ideal because they have an error rate of 0.16 % . |
That's really a good idea, I didn't know that BCM43340 also supports H5, but now I see in the datasheet you cited that it does. However, converting the driver to use H5 is more effort, so I'll try it if I happen to have enough free time. In the meanwhile, I'll test hciattach to see if it also suffers from the same errors, and if the device tree configuration doesn't have functional drawbacks compared to hciattach, I'll submit a pull request to change the defconfig and add a DT overlay that would allow people to choose the way they configure Bluetooth (DT or hciattach).
Thanks for the hint. I'll stay with 2000000 for now, the datasheet says the error rate is 0%. |
I like the overlay idea because it provides an easily reversible migration path. |
Is this the right place for my bug report?
I hope so, because it's kernel-related and Raspberry Pi-specific.
Describe the bug
The upstream device tree (bcm2837-rpi-3-b.dtb) attempts to configure Bluetooth:
However, the code in
drivers/of/platform.c
skips thebluetooth
subsection, becauseuart0
is defined inbcm283x.dtsi
as follows:It contains
"arm,primecell"
incompatible
, which makes the enumeration code indrivers/of/platform.c
to return early and skip enumerating children ofuart0
, i.e. thebluetooth
node. As a result, hci_uart is not autoloaded by udev, and when loaded manually, it doesn't autodetect the Bluetooth hardware, so I need to runbtattach
orhciattach
manually.Tested on both this kernel (built from the 5.7.y branch) and the upstream kernel (5.7.2).
To reproduce
hciuart.service
or any other scripts that runhciattach
orbtattach
on boot.device_tree=dtbs/broadcom/bcm2837-rpi-3-b.dtb
in/boot/config.txt
.Expected behaviour
Bluetooth adaptor is probed with device tree and is visible in the system (e.g., under
/sys/class/bluetooth/hci0
).Actual behaviour
/sys/class/bluetooth
is empty, bluetoothd doesn't autostart, no Bluetooth functionality in the system.System
Sorry, I use a custom distribution, so I don't have many of the requested commands, but I believe the information below should be enough, the rest doesn't seem relevant.
cat /etc/rpi-issue
)? Custom Linux distribution.vcgencmd version
)?uname -a
)? Upstream kernel 5.7.2 and raspberry kernel from branch 5.7.y.Logs
dmesg part with debug output enabled in
drivers/of/platform.c
:As we see, it doesn't traverse the children of
/soc/serial@7e201000
, instead it creates an AMBA device.Additional context
It sounds weird that there is a guy who claims that device tree autoprobing of Bluetooth worked for him: https://gist.github.com/shenghaoyang/92e6dd65b9f0cc736a419f3e640663c2. He basically adds a part of the upstream device tree as an overlay for the raspberry device tree (bcm2710-rpi-3-b.dtb). This approach hasn't worked for me either, for the same reason explained above.
The text was updated successfully, but these errors were encountered: