Record and play audio Verdin iMX8M Mini

Hi,

I’m trying to record and play audio on my Verdin iMX8M Mini. I’ve connected a normal set of headphones to the 3,5 mm jack on the Dahlia Development board.
I’m following the guide for how to record and play sound [Audio (Linux) | Toradex Developer Center]
But neither recording or playback works. When I run the record command:
arecord -D hw:0,0 -V mono -c 2 -f S16_LE -r 48000 -t wav mic.wav
i get
arecord: pcm_read:2152: read error: Input/output error
and when I try to play a wav file i imported to the unit I get no errors but I can hear anything.

Do I need to configure the Dahlia carrier board somehow? Or is there any other settings I need to do on the imx8?

Best regards,
Pontus

Dear @pontusoim,

Hope you’re doing good. Would you please be able to share more information about your setup?

  • Which version of the Verdin iMX8M Mini are you using?
  • Which version of the Dahlia are you using?
  • Which OS Image are you running on the module? Did you do any modifications?
  • What is the device tree that your system is using? You can find it by entering u-boot and using printenv fdt_board. It should reference the Dahlia Carrier Board as it uses a different codec than the Evaluation Board.

Also, looking at this problem on a first look, it may be a problem linked to not selecting the right audio device. Can you please share the output of the following commands?

aplay -L

&

cat /proc/asound/cards

Also, as an additional check, did you run the following command before trying to record the audio?

amixer set "Capture" cap

It’s stated in this section of the Audio Linux page: Audio (Linux) | Toradex Developer Center

Best regards,
Guilherme

Hi,

I’m using the Verdin imx8mm dl 1GB WB IT V1.1B.
The Dahlia is the V1.1C.
I’m running a custom image that I made from TorizonCore Builder Tool guide. It’s based on the TorizonCore image without evaluation containers and I’m running a docker container at boot that has python and alsa and some other things installed.
How do I enter U-boot console with the Dahlia board? The U-boot page only talks about the Verdin, Apalis and Iris boards.

When I enter aplay -L i get:

null
Discard all samples (playback) or generate zero samples (capture)
hw:CARD=imx8mmnau8822,DEV=0
imx8mm-nau8822,
Direct hardware device without any conversions
plughw:CARD=imx8mmnau8822,DEV=0
imx8mm-nau8822,
Hardware device with all software conversions
default:CARD=imx8mmnau8822
imx8mm-nau8822,
Default Audio Device
sysdefault:CARD=imx8mmnau8822
imx8mm-nau8822,
Default Audio Device
dmix:CARD=imx8mmnau8822,DEV=0
imx8mm-nau8822,
Direct sample mixing device

cat /proc/asound/cards gives me:

0 [imx8mmnau8822 ]: imx8mm-nau8822 - imx8mm-nau8822
imx8mm-nau8822

But when I try amixer set “Capture” cap i get:

amixer: Unable to find simple control ‘Capture’,0

When i list the amixer controls with amixer scontrols i get this:

Simple mixer control ‘Headphone’,0
Simple mixer control ‘Headphone ZC’,0
Simple mixer control ‘Speaker’,0
Simple mixer control ‘Speaker RInversion’,0
Simple mixer control ‘Speaker ZC’,0
Simple mixer control ‘PCM’,0
Simple mixer control ‘Aux Boost’,0
Simple mixer control ‘ADC’,0
Simple mixer control ‘ADC 128x Oversampling’,0
Simple mixer control ‘ADC Companding’,0
Simple mixer control ‘ADC Inversion’,0
Simple mixer control ‘ALC Attack’,0
Simple mixer control ‘ALC Decay’,0
Simple mixer control ‘ALC Enable’,0
Simple mixer control ‘ALC Hold’,0
Simple mixer control ‘ALC Max Gain’,0
Simple mixer control ‘ALC Min Gain’,0
Simple mixer control ‘ALC Mode’,0
Simple mixer control ‘ALC Noise Gate’,0
Simple mixer control ‘ALC Noise Gate Threshold’,0
Simple mixer control ‘ALC Target’,0
Simple mixer control ‘AUX1 Output Mixer LDAC’,0
Simple mixer control ‘AUX1 Output Mixer LMIX’,0
Simple mixer control ‘AUX1 Output Mixer RDAC’,0
Simple mixer control ‘AUX1 Output Mixer RINMIX’,0
Simple mixer control ‘AUX1 Output Mixer RMIX’,0
Simple mixer control ‘AUX2 Output Mixer AUX1MIX Output’,0
Simple mixer control ‘AUX2 Output Mixer LDAC’,0
Simple mixer control ‘AUX2 Output Mixer LINMIX’,0
Simple mixer control ‘AUX2 Output Mixer LMIX’,0
Simple mixer control ‘AUXOUT’,0
Simple mixer control ‘DAC 128x Oversampling’,0
Simple mixer control ‘DAC Companding’,0
Simple mixer control ‘DAC Inversion’,0
Simple mixer control ‘DAC Limiter’,0
Simple mixer control ‘DAC Limiter Attack’,0
Simple mixer control ‘DAC Limiter Decay’,0
Simple mixer control ‘DAC Limiter Threshold’,0
Simple mixer control ‘Digital Loopback’,0
Simple mixer control ‘EQ Function’,0
Simple mixer control ‘High Pass Cut Off’,0
Simple mixer control ‘High Pass Filter’,0
Simple mixer control ‘L2/R2 Boost’,0
Simple mixer control ‘Left Input Mixer L2’,0
Simple mixer control ‘Left Input Mixer MicN’,0
Simple mixer control ‘Left Input Mixer MicP’,0
Simple mixer control ‘Left Output Mixer LAUX’,0
Simple mixer control ‘Left Output Mixer LDAC’,0
Simple mixer control ‘Left Output Mixer LINMIX’,0
Simple mixer control ‘Left Output Mixer RDAC’,0
Simple mixer control ‘PGA’,0
Simple mixer control ‘PGA Boost’,0
Simple mixer control ‘PGA ZC’,0
Simple mixer control ‘Right Input Mixer MicN’,0
Simple mixer control ‘Right Input Mixer MicP’,0
Simple mixer control ‘Right Input Mixer R2’,0
Simple mixer control ‘Right Output Mixer LDAC’,0
Simple mixer control ‘Right Output Mixer RAUX’,0
Simple mixer control ‘Right Output Mixer RDAC’,0
Simple mixer control ‘Right Output Mixer RINMIX’,0

Should the aplay and arecord commands work with headphones connected to the 3,5mm jack on the Dahlia board?

Best regards,
Pontus

Dear @pontusoim, thanks for the update!

As you can see here, your board uses the following audio device:

If we go back to the Audio (Linux) | Toradex Developer Center page, you can see that it’s linked to the codec on the Verdin Development Board. Therefore, you may be using the wrong device tree. Thus, the audio interface on Dahlia will not work as expected.

So, regarding your questions:

On the Dahlia, there are two USB-C Ports. You shall connect the port referred to as Debug and you can connect to serial using, for instance, picocom on /dev/ttyUSB3. Then, when the system start to boot you need to interrupt the boot console.

However, as you’re using Torizon, there is an easier solution.

If you’re using the build command, you can set the desired device tree, i.e., imx8mm-verdin-wifi-dahlia.dts on the device-tree custom field. Then, all your images will have the right device tree.

Can you please give it a try?

Best regards,
Guilherme

Great, it works!

I have another question though. Will we be able to use another audio codec on our PCBs without changing the device trees to make it work? Or do we have to chose a audio codec that Toradex has a pre build device tree for?

Best regards,
Pontus

Dear @pontusoim,

I’m glad we could help you with your issue. Could you please tag it as solved?

About your last question:

You’re free to use every codec that would best fit your needs on a custom PCB that you build. You’d need, however, to write a new device tree accordingly. You can always base yourself on our design guides (https://docs.toradex.com/108140-verdin-carrier-board-design-guide.pdf) and on our device tree sample codes to write yours. If you chose one of the codecs that we have a pre-built device tree, you can profit from a quicker integration as we’ve done and tested it on our side already.

Lastly, you should check if you have the proper kernel modules already enabled for the codec driver to work. To check the ones that are already available on your Torizon distro you could run zcat /proc/config.gz on your module.

If you have your custom device tree properly configured and the right kernel configuration, I don’t see any issue to use another codec on your custom PCB.

Best regards,

Great, thanks a lot for the help!

1 Like