Bluetooth HFP echo on receiver side

When making a bluetooth hands free phone call, the person on the receiving end of the call hears an echo (or loopback) of their own voice with an aprox 1 second delay. The feedback IS NOT caused by a speaker feeding back into a microphone.

I was using this Toradex article as a guide How to Setup Bluetooth Audio Profiles (Linux) | Toradex Developer Center

Environment info:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.129-6.4.0-devel+git.67c3153d20ff #1 SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023
Kernel command line:      root=PARTUUID=72b5ae8b-02 ro rootwait console=tty1 console=ttymxc2,115200 consoleblank=0 earlycon
Distro name:              NAME="TDX Wayland with XWayland"
Distro version:           VERSION_ID=6.4.0-devel-20231220205908-build.0
Hostname:                 verdin-imx8mp-15006329
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version:          0058 V1.1A
Serial number:            15006329
Processor arch:           aarch64
------------------------------------------------------------

Bluez v5.65
BlueALSA v16.1

Hey @david.bouthillier,

For general checking: Can you switched out the speaker/microphone to validate the issue most likely relating to software? Also can you share how you know it’s not related to speaker->microphone feedback?

Can you describe your hardware setup, and what software steps you are taking to produce this event?

-Eric

I have a Verdin board with an IMX8MP. I’m using headphones for the audio (completely sealed), and the device has an integrated microphone. I used bluetoothctl to connect my iPhone. I initiate a phone call on my iPhone to another phone. I then ran the following BlueALSA scritp (from the tutorial).

alsaloop -g /dev/stdin <<EOF
-C bluealsa:SRV=org.bluealsa,DEV=A0:56:F3:97:94:4C,PROFILE=sco -P plughw:0 -r 8000 -c 2 -f s16_le -n -t 40000 -T 1
-C plughw:0 -P bluealsa:SRV=org.bluealsa,DEV=A0:56:F3:97:94:4C,PROFILE=sco -r 8000 -c 2 -f s16_le -n -t 40000 -T 2
EOF

On my end (bluetooth connect through embedded device), I can hear the person on the other phone perfectly, and they can hear me perfectly.

However, on the receiver end, they hear their voice repeated back to them with an aprox 1 second delay. On my end, I never hear any feedback, echo, or loopback.

This is the issue I cannot seem to figure out.

Hey @david.bouthillier,

Just wanted to check in and report that I will try and recreate your experience.

-Eric

1 Like

Hey @david.bouthillier,

Looking through your old post, you stated that you updated bluealsa to v4.1.1. Can you confirm you did this? I ran into some gdbus-codegen issues when attempting.

-Eric

Yes, we upgraded to v4.1.1-90-gc18e812

I’m not on the build team, so I’m not exactly sure how it was done. We upgraded because there was a bug in the old version that caused a crash for us.

Hey @david.bouthillier,

Unfortunately I couldn’t recreate the error. I will escalate the topic on our end, that most likely won’t provide any immediate solution. I would recommend reaching out to the bluez-alsa community on their
git-hub link and maybe they can provide specific guidance.

-Eric

Ok, keep us updated. This is critical for us to resolve.

I have already reached out to the Blue ALSA folks, the PulseAudio team, and the Bluez community. I did not have any success resolving the issue.

Hey @david.bouthillier,

I’ve managed to update to v4.1.1, requirement was to include glib-2.0-native to the .bb files depends.

Are you able to provide a step by step process of settings/actions taken so I can mimic the results and share with my team? (as best you can)

-Eric

Yes, I’ll try my best.

  • Start with the base multimedia reference image. Disable the QT demo app.
  • Follow this How-To guide for Bluetooth HFP. How to Setup Bluetooth Audio Profiles (Linux) | Toradex Developer Center
  • Add the oFono profile to bluealsa by adding -p hfp-ofono in the ExecStart command in /lib/systemd/system/bluealsa.service
  • Connect a microphone and headset to the board (I’m using a headset that has 3.5mm mic and audio connector and using the green and pink ports on the Verdin dev board)
  • Connect to a phone using bluetoothctl
  • Initiate a call on the phone
  • Run the alsaloop_call.sh script created in the how-to guide right after you start the call.

At this point, you should be able to have a phone conversation through the headset. The person on the other end will hear their voice repeated back to them.

Please feel free to ask any questions regarding settings on my board if you run into issues.

Hey @david.bouthillier,

Can you share your alsaloop_call.sh? And when you run your shell command, can you share the terminal output throughout a call?

-Eric

This is my script. There really isn’t anything output from the script.

alsaloop -g /dev/stdin <<EOF
-C bluealsa:SRV=org.bluealsa,DEV=A0:56:F3:97:94:4C,PROFILE=sco -P plughw:0 -r 8000 -c 2 -f s16_le -n -t 40000 -T 1
-C plughw:0 -P bluealsa:SRV=org.bluealsa,DEV=A0:56:F3:97:94:4C,PROFILE=sco -r 8000 -c 2 -f s16_le -n -t 40000 -T 2
EOF

Hey @david.bouthillier,

Thanks for the added information. I am waiting on our internal team and our escalation process. I will report back as soon as I have more info.

-Eric

Hey @david.bouthillier,

I received an updated from our escalation processes. What was determined is that the Bluez-ala project considered echo cancelling out of scope. For a bit more information: Integration of echo-cancelling · Issue #532 · arkq/bluez-alsa · GitHub There is the belief that this issue wont be able to be solved via just ALSA tools.

They were able to get a bluetooth HFP setup using pulseaudio, and are working on documentation.

-Eric

Thank you for the update @eric.tx

Dear @eric.tx,
I have the same problem and I am trying to integrate the webrtc echo canceller into my system.
I have included the following lines in local.conf

IMAGE_INSTALL:append = “ pulseaudio pulseaudio-server pulseaudio-misc”
DISTRO_FEATURES:append = “ pulseaudio”

I have included the following lines in ./layers/openembedded-core/meta/recipes-multimedia/pulseaudio/pulseaudio.inc

EXTRA_OEMESON += “-Dwebrtc-aec=enabled”
EXTRA_OECONF += “--enable-webrtc-aec”
DEPENDS += “webrtc-audio-processing”

The result is that we have pulseaudio on board but not the echo canceller, could you help me with the recipe?

Best regards,
Julian

Hey @jbruno,

Would you mind starting a new post for your topic? We like to keep it 1 topic per post so solutions are easier for people to find.

@david.bouthillier,

It looks like the echo effect/issue is reproducible with Pluseaudio, there are some tools that may allow elimination of the echo, this is the next step in the investigation.

-Eric

Thanks for the update @eric.tx

Hi @eric.tx,
I have created a new post asking for your help to integrate the pulseaudio echo canceller.

On the other hand, we have been testing and we believe that the echo is not due to acoustic feedback but to a failure of the WM8904. It seems to have a very high crosstalk between the HP and MIC signal path. @eric.tx have you tested if with another codec you get the same echo? Have you tested with the NAU88C22?

Julián

@jbruno,

Thank you and I’ve included your insight with the previously escalation. Will comment back when more information is discovered.

-Eric