none
Posts: 10
Joined: Sat Dec 01, 2012 5:50 pm

[solved] I2S , dtoverlay=max98357a, "no soundcards found"

Tue Jun 02, 2020 8:18 am

Rpi Zero W 1.1, 2020-05-27-raspios-buster-lite-armhf.zip upgraded just now.
Setting up raspberrypi-kernel (1.20200601-1) ...
4.19.118+

A max98357a mono I2S DAC works (partially) when loading

Code: Select all

dtoverlay=hifiberry-dac
but fails with

pi@raspberrypi:~ $ sudo nano /boot/config.txt

Code: Select all

dtdebug=1
dtoverlay=max98357a
#dtparam=audio=on

Code: Select all

pi@raspberrypi:~ $ aplay -l
aplay: device_list:272: no soundcards found...
pi@raspberrypi:~ $ sudo vcdbg log msg

Code: Select all

001518.803: brfs: File read: /mfs/sd/config.txt
001519.182: brfs: File read: 1871 bytes
001524.281: dtdebug: Opened overlay file 'overlays/max98357a.dtbo'
001525.840: brfs: File read: /mfs/sd/overlays/max98357a.dtbo
001546.623: Loaded overlay 'max98357a'
001549.138: dtdebug: fragment 2 disabled
001550.748: dtdebug: fragment 4 disabled
001560.776: dtdebug: merge_fragment(/soc/i2s@7e203000,/fragment@0/__overlay__)
001560.804: dtdebug:   +prop(status)
001561.824: dtdebug: merge_fragment() end
001561.984: dtdebug: merge_fragment(/,/fragment@1/__overlay__)
001573.401: dtdebug: merge_fragment(/max98357a,/fragment@1/__overlay__/max98357a)
001573.425: dtdebug:   +prop(compatible)
001574.861: dtdebug:   +prop(#sound-dai-cells)
001576.428: dtdebug:   +prop(sdmode-gpios)
001578.281: dtdebug:   +prop(status)
001579.805: dtdebug:   +prop(phandle)
001581.341: dtdebug: merge_fragment() end
001581.370: dtdebug: merge_fragment() end
001581.497: dtdebug: fragment 2 disabled
001598.911: dtdebug: merge_fragment(/soc/sound,/fragment@3/__overlay__)
001598.937: dtdebug:   +prop(compatible)
001599.506: dtdebug:   +prop(simple-audio-card,format)
001600.477: dtdebug:   +prop(simple-audio-card,name)
001601.462: dtdebug:   +prop(status)
001608.523: dtdebug: merge_fragment(/soc/sound/simple-audio-card,cpu,/fragment@3/__overlay__/simple-audio-card,cpu)
001608.555: dtdebug:   +prop(sound-dai)
001609.531: dtdebug: merge_fragment() end
001616.214: dtdebug: merge_fragment(/soc/sound/simple-audio-card,codec,/fragment@3/__overlay__/simple-audio-card,codec)
001616.244: dtdebug:   +prop(sound-dai)
001617.226: dtdebug: merge_fragment() end
001617.254: dtdebug: merge_fragment() end
001617.441: dtdebug: fragment 4 disabled
It seems this would use the device with SD pin (shutdown) on GPIO4, which is as intendend.

Code: Select all

$ dtc -I fs /proc/device-tree

<stdout>: Warning (clocks_property): /soc/i2s@7e203000:clocks: cell 0 is not a phandle reference
...
<stdout>: Warning (dmas_property): /soc/i2s@7e203000:dmas: cell 0 is not a phandle reference
<stdout>: Warning (dmas_property): /soc/i2s@7e203000:dmas: cell 2 is not a phandle reference
...
<stdout>: Warning (sound_dai_property): /soc/sound/simple-audio-card,cpu:sound-dai: cell 0 is not a phandle reference
<stdout>: Warning (sound_dai_property): /soc/sound/simple-audio-card,codec:sound-dai: cell 0 is not a phandle reference
...
<stdout>: Warning (gpios_property): /max98357a:sdmode-gpios: cell 0 is not a phandle reference

...

        __overrides__ {
        ...
                i2s = [ 00 00 00 1e 73 74 61 74 75 73 00 ];
... 

                        i2s {
                                brcm,pins = < 0x12 0x13 0x14 0x15 >;
                                phandle = < 0x0c >;
                                brcm,function = < 0x04 >;
                        };

...

                i2s@7e203000 {
                        compatible = "brcm,bcm2835-i2s";
                        clocks = < 0x03 0x1f >;
                        #sound-dai-cells = < 0x00 >;
                        status = "okay";
                        dma-names = "tx\0rx";
                        phandle = < 0x1e >;
                        reg = < 0x7e203000 0x24 >;
                        pinctrl-0 = < 0x0c >;
                        dmas = < 0x0a 0x02 0x0a 0x03 >;
                        pinctrl-names = "default";
                };

...

        max98357a {
                compatible = "maxim,max98357a";
                #sound-dai-cells = < 0x00 >;
                status = "okay";
                phandle = < 0x74 >;
                sdmode-gpios = < 0x0f 0x04 0x00 >;
        };


Code: Select all

pi@raspberrypi:~ $ cat /proc/device-tree/max98357a/status
okay 
pi@raspberrypi:~ $ sudo depmod
pi@raspberrypi:~ $ sudo dtparam -l
No overlays loaded
pi@raspberrypi:~ $ sudo dtparam i2s
pi@raspberrypi:~ $ sudo dtparam -l
Overlays (in load order):
0:  dtparam  i2s=true
pi@raspberrypi:~ $ sudo dtoverlay -l
Overlays (in load order):
0:  dtparam  i2s=true
pi@raspberrypi:~ $ sudo dtoverlay max98357a
* Failed to apply overlay '1_max98357a' (kernel)
pi@raspberrypi:~ $

Any help appreciated.

https://www.raspberrypi.org/documentati ... md#part3.5

EDIT:

Code: Select all


pi@raspberrypi:~ $ cat /proc/device-tree/soc/sound/*
simple-audio-card sound    pcat: /proc/device-tree/soc/sound/simple-audio-card,codec: Is a directory
cat: /proc/device-tree/soc/sound/simple-audio-card,cpu: Is a directory
i2s MAX98357A okay

pi@raspberrypi:~ $ cat /proc/asound/cards
--- no soundcards ---

pi@raspberrypi:~ $ lsmod | grep snd
snd_soc_simple_card    16384  0
snd_soc_bcm2835_i2s    20480  0
snd_soc_simple_card_utils    16384  1 snd_soc_simple_card
regmap_mmio            16384  1 snd_soc_bcm2835_i2s
snd_soc_core          192512  3 snd_soc_simple_card_utils,snd_soc_bcm2835_i2s,snd_soc_simple_card
snd_compress           20480  1 snd_soc_core
snd_pcm_dmaengine      16384  1 snd_soc_core
snd_pcm                98304  3 snd_pcm_dmaengine,snd_soc_bcm2835_i2s,snd_soc_core
snd_timer              32768  1 snd_pcm
snd                    73728  4 snd_compress,snd_timer,snd_soc_core,snd_pcm
Last edited by none on Wed Jun 03, 2020 6:06 am, edited 1 time in total.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4655
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2S , dtoverlay=max98357a, "no soundcards found"

Tue Jun 02, 2020 9:31 am

The max98357a overlay isn't working for you because the Raspberry Pi kernels don't include the MAX98357A driver module. I've added it to our standard configurations, and the required module should be in future releases.

none
Posts: 10
Joined: Sat Dec 01, 2012 5:50 pm

Re: I2S , dtoverlay=max98357a, "no soundcards found"

Tue Jun 02, 2020 11:45 am

Thanks!
How would I get this configuration so I can build the module?
Manual changes to .config get overwritten (as it says) and menuconfig does not seem to offer an MAX98357A option.
Unfortunately, I don't know which switches to put where, maybe linux/arch/arm/configs/bcmrpi_defconfig?

Hold that thought, trying menuconfig for cross-compilation again.. NO

Code: Select all

.config - Linux/arm 4.19.122 Kernel Configuration
 > Device Drivers > Sound card support > Advanced Linux Sound Architecture > ALSA for SoC audio support > CODEC drivers

none
Posts: 10
Joined: Sat Dec 01, 2012 5:50 pm

Re: I2S , dtoverlay=max98357a, "no soundcards found"

Tue Jun 02, 2020 12:08 pm

Ah, I've added

Code: Select all

select SND_SOC_MAX98357A
to

Code: Select all

linux/sound/soc/bcm/Kconfig
's config SND_BCM2708_SOC_HIFIBERRY_DAC and that causes CONFIG_SND_SOC_MAX98357A=m to be written to config and the module to be built.

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: MAX98357A [MAX98357A], device 0: bcm2835-i2s-HiFi HiFi-0 [bcm2835-i2s-HiFi HiFi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0


But "front right" is silent with SD connected

Code: Select all

pi@raspberrypi:~ $ speaker-test -c2

speaker-test 1.1.8

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 8192
Period size range from 1024 to 1024
Using max buffer size 8192
Periods = 4
was set period_size = 1024
was set buffer_size = 8192
 0 - Front Left
 1 - Front Right
^CWrite error: -4,Interrupted system call
xrun_recovery failed: -4,Interrupted system call
Transfer failed: Interrupted system call
This may be a hardware issue for the IC or an /etc/asound.conf issue:

Code: Select all

pi@raspberrypi:~ $ cat /etc/asound.conf
    pcm.speakerbonnet {
       type hw card 0
    }
     
    pcm.dmixer {
       type dmix
       ipc_key 1024
       ipc_perm 0666
       slave {
         pcm "speakerbonnet"
         period_time 0
         period_size 1024
         buffer_size 8192
         rate 44100
         channels 2
       }
    }
     
    ctl.dmixer {
        type hw card 0
    }
     
    pcm.softvol {
        type softvol
        slave.pcm "dmixer"
        control.name "PCM"
        control.card 0
    }
     
    ctl.softvol {
        type hw card 0
    }
     
    pcm.!default {
        type             plug
        slave.pcm       "softvol"
    }

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4655
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2S , dtoverlay=max98357a, "no soundcards found"

Tue Jun 02, 2020 1:28 pm

The kconfig files in 4.19 don't have a description string for the MAX98357 setting, so the only way to enable or is to select it from some other setting - I think there's a CODEC_ALL, or similar. In 5.4 there is a description for the setting, so it can be enabled with menuconfig etc. As future kernel releases will be 5.4, that's where I've made the change.


none
Posts: 10
Joined: Sat Dec 01, 2012 5:50 pm

Re: [solved] I2S , dtoverlay=max98357a, "no soundcards found"

Sat Jun 06, 2020 11:04 am

none wrote:But "front right" is silent with SD connected
Driving the SD pin high (3.3V) overrides the voltage divider and causes the IC to output the left channel only.
Solutions:
1. Mix stereo down to mono/left in ALSA
2. fix hardware by removing the pull-up resistor and placing a suitable resistor in series with SD
3. use open drain switch (and invert output )
4. modify driver to not drive output high but switch to input (high-z) without internal pull-up

Return to “Device Tree”