Bluetooth Audio Cyclic Error

Hi,

During my tests i’ve found a error in audio being transmitted through bluetooth, in every 30s approximately the audio fails, does you guys know what could be the cause?

I’m using a AM62P5, i’ve already tested with others telephones and had the same outcome

Here are the commands i used on the board to play the audio.

am62pxx:~# bluealsa-aplay -vvv &
[1] 590
am62pxx:~# Selected configuration:
BlueALSA service: org.bluealsa
PCM device: default
PCM buffer time: 500000 us
PCM period time: 100000 us
ALSA mixer device: default
ALSA mixer element: ‘Master’,0
Bluetooth device(s):
Profile: A2DP
bluealsa-aplay: W: Couldn’t open mixer: Mixer element not found
Used configuration for :
PCM buffer time: 743038 us (131072 bytes)
PCM period time: 371519 us (65536 bytes)
PCM format: S16_LE
Sampling rate: 44100 Hz
Channels: 2

And here is my device tree for our bluetooth configuration:

wifi_pwrseq: wifi-pwrseq {
compatible = “mmc-pwrseq-simple”;
pinctrl-names = “default”;
pinctrl-0 = <&wlan_en_pins_default>;
reset-gpios = <&main_gpio0 71 GPIO_ACTIVE_LOW>;
post-power-on-delay-ms = <200>;
power-off-delay-us = <100>;
status = “okay”;
};

&sdhci2 {
/* SDIO Wifi */
status = "okay";
assigned-clocks = <&k3_clks 226 0>;
assigned-clock-parents =  <&k3_clks 226 5>;
	
pinctrl-names = "default";
pinctrl-0 =<&main_mmc2_pins_default>, <&wifi_32k_clk>;
bus-width = <4>;

mmc-pwrseq = <&wifi_pwrseq>;
vmmc-supply = <&wl_lt_en>;

non-removable;
ti,fails-without-test-cd;
ti,driver-strength-ohm = <50>;
cap-power-off-card;
keep-power-in-suspend;

};

&main_uart1 {
pinctrl-names = “default”;
pinctrl-0 = <&main_uart1_pins_default>;
/* Main UART1 is used by TIFS firmware /
interrupts-extended = <&gic500 GIC_SPI 179 IRQ_TYPE_LEVEL_HIGH>,
<&main_pmx0 0x01ac>; /
(G23) MCASP0_AFSR.UART1_RXD */
interrupt-names = “irq”, “wakeup”;
current-speed = <3000000>;
uart-has-rtscts;
status = “okay”;
bootph-all;

bluetooth_8987 {
	compatible = "nxp,88w8987-bt";
	fw-init-baudrate = <115200>;
	status = "okay";
	post-power-on-delay-ms = <200>;
	power-off-delay-us = <100>;
};

};

BR,

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Bluetooth Audio Issues on AM62P5

Based on your description of audio failures every 30 seconds during Bluetooth transmission, this appears to be related to buffer configuration and BlueALSA settings. Let me address the key areas that could cause this issue.

BlueALSA Configuration Analysis

Your current bluealsa-aplay output shows some important configuration details that may be contributing to the audio interruptions (1):

  • PCM buffer time: 743038 us (131072 bytes)
  • PCM period time: 371519 us (65536 bytes)
  • Warning: “Couldn’t open mixer: Mixer element not found”

The mixer warning suggests that the ALSA mixer configuration may not be properly set up for your audio hardware (1).

BlueALSA Service Configuration

For proper Bluetooth audio operation, ensure that the BlueALSA service is correctly configured. The service should be running with appropriate profiles (2):

# systemctl status bluealsa.service

You should see output similar to (2):

● bluealsa.service - BlueALSA service  
     Loaded: loaded (/lib/systemd/system/bluealsa.service; enabled; vendor preset: enabled)  
     Active: active (running) since Tue 2023-05-16 13:40:04 UTC; 52min ago  
       Docs: man:bluealsa(8)  
   Main PID: 758 (bluealsa)  
      Tasks: 4 (limit: 1670)  
     Memory: 956.0K  
     CGroup: /system.slice/bluealsa.service  
             └─ 758 /usr/bin/bluealsa -p a2dp-source -p a2dp-sink  

Sound Card Verification

Check your available sound cards to ensure proper audio device configuration (1):

# aplay -l
# arecord -l

For Bluetooth devices specifically, verify the BlueALSA audio devices (1):

# bluealsa-aplay -L

Buffer and Latency Considerations

The periodic audio failures you’re experiencing could be related to buffer underruns or timing issues. The BlueALSA backend allows configuration of buffer parameters, and audio processing features are restricted compared to PipeWire or PulseAudio (2).

Device Tree Configuration

Your Device Tree configuration for the NXP 88w8987-bt module appears standard. However, ensure that the Bluetooth hardware is properly initialized and that there are no conflicts with other peripherals (3)(4).

Troubleshooting Steps

  1. Restart BlueALSA service (2):

    # systemctl restart bluealsa.service
    
  2. Check D-Bus permissions by ensuring the bluetooth.conf file has proper user permissions (2):

    +    <policy user="bluealsa">  
    +        <allow send_destination="org.bluez"/>  
    +    </policy>
    
  3. Verify Bluetooth profiles are properly enabled for A2DP operation (2).

Known Issues

There have been reports of timing-related issues with AM62 series modules in Bluetooth applications, including packet transmission delays (5). While your issue manifests as periodic audio interruptions rather than transmission delays, similar underlying timing or buffer management issues could be involved.

The 30-second interval pattern suggests this might be related to a periodic system process, buffer management, or power management feature that’s interfering with the audio stream.

Best regards, Toradex AI Assistant.

I had this outputs to the aplay-l and arecord -l
root@am62pxx-evm-lohr-recovery-mode:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: AM62xSKEVM [AM62x-SKEVM], device 0: 2b10000.audio-controller-tlv320aic3x-hifi tlv320aic3x-hifi-0 [2b10000.audio-controller-tlv320aic3x-hifi tlv320aic3x-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
root@am62pxx-evm-lohr-recovery-mode:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: AM62xSKEVM [AM62x-SKEVM], device 0: 2b10000.audio-controller-tlv320aic3x-hifi tlv320aic3x-hifi-0 [2b10000.audio-controller-tlv320aic3x-hifi tlv320aic3x-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

for the command bluealsa-aplay -L, i had the following output

root@am62pxx-evm-lohr-recovery-mode:~# bluealsa-aplay -L
bluealsa:SRV=org.bluealsa,DEV=A4:E2:87:E0:51:A8,PROFILE=a2dp
LOHR-POCO, trusted phone, capture
A2DP (SBC): S16_LE 2 channels 44100 Hz

I’ve ran the troubleshooting steps, but the problem kept happening.

Hello Sergio,

Welcome to the Toradex Community, and thank you for reaching out with your question!

Could you please share with us which SoM and Carrier Board you are using? Additionally, we would like to know which Operating System and Bluetooth module you are working with.

Best regards,
Daniel Morais

Hi i’m using AM62P5, and we are using linux with a custom toradexsdk 7.
My blueetoth is NXP 88w8987

Hi @Sergio ,

Thanks for answering.

This type of issue is a bit hard to solve, the correct way is trying to reproduce this on my side and trying to find a solution. Unfortunately, the Verdin AM62P modules are still on samples and I do not have any here to try it.

I’m looking internally if there is something we can do here to support you on this demand, but I understand that you are developing your own product using a chip-down AM62P5, is that correct?

Here are some tips that may help you investigate on your side:

  • Try increasing the PCM buffer and period size when running bluealsa-aplay (for example: bluealsa-aplay -B 1000000 -P 250000) to check if the issue is related to underruns.
  • Temporarily disable Wi-Fi and test only Bluetooth audio, since the 88W8987 uses coexistence between Wi-Fi and Bluetooth and conflicts can cause periodic audio drops.

Best regards,
Daniel Morais

Correct, we’re using the AM62P5 chip-down.

I tried increasing the PCM buffer, but the audio still failed, but the error duration and error-free playback period varied.

I’ve also tried disabling Wi-Fi, but the error persisted.

Another error I encountered was using a Qt application:
ALSA lib /usr/src/debug/alsa-lib/1.2.11/src/pcm/pcm.c:8740:(snd_pcm_recover) underrun occurred

I’ve corrected my problem by modifying my RtAudio.

Dear @Sergio ,
I’m experiencing the same error. What do you mean by RtAudio? Could you give an example of your configuration?
Thanks in advance,
Julián