Apalis-imx8 Azurewave bluetooth HFP not working

Have an Apalis-i.MX8 with custom yocto image running bluez 5.55 and the toradex_5.4-2.1.x-imx branch of linux-toradex.

Having problems with getting HFP bluetooth working with the Azurewave bluetooth module. We are running bluez, pulseaudio with bluetooth modules, and ofono. I can pair the board to my phone, and initiate phone calls from the board, and the audio will not go through the bluetooth connection. A2DP audio does work between the phone and the board (with the board as A2DP sink), but HFP audio does not work.

In addition, after the devices are paired, when attempting to reconnect after a disconnect, the connect will initially succeed, and then disconnect a few seconds later. bluez shows error:

bluetoothd: ../bluez-5.55/src/profile.c:ext_connect() hfp_hf failed connect to F0:5C:77:C1:1A:2C: Connection reset by peer (104)[link text][1]

btmon log attached

Initially there were two other bluetooth issues. rfcomm was not working, the kernel was returning a “protocol not supported” error when running the rfcomm utility. For some reason, changing CONFIG_BT_RFCOMM from “y” to “m” fixed this. And bluez was complaining about missing uinput so I added CONFIG_INPUT_UINPUT to the kernel config, but otherwise we are using the defconfig from linux-toradex.

Hi @aaronb I am trying to replicate this in my local setup. Can you provide exact steps, commands, etc that you are using?

In the meantime, can you try this with our latest BSP? There is a toradex_5.4-2.3.x-imx branch now.

Drew

We have a build with pulseaudio, ofono and packagegroup-tools-bluetooth.
We had to add MACHINE_FEATURES_append_mx8 = " 3g" to get pulseaudio to enable ofono support.

With bluetoothd, ofono, and pulseaudio running, use bluetoothctl to pair with phone. Verify from the phone that the apalis-imx8 device supports “Phone calls”. Then disconnect and reconnect. For me, it fails on the reconnect. It will briefly connect and then disconnect after a while.

I had tried to update meta-toradex-nxp to the version that pulls in 5.4-2.3.x-imx, but when I did the build it was complaining about a missing hdmi device tree overlay and I reverted back.

Also see section 4.3 of https://www.nxp.com/docs/en/user-guide/UM11490.pdf

When I get to step 5, there’s no platform-sound-bt-sco sink.

Could you provide a build log with mentioned complains about missed overlay?

@drew.tx I am back trying to get HFP bluetooth to work, still no luck. When I run btmon during a connection I see:

> HCI Event: Connect Request (0x04) plen 10                                                                                                                                                     #11 [hci0] 21.153836
        Address: F0:5C:77:C1:1A:2C (Google, Inc.)
        Class: 0x5a020c
          Major class: Phone (cellular, cordless, payphone, modem)
          Minor class: Smart phone
          Networking (LAN, Ad hoc)
          Capturing (Scanner, Microphone)
          Object Transfer (v-Inbox, v-Folder)
          Telephony (Cordless telephony, Modem, Headset)
        Link type: eSCO (0x02)
< HCI Command: Reject Synchronous Connection Request (0x01|0x002a) plen 7                                                                                                                       #12 [hci0] 21.154154
        Address: F0:5C:77:C1:1A:2C (Google, Inc.)
        Reason: Connection Rejected due to Limited Resources (0x0d)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                       #13 [hci0] 21.157585
      Reject Synchronous Connection Request (0x01|0x002a) ncmd 1
        Status: Success (0x00)
> HCI Event: Max Slots Change (0x1b) plen 3                                                                                                                                                     #14 [hci0] 21.163883
        Handle: 1
        Max slots: 5
> HCI Event: Synchronous Connect Complete (0x2c) plen 17                                                                                                                                        #15 [hci0] 21.164091
        Status: Connection Rejected due to Limited Resources (0x0d)
        Handle: 8
        Address: F0:5C:77:C1:1A:2C (Google, Inc.)
        Link type: eSCO (0x02)
        Transmission interval: 0x00
        Retransmission window: 0x00
        RX packet length: 0
        TX packet length: 0
        Air mode: Reserved (0x0a)

So it seems like my phone is trying to initiate an eSCO connection, but the driver is rejecting it with a “limited resources” error.

Hi @aaronb,

Sorry for the delay from my side. I’ve been experiment with this but cannot reproduce your exact situation. Can you share more specifics about how you are able to reproduce this? Specifically, can you share all the commands you run to connect and configure the bluetooth devices, as well as the make/model of each of the devices you are working with?

Drew

Hi @drew.tx , when you say you can’t reproduce it, does that mean you have verified that the HFP/HSP profile works on an image with an apalis-imx8 SoM? If you have an image where it’s working it would be great if you could send me that and I could compare to our image. We have a custom application that uses the DBUS APIs of bluez and ofono to connect and configure the devices, so it’s not so easy to reproduce the setup.

Section 4.3 of https://www.nxp.com/docs/en/user-guide/UM11490.pdf has a good guide to testing HFP/HSP using the same Azurewave chip in the apalix-imx8. When I get to step 5 on our image, there is no pulseauido bt-sco sink.

No I have not been able to get it functioning. I’ve never played much with these components before so I’m still coming up to speed.

I did reproduce the issue of not seeing a bt-sco sink but I had similar behavior on a Raspberry Pi as well so I was unclear if that was the root cause of your issue or not.

To clarify my understanding of your setup, you are connecting a mobile phone and a bluetooth headset to the Apalis and then using ofono to control the mobile device. Is that correct?

Yes. We are connecting a USB headset to the Apalis/Ixora board, and connecting a phone over bluetooth, and trying to use the USB headset for voice phone calls.

@drew.tx I think this is the simplest method to reproduce:

  1. Run bluetoothctl, pair and connect to phone
  2. run “btmon”
  3. From prompt, run "scotest -c "

That tests a SCO connection. From my laptop, that connects. From the apalis-imx8, it fails to connect, and I see HCI SCO connect events indicating “Connection Rejected due to Limited Resources”. But I don’t know what that means. I checked the Bluetooth Spec, Vol 1, Part F, section 2.13, and the description of the “Connection Rejected Due to Limited Resources (0x0D)” error is as follows:

The Connection Rejected Due to Limited Resources error code indicates that a connection was rejected due to limited resources.

How can I get the reference manual for the marvell/nxp bluetooth part? I suspect there’s some vendor HCI commands that may be useful for configuring SCO, or maybe a better description of what resources are limited?

Hi @aaronb the docs are available here. I think it may require an NXP login to access but am not sure.

Drew

@drew.tx The datasheet is not available to me. Working with NXP reps to get access.

I also don’t have the schematic for the Apalis-imx8 SOM. Looking at the block diagrams, it looks like there is not a separate PCM connection for audio. Can you confirm that the PCM/I2S is not connected to the azurewave chip, and that SCO audio should be routed over the USB bus?

@drew.tx Can you please confirm whether the PCM pins are connected on the Azurewave module to the SOM? How can I get the Apalis-iMX8 schematic?

Hi @aaronb the I2S pins are not connected to the Azurewave part. I’m checking on schematic access.

We don’t generally share schematics although we have shared parts of them for certain issues. I’ve notified your account rep @stuart.tx as he is your primary interface for these kinds of requests.

Just to confirm, I have reproduced the issue using scotest but interestingly in my case I get similar behavior on my desktop as well as with a Raspberry Pi.

Hi @aaronb

I am investigating your case. So you want use audio over bluetooth for phone calls. Which audio output are you using? USB speaker?

By the way, did you try to use Bluetooth Alsa instead of Pulseaudio, which is not best suite for embedded devices.

Answering also your question about the SCO over USB, I think so that it is already configured like that since the Azurewifi chip is connected to the SoC over USB interface.

Best regards,
Jaski

Thanks @jaski.tx. For testing I was using USB headset. We have tried bluez-alsa which also didn’t work. Fundamentally, we can’t get “scotest -c” to work. This is a utility that just tests creating an SCO connection. If we can’t get that working pluse/bluez-alsa won’t matter.

Have you been able to get a HSP/HFP connection working using the Apalis-iMX8 SOM?

Hi @aaronb

You are welcome. I did not achieve till now to make the HSP/HFP connection and scotest work. I will update you once I got any results.

Best regards,
Jaski

@jaski.tx Any update on this? It has been almost two months, does HSP/HFP bluetooth profile work on the Apalis-iMX8 SOM or not?