​How can I play audio codec and BT audio (WAV) on a PicoCore8MP?

  • The following steps enable playing a WAV file through a BT headphone.

    1) A Bluetooth stack is required, which is not enabled in our default image. The activation can be done by the local image configuration. Add the line CORE_IMAGE_EXTRA_INSTALL += " bluez5" to the end of the file "local.conf". This will add a Bluetooth stack to your image.

    2) To output audio via Bluetooth, you need the package bluez-alsa. The bluez-alsa project is not part of Yocto, so you have to add the recipes manually. In the attachment, you will find a ready-to-use recipe to add bluez-alsa to the image as well. For example, copy the contents of the archive to the directory "[path to BSP]/fsimx8mp-Y2021.07.1/[build-directory] /yocto-3.0-fus/sources/poky/meta/recipes-multimedia".

    3) Extend your local configuration with the package "bluez-alsa" -> CORE_IMAGE_EXTRA_INSTALL += " bluez-alsa".

    4) Build your image and play it on the board.

    5) The Bluetooth interface hci0 is normally disabled. You can use the command "hciconfig" to see the status. You activate it with the command hciconfig hci0 up.

    6) To use bluetoothstack you still have to start the daemon. This is possible in Yocto with systemd. You can start the daemon with the command "systemctl start bluetooth.servce". Make sure that this is turned off again after the reboot. For continuous operation "systemctl enable bluetooth.service" is necessary.

    7) Now you can search for your Bluetooth headphones. For this, you can use the program "bluetoothctl".

    a. With help you can display available commands.

    b. Command "power on" activates the interface

    c. Command "scan on" switches on the search function. With this, you get the MAC address of your device. As soon as you know it, you can switch off the search (scan off).

    d. With the command "pair [MAC]" you initiate the connection setup.

    e. With the command "trust [MAC]" you mark the device as confidential.

    f. Use the "connect [MAC]" command to indicate that the device can actually be used.

    g. If everything is successful, then you can use the tool aplay to output for example a wav file

    8)The command to do this is "aplay -D bluealsa:DEV=[MAC],PROFILE=a2dp file.wav

    Link to a related forum contribution


    • bluez-alsa.zip

      (1.23 kB, downloaded 17 times, last: )
    • local_conf.zip

      (717 Byte, downloaded 17 times, last: )

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.