Audio with Yocto and the iMX8M Mini

Hello,

I have a Verdin iMX8M Mini on a Dahlia Carrier Board Rev 1.1. I use Yocto and I have been trying to play and record audio following this: Audio (Linux) | Toradex Developer Center

Using the Easy Installer, I used the Multimedia Reference Image and tried some of the steps, but nothing seems to work properly:

root@verdin-imx8mm-06898530:/# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=imx8mmnau8822
    imx8mm-nau8822,
    Default Audio Device
root@verdin-imx8mm-06898530:/# cat /proc/asound/cards
 0 [imx8mmnau8822  ]: imx8mm-nau8822 - imx8mm-nau8822
                      imx8mm-nau8822
root@verdin-imx8mm-06898530:/# amixer set "Capture" cap
amixer: Unable to find simple control 'Capture',0

I have the same exact results as in this ticket: Record and play audio Verdin iMX8M Mini - Technical Support - Toradex Community

But, the solution indicated is for Torizon Core. It seems to me that the problem is the same (the device tree being used). How do I set the desired device tree, i.e., imx8mm-verdin-wifi-dahlia.dts in a custom layer using Yocto?

Thank you for your time and answers,

Hello @mnano

Your output of aplay -L shows a NAU8822 codec, which is not present on the Dalia carrier board, only on the Verdin development board.

The Dahlia carrier board uses a WM8904 codec

As you pointed out this issue comes from the wrong device tree being loaded:

Unfortunately I don’t have a Verdin iMX8M Mini at hand, but I have been able to reproduce the issue with a Verdin iMX8M Plus , and as a quick test, adapted the solution from that thread

For your SoM it should be:

fw_setenv board 'dahlia-imx8mm'
fw_setenv board_name 'dahlia-imx8mm'
fw_setenv fdt_board 'dahlia'
fw_setenv fdtfile 'imx8mm-verdin-wifi-dahlia.dtb'
reboot now

Then try playing some sound, for example:

aplay -D sysdefault:CARD=imx8mpwm8904 /home/root/sound/Gong.wav

Can you try and check if that works for you?

For the production version of your image, here you have information about how to load your custom device tree on a Yocto build:

Best regards,
Josep

Hello,

Thank you for your answer. Using fw_setenv to set the correct device tree did indeed work as intended.

However, I still do not know how to implement it correctly in my custom layer. It is not clear to me from the link you gave how to do that. I tried setting KERNEL_DEVICETREE in machine-extra.conf (which is included by my-distro.conf):

KERNEL_DEVICETREE = " freescale/imx8mm-verdin-wifi-dahlia.dtb"

But, I got this error while booting:

## Executing script at 50280000
Loading DeviceTree: imx8mm-verdin-wifi-dev.dtb
Failed to load 'imx8mm-verdin-wifi-dev.dtb'
Booting from mmc failed!

Seems to come from u-boot-initial-env-sd:

preboot=test -n ${fdtfile} || setenv fdtfile imx8mm-verdin-${variant}-${fdt_board}.dtb
(...)
fdt_board=dev

How to properly set that? And how come I also get this wrong device tree when I install a reference image through Easy Installer

Hello @mnano

Here are the result of a test that I did on my Verdin iMX8M Plus (it should work on your Verdin iMX8X Mini as well)

  • Downloaded the reference multimedia image from here:
  • Extracted the contents of the file

  • Made the following changes on u-boot-initial-env-sd:
    fdt_board=dahlia instead of fdt_board=dev

  • Wrote the whole folder to a USB drive

  • Put the SoM in recovery mode and connect te USB drive to the carrier board

  • Install the newly created image via USB

  • Play the gong sound
    aplay -D sysdefault:CARD=imx8mpwm8904 /home/root/sound/Gong.wav

That avoids the need to create a custom layer just for this change

Best regards,
Josep