BlueZ5 and A2DP Sink on Freescale i.MX6Q/DL SabreSD

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

BlueZ5 and A2DP Sink on Freescale i.MX6Q/DL SabreSD

BlueZ5 and A2DP Sink on Freescale i.MX6Q/DL SabreSD

BlueZ5 provides support for the core Bluetooth layers and protocols. It is flexible, efficient and uses a modular implementation. BlueZ5 has implemented the Bluetooth low level host stack for Bluetooth core specification 4.0 and 3.0+HS which includes GAP, L2CAP, RFCOMM, and SDP. Besides the host stack, BlueZ5 has also supported the following profiles itself or via a third party software.

  • Profiles provided by BlueZ:
    • A2DP 1.3
    • AVRCP 1.5
    • DI 1.3
    • HDP 1.0
    • HID 1.0
    • PAN 1.0
    • SPP 1.1
    • GATT (LE) profiles:
      • PXP 1.0
      • HTP 1.0
      • HoG 1.0
      • TIP 1.0
      • CSCP 1.0
  • OBEX based profiles (by obexd):
    • FTP 1.1
    • OPP 1.1
    • PBAP 1.1
    • MAP 1.0
  • Provided by the oFono project:
    • HFP 1.6 (AG & HF)Supported Profiles


BlueZ5 has been supported in the latest Freescale Linux BSP release, so it would be pretty easy to generate the binaries for Bluetooth core stack and its profiles. In order to support A2DP sink on a SabreSD board, the following software should be downloaded and installed onto the target rootfs too.


PulseAudio package has some dependencies with bluetooth and sbc packages, and pulseaudio will detect if the two packages have been built and then decide which pulse plugin modules to be generated. So the building order will be 1) bluez5_utils or bluez_utils   2) sbc   3) pulseaudio.

After compile and install the above software onto the target rootfs, you should be able to see the following executable under the directory /usr/bin

  • From BlueZ5: bluetoothctl, hciconfig, hciattach (Needed by operating a UART bluetooth module)
  • From PulseAudio: pulseaudio, pactl, paplay

If the building dependency has been setup correctly, the following pulse plugin modules should be located under the directory /usr/lib/pulse-5.0/modules

  • module-bluetooth-discover.so      module-bluetooth-policy.so        module-bluez5-device.so   module-bluez5-discover.so

Edit the file /etc/dbus-1/system.d/pulseaudio-system.conf, and add the following lines in red:

<policy user="pulse">

    <allow own="org.pulseaudio.Server"/>

   <allow send_destination="org.bluez"/>

    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>

</policy>

Edit the file /etc/dbus-1/system.d/bluetooth.conf, and add the following lines:

<policy user="pulse">

     <allow send_destination="org.bluez"/>

     <allow send_interface="org.freedesktop.DBus.ObjectManager"/>

</policy>

Adding the following settings at the bottom of the pulseaudio system configuration file which locates in /etc/pulse/system.pa

### Automatically load driver modules for Bluetooth hardware

.ifexists module-bluetooth-policy.so

load-module module-bluetooth-policy

.endif

.ifexists module-bluetooth-discover.so

load-module module-bluetooth-discover

.endif

load-module module-switch-on-connect

load-module module-alsa-sink device_id=0 tsched=true tsched_buffer_size=1048576 tsched_buffer_watermark=262144


On the system that can automatically detect the alsa cards, the above line #13 should be removed. 

Also make sure "auth-anonymous=1" is added to the following line, which can resolve the issue: "Denied access to client with invalid authorization data".

load-module module-native-protocol-unix auth-anonymous=1


Selecting a audio re-sampling algorithm and configuring the audio output by adding the following settings to the file daemon.conf locating in /etc/pulse

resample-method = trivial

enable-remixing = no

enable-lfe-remixing = no

default-sample-format = s16le

default-sample-rate = 48000

alternate-sample-rate = 24000

default-sample-channels = 2

Pulseaudio can be started as a daemon or as a system-wide instance. To run PulseAudio in system-wide mode, the program will automatically drop privileges from "root" and change to the "pulse" user and group. In this case, before launching the program, the "pulse" user and group needs to be created on the target system.  In the example below, "/var/run/pulse" is the home directory for "pulse" user.

adduser -h /var/run/pulse pulse

addgroup pulse-access

adduser pulse pulse-access

Because PulseAudio needs to access the sound devices, add the user "pulse" to the "audio" group too.

adduser pulse audio

Starting bluetoothd and pulseaudio:

/usr/libexec/bluetooth/bluetoothd -d &

pulseaudio --system --realtime &

To verify if the pulseaudio has been set up correctly, you can play a local wave file by using the following command. If you can hear the sound, the system should have been configured correctly.

paplay -vvv audio8k16S.wav

After setting up the pulseaudio, launch bluetoothctl to pair and connect to a mobile phone. After connecting to a mobile phone, you should be able to see the following information in bluetoothctl console:

[bluetooth]# show

Controller 12:60:41:7F:03:00

        Name: BlueZ 5.21

        Alias: BlueZ 5.21

        Class: 0x1c0000

        Powered: yes

        Discoverable: no

        Pairable: yes

        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)

        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)

        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)

        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)

        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)

        UUID: Message Notification Se.. (00001133-0000-1000-8000-00805f9b34fb)

        UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)

        UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)

        UUID: IrMC Sync                 (00001104-0000-1000-8000-00805f9b34fb)

        UUID: OBEX File Transfer        (00001106-0000-1000-8000-00805f9b34fb)

        UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)

        UUID: Vendor specific           (00005005-0000-1000-8000-0002ee000001)

        UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)

        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)

        Modalias: usb:v1D6Bp0246d0515

        Discovering: no

If you can see the audio sink UUID, you are ready to enjoy the bluetooth music now.

コメント

Hi,

I am using bluez 5.30 in android Kitkat 4.4.2, It's working fine and i am getting all the profiles except spp. if i try to browse spp it shows an error like "No SDP records found". Can anyone please help me to solve this problem.

Hi Shenwei Wang,

Which Bluetooth module you test ?

AR6233X or other chip setting ?

I tested with some Bluetooth USB dongles. In theory, it should be working with any USB module as long as the HCI interface is ready.

Shenwei

What reason is it ?????

pastedImage_0.png

pastedImage_0.png

Hi Shenwei Wang,

The configuration you have provided is working absolutely fine in fsl(Freescale) image generated by using yocto.

Kernel version : 4.1.15

Bluez version : 5.33

pulseaudio version: 6.0, so with these versions of packages I am able to play some music from bluetooth.

But when I am trying to use fsl-qt image, the file's which needs to be edit are not even available in corresponding directories(/etc/dbus-1/system.d/pulseaudio-system.conf, /etc/dbus-1/system.d/bluetooth.conf, and /etc/pulse/system.pa). The same version of Bluez and pulseaudio I am using in fsl-qt image also.

 

"show" command in bluetoothctl console is  giving the following log:

Controller 43:39:00:00:1F:AC
         Name: BlueZ 5.33
         Alias: BlueZ 5.33
         Class: 0x200000
         Powered: yes
         Discoverable: no
         Pairable: yes
         UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
         UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
         UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
         UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
         UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb)
         UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
         Modalias: usb:v1D6Bp0246d0521
         Discovering: no

So here I am not getting UUID: Audio Source / UUID: Audio Sink which means I can't stream audio from bluetooth.

 Please provide some inputs regarding this.

Thanks in  advance.

 

Regards,

Ganapathirao

Hi Shengwei,

I followed your guide and finally I can get bluetooth audio streaming working on i.MX7d. But I only can hear the bluetooth audio on the left side of the headphone.

Furthermore, if I run aplay audio.wav then I can hear the audio on both sides of the headphone. Running paplay audio.wav, unfortunately I have the same issue like bluetooth streamig: I only hear the audio on the left side of the headphone.

Where can I change the setting so that I can hear the audio on both channels of the headphone?

Following the info about the sink:

---------------------------------------------------------------------------------------------------------

 sink(s) available.
  * index: 0
        name: <alsa_output.platform-sound.analog-mono>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
        state: SUSPENDED
        suspend cause: IDLE
        priority: 9009
        volume: mono: 52057 /  79% / -6.00 dB
                balance 0.00
        base volume: 52057 /  79% / -6.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max request: 0 KiB
        max rewind: 0 KiB
        monitor source: 0
        sample spec: s16le 1ch 44100Hz
        channel map: mono
                     Mono
        used by: 0
        linked by: 0
        fixed latency: 99.95 ms
        card: 0 <alsa_card.platform-sound>
        module: 6
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "HiFi wm8731-hifi-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "wm8731-audio"
                alsa.long_card_name = "wm8731-audio"
                device.bus_path = "platform-sound"
                sysfs.path = "/devices/soc0/sound/sound/card0"
                device.form_factor = "internal"
                device.string = "hw:0"
                device.buffering.buffer_size = "8816"
                device.buffering.fragment_size = "2204"
                device.access_mode = "mmap"
                device.profile.name = "analog-mono"
                device.profile.description = "Analog Mono"
                device.description = "Built-in Audio Analog Mono"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        ports:
                analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
                        properties:

        active port: <analog-output>

---------------------------------------------------------------------------------------------------------

Thank you in advance

Xi

評価なし
バージョン履歴
最終更新日:
‎09-10-2020 01:38 AM
更新者: