Play audio on DUO256 using Buildroot SDK V2

Hello,

I am really sorry if my question seems stupid but I recently acquired my first DUO256 card, and I would like to use it to play sound using the GPIO PIN 34. I am a beginner in embedded computing and electronics in general.

I flashed an SD Card using the new Buildroot SDK V2 image, which seems to include ALSA tools (like aplay) by default but I am unable to play sound. A device is listed when running aplay -l:

[root@milkv-duo]~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: cv182xadac [cv182xa_dac], device 0: cviteka-dac 300a000.dac-0 [cviteka-dac 300a000.dac-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
[root@milkv-duo]~# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=cv182xadac
    cv182xa_dac, cviteka-dac 300a000.dac-0
    Default Audio Device
sysdefault:CARD=cv182xadac
    cv182xa_dac, cviteka-dac 300a000.dac-0
    Default Audio Device

Here is an extract of the dmesg logs:

[    1.097437] usbcore: registered new interface driver snd-usb-audio
[    1.104834] cvitek-i2s 4100000.i2s: cvi_i2s_probe
[    1.116793] cvitek-i2s 4130000.i2s: cvi_i2s_probe
[    1.122418] cviteka-adc sound_adc: cviteka_adc_probe, dev name=sound_adc
[    1.129509] cviteka-adc sound_adc: cviteka_adc_probe start devm_snd_soc_register_card
[    1.138078] cvitekaadc 300a100.adc: cvitekaadc_probe
[    1.148960] cviteka-dac sound_dac: cviteka_dac_probe, dev name=sound_dac
[    1.156336] cvitekadac 300a000.dac: cvitekadac_probe
[    1.161816] cvitekadac_probe gpio_is_valid mute_pin_l
[    1.168251] NET: Registered protocol family 10
[    1.174341] Segment Routing with IPv6
[    1.178337] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    1.185431] NET: Registered protocol family 17
[    1.190326] Loading compiled-in X.509 certificates
[    1.227474] i2c_designware 4010000.i2c: running with gpio recovery mode! scl,sda
[    1.242227] mmc0: new high speed SDHC card at address b36a
[    1.248698] i2c_designware 4020000.i2c: running with gpio recovery mode! scl,sda
[    1.257431] i2c_designware 4030000.i2c: running with gpio recovery mode! scl,sda
[    1.265673] mmcblk0: mmc0:b36a CBADS 29.3 GiB 
[    1.272491]  mmcblk0: p1 p2
[    1.275696] cviteka-adc sound_adc: cviteka_adc_probe, dev name=sound_adc
[    1.283706] cviteka-adc sound_adc: cviteka_adc_probe start devm_snd_soc_register_card
[    1.297286] cviteka-dac sound_dac: cviteka_dac_probe, dev name=sound_dac
[    1.309985] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.320881] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.327931] cfg80211: failed to load regulatory.db
[    1.333140] ALSA device list:
[    1.336590] dw-apb-uart 4140000.serial: forbid DMA for kernel console

Here is what happen when I try to play music:

[root@milkv-duo]~# aplay --device default test-music.wav 
aplay: main:850: audio open error: No such file or directory

Am I missing something?

Thank you in advance for your help!

1 Like

I think you already found the answer but I’ll leave a reply here for anyone who came across this post while searching.

(1) Temporary Answer:

To playback, use

aplay -Dhw:1

And to record, use

arecord -Dhw:0

Details:

When you run aplay -l and arecord -l to check available devices for playback/record, you can see that card1 and card0 are mentioned on each log. These device number should be specified otherwise aplay: main:850: audio open error: No such file or directory error will appear.

[root@milkv-duo]/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: cv182xadac [cv182xa_dac], device 0: cviteka-dac 300a000.dac-0 [cviteka-dac 300a000.dac-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

[root@milkv-duo]/# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: cv182xaadc [cv182xa_adc], device 0: cviteka-adc 300a100.adc-0 [cviteka-adc 300a100.adc-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

(2) Permanent Answer

You can specify the default device as a configuration file, so that you don’t have to specify -Dhw:x everytime when you run arecord or aplay.

If you are familiar with vi text editor, just jump to step 3 and copy that to /usr/etc/asound.conf.

If you are not familiar with using vi text editor, please follow the below instruction carefully.


On DUO256, run below

1. Create a directory if necessary

mkdir /usr/etc

2. Create an Alsa configuration file

vi /usr/etc/asound.conf

3. Modify Alsa configuration file

Press i on keyboard and paste the below code block in asound.conf

pcm.!default {

        type asym

        playback.pcm {
                type hw
                card 1
                device 0
        }

        capture.pcm {
                type plug
                slave {
                        pcm {
                                type hw
                                card 0
                                device 0
                        }
                }
        }
}

4. Save and exit

  1. Press esc
  2. Press :
  3. Type in wq
  4. Press Enter

5. Now the default device is configured. aplay and arecord can be run without specifying device number.

[root@milkv-duo]~# arecord -d 5 -f S16_LE -r 48000 -c 1 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
[root@milkv-duo]~# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
3 Likes