-
Notifications
You must be signed in to change notification settings - Fork 194
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
On Pi3 B and B+ choppy sound #205
Comments
Also, if you know, why does the B3+ have a non-use-able hci0? I have a B3 and a B3+ set up and am trying this on them. Both of these pis are using the onboard bluetooth. Both are using the same image with the same packages installed. This strange non-accessible hci0 means I need to specify hci1 for my bluealsa service files. Any idea what is going on?
Pi B3+
|
I note the same result on PiZero (armv6) and also on Pi B3 (armv6). This is only with the onboard bluetooth dongle. |
I have a rpi zero W and a rpi 3B+, both with minimal Raspbian Stretch Lite systems installed. Neither has a device "hci1", the on-board bluetooth is hci0, and bluealsa-aplay works flawlessly on both. Since systemd gets its devices from udev, you should look at your udev config to find out why systemctl reports 2 bluetooth devices and what exactly is hci0 on your system. I think the best place to look for answers would be on a forum for your specific system (you don't say what system it is) as neither issue looks like it is directly related to bluealsa, and other users of that system may have already experienced and fixed the issue. |
@ borine - Good advice. I'll do some checking on the boards. I am running Arch Linux. I'll look into udev a bit more.
The a2dp-connect is this:
Neither image lists any other problems in journal or dmesg when the audio problems are apparent, It just plays a bit then stops then plays a bit more. It also does not appear in the journal that the device is connecting and disconnecting until I actually disconnect from the phone. This script works fine with a BT dongle on either B1 or B2 image. It is strange to me that the same B2/3 (armv7h) image works perfectly on my Pi2 which has an old BT dongle and hiccups on a B3 and B3+ with onboard BT. Similarly, the same B1 (armv6h) image works perfectly with a BT dongle on the B+ and has this hiccup with the Zero with onboard BT. |
digging a bit further... My alsa-utils is 1.1.8. I am running the latest git of bluealsa 1.4.0.r9.g1557602 The B3 adapter lists as:
The Pi2 list as:
I tried playing on a B3 (choppy) and it looks like this: |
Re rpi hci0/hci1 issue, a popular web search engine found this for me: |
Thanks for the help! I searched on the wrong terms and didn't didn't find this. I am indeed on 4.19
This solves the hci0/hci1 problem, but not the choppy playback. I did some btmgmt work and turned off some functionality on the BT radio and will see if it works any better tonight. |
Maybe Arch is using different firmware to Raspbian. For example, see the linked comment here: |
They are indeed different:
That mine does not have. I'll check it out and see if it works any better. I'll also have to look into this on Arch and find out why theirs is not updated. |
I did the update manually. No improvement. I am running kernel 4.19-32. If I disable the onboard bluetooth by stopping the brcm43438.service and put in a bluetooth dongle it all works as expected. To get the onboard BT working on Arch, you need to run this service which runs this: |
RPi on-board bluetooth is enabled out of the box with Raspbian. |
@borine You have contributed a lot to my understanding of this, thanks. My guess is that this is run at boot in some rc file under raspbian. I have not used raspian for a while, so I am not as familiar with it. |
So, I tried hciattach and now it works with wifi on, no stuttering. |
Could you post a link to the Arch discussion here? If you have a working solution then it may be useful for others to follow - for example #193 looks like the same, or closely related, issue for a non-raspbian user. |
I am still struggling in the dark with a single match, here... It is a lot of wrangling to get these to work. As long as they have been around, there should be a cleaner way, IMO. AFAICT, Bluez has deprecated hciattach and replaced it with btmgmt and bluetoothctl. Lots of overlap between the 2 commands and some things can only be done in one or the other. I am unable to decipher much of what is going on other than copy and paste and try. The man page is not helpful to me nor is help. On a B3+, I had to blacklist the btsdio module when using btattach to get the BT to show up on hci0 instead of hci1. When I use hciattach, that approach no longer works and my bluetooth device appears on hci1 and I cannot figure out how to put it on hci0, yet. Also, I figured out that I need to comment out the console setting in cmdline.txt. It was "console=ttyAMA0,115200" now it reads "console=" If I did not do this, it would disconnect as soon as I connected. I need to do more experimentation on this and figure out exactly what works and how/why. It was late last night and I was using a shotgun approach. It is a bit different (go figure) with the Zero, B3 and B3+. As of last night I was able to get it to work on the B3+(hci1) and B3 (hci0), but was failing with the Zero and went to bed. When I was able to get it working with hciattach it was smooth audio and wifi was enabled and running at the same time with no discernible effect on audio. That is encouraging. I just wish it were clear as to how and why it was happening.
pi-bluetooth.install
The license file can be found in the pi-bluetooth arch AUR repository. |
I can confirm having the same issue with a Pi 4B running Arch Linux ARM (32 bits), with I feel bad not adding much to the conversation, so I might as well give you how to get First, install mkdir /etc/firmware
ln -s /usr/lib/firmware/BCM4345C0.hcd /etc/firmware/BCM4345C0.hcd
ln -s /usr/lib/firmware/BCM43430A1.hcd /etc/firmware/BCM43430A1.hcd
systemctl enable brcm43438.service bluetooth.service bluealsa.service Edit console= Create If you have a Raspberry Pi 4 or a 3B+ (maybe other models, sorry I don't know which are 921600 bauds and which are 3000000. If unsure, skip this and come back at it later if it didn't work), override the [Service]
ExecStart=
ExecStart=/usr/bin/hciattach -n /dev/ttyAMA0 bcm43xx 3000000 flow - Then, reboot (to make sure the firmware gets written properly as it seems you can write it once per power cycle) and continue from here. |
Bluetooth can be used for so many different things and when someone on a forum says 'it works', you must understand that as 'it works for them on the things they have tried', nothing more. It seems that the effort that has gone into bluez was for devices and ethernet etc and audio seems to be a bit of an afterthought. btattach and hciattach do not result in the same performance with audio on my systems and btattach either doe snot work at all or is choppy. Personally, I'd like the bluez group to revisit btattach and resolve it there... |
Had similar choppy sound issue on Alpine, with It seems kernel needs some tweaked configs ( |
i have arch linux kernel with CONFIG_SERIAL_DEV_BUS=y and CONFIG_BT_HCIUART_BCM=y but i have too very choppy sound with bluealsa. |
@Mitschmaster are you using a rpi? if so, which model? what is the hciattach or btattach command line ? |
Im on a rpi 4 and i only tested the btattach command. |
got another workaround: |
The most significant difference I can see between the source for hciattach and btattach is that hciattach calls a driver-specific init function (bcm43xx_init() for the RPi) which loads the firmware hcd file before any other uart config takes place; btattach does not call this function.
Do you mean that running that command before btattach results in goos sound, or that with that command btattach is not necessary, or what? This RPi issue when not using Raspbian has been raised many times on this list, but I've never seen a definitive answer. Do you have a repeatable solution at last? |
i mean that i ran brcm_patchram_plus instead of btattach. and had good sound, like i had with a bluetooth usb dongle. |
Ok, thanks; although unfortunately I still don't understand how this works. With neither hciattach nor btattach running, I don't see how the uart device is being configured. I haven't seen the source code to brcm_patchram_plus but my understanding is that it just uploads the firmware file. Maybe my understanding is wrong, or just outdated. Still, you have it working and that's very encouraging news. |
update - I've just found the source for brcm_patchram_plus and indeed it does set up the hci interface on the uart device if you pass the --enable_hci option. When I next get chance I'll see if this also works on Raspbian |
I can confirm that brcm_patchram_plus works also with Rasbian buster on a pi zeroW. You need to use firmware /lib/firmware/brcm/BCM43430A1.hcd but otherwise the command is the same. You also need to disable (and stop) the systemd hciuart.service that Rasbian uses to launch hciattach. btattach on Raspbian buster also configures the uart hci correctly and uploads the firmware, but fails to set a usable bluetooth address. I get 00:00:00:00:00:00. The interesting thing is that brcm_patchram_plus does not set the bt address unless explicilty told to do so on the command line. So perhaps btattach actually prevents the address from being set? I'll look into that next. |
another data point using btattach:
So the difference is somewhere in the protocol setup |
A safe way to get things setup is to reuse Pi Foundation's own btuart script & eventually customize it on particular distribution (ie replace Interestingly folks at LibreELEC recommend loading through |
I'm not familiar with devicetree usage for bluetooth setup - is there a good general introduction anywhere I can read up on this? I notice that the LibreElec link you give relates to SDIO, is that relevant for bluetooth audio? (you can tell this is all beyond my experience level!)
Just to add to that: the patches you mention are from the Pi Foundation's build of hciattach, and are specifically to add support for the original Pi3 and the PiZeroW onboard bluetooth, they are not necessary for the Pi3B+ or Pi4. |
@macmpi wrote:
Yes - in fact the Raspbian kernel is now built that way. The problem is that when bluez re-factored the vendor-specific functions from user-space tools to kernel modules (ie when hciattach was deprecated in favour of btattach), the they were split between the hci config (in module hci_uart) and the bluetooth config (in module btbcm). Unfortunately, the bcm43xx requires the host to explicitly select a baudrate for the uart, otherwise it defaults to 115200, and this step of the config was lost during the refactoring. Once the bcm43xx firmware is uploaded, the controller baud rate reverts to 115200, so the host has to then set it to 3000000 (or whatever the application has requested). The btbcm driver does not do this, and in fact I can see no way in the API for user space to communicate its chosen baud rate. So when using btattach the hci is set up to use 115200 baud which is insufficient to maintain a steady A2DP audio stream. My conclusion is that at the present time btattach cannot be used successfully with bcm4xx over a uart hci. I don't know enough about device tree overlays to say whether one could be used to pre-configure the operating baud rate of the bcm43xx. That would be a neat fix for boards such as the Pi. Failing that, it is left to user space to implement the necessary vendor-specifc HCI command and tty config to change the baud rate after initial setup - so perhaps a patch to the btattach application code. |
Hi everybody, I really spend a lot of time trying to figure out the reason for my stuttering audio (with wifi off) while a working solution for my issue has already been released years ago: reducing the baudrate to 460800. (I was always thinking about increasing it...) See original post here: raspberrypi/linux#2264 (comment) What to do: @borine btattach didn't work for me either. So I kept Following additional information:
Originally posted by @docgloucester in nicokaiser/rpi-audio-receiver#38 (comment) |
hi. |
do you mean the issue when using btattach? if so, then that is to be expected.. As I tried to explain in comment #205 (comment) this is a bug/design limitation of the btbcm kernel module which does not set the desired baud rate after loading the firmware. The only workaround I know is to use a tool that does not require support from the kernel - so basically hciattach or brcm_patchram_plus. You can check the baudrate of the UART with If it reports 115200 (the default setting of the bcm43xx chip) then that is too low for a2dp |
FWIW ( note, on Pi3b rev1.2 boards, one may want to limit baudrate as previously with |
Building 5.4.50 now. We will see how well it works. RPi foundation took 4 years to release this. I hope it works. Tried it last night and got no joy. I'll have to read up on it a bit more. As it is, I still have to have brcm43438.service running and bluetooth.service before bluetoothctl acknowledges that there is a Bt module onboard. If I disable brcm43438 then reboot, no bt module shows up. |
@gearhead did you try with Foundation's firmware files.
|
Thank you so much! This is working fine now on ArchLinuxARM and my Raspberry PI 4. Bluetooth audio is playing fine and now special tweaks are needed anymore.
and add
to |
@onny glad it helped: you may want to spread the word onto ArchLinuxARM pi-bluetooth package discussion and related Pi wiki |
OK. I got this to work on a B3 running armv7. The package firmware-brcm43xx is not available for armv6 (PiZeroW) nor for aarch64 (Pi2-4). I'll dig into it and see what is up and if I can build a package for those 2 architectures and see if it works. Does anyone know if there are specific kernel build flags that are needed to make this work? I am re-building the aarch64 kernel and will see if it 'just works', but I already rebuilt 5.4.50-1 with my config and on aarch64 it does not work with the config.txt setting. I built the firmware-brcm43xx and installed it for aarch64 and it installed without any errors. Still no BT joy on aarch64. |
got it working on aarch64. no choppy sound |
hi! @gearhead Do you have any update regarding PiZeroW? |
Works for me on zero, b2 b3 and b3+
…On Sat, Sep 26, 2020, 17:36 etienne1911 ***@***.***> wrote:
hi! @gearhead <https://github.com/gearhead> Do you have any update
regarding PiZeroW?
I'm trying to get bluetooth work on archlinux but no luck yet :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#205 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAARWJGOUYJ2SCH4DGG4CATSHZUIPANCNFSM4HDYNKGA>
.
|
Ok that's good news. is there any additional firmware to install like 'firmware-brcm43xx' because I coudn't find any for armv6. |
Latest raspberry pi firmware appears to be working well together with latest bluez-alsa code (ie not the bluealsa package in the RaspiOS repository which is currently very outdated and somewhat broken). If you have a specific issue with the latest bluez-alsa on RPi please open a new issue as much of the information here is now out of date. |
I thought this was a wifi/BT interference problem, but even with BT turned off, I get choppy sound. It plays a bit at a time then cuts out then comes back. I do not get this with the same packages and install on a Pi2 with an old BT dongle... On teh Pi2 it works fine and no choppiness
The journal shows:
The text was updated successfully, but these errors were encountered: