Audio | Mallow board | Codec WM8904

Hi Toradex team,

Hope you can give me some guidance over here.
I’m trying to create an overlay to enable the WM8904 codec on my Mallow board. I don’t have all the information on my side but a previous HW colleague used the reference design of the Dahlia board and used the same DAC on a custom hardware extension board that is connected to the Mallow board.

I have base by .dts file on the Dahlia and Verdin available on toradex git but i’m getting errors while building using the Torizon Builde plugin on the Visual Code.

My .dts file is as follow:

/dts-v1/;
/plugin/;

/ {
    compatible = "toradex,verdin-imx8mp-mallow";
    
    /* Simple Audio Card */
    sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "Mallow-I2S";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&codec_dai>;
        simple-audio-card,frame-master = <&codec_dai>;
        simple-audio-card,mclk-fs = <256>;
        simple-audio-card,routing =
            "Headphone Jack", "HPOUTL",
            "Headphone Jack", "HPOUTR",
            "IN2L", "Line In Jack",
            "IN2R", "Line In Jack",
            "Headphone Jack", "MICBIAS",
            "IN1L", "Headphone Jack";
        simple-audio-card,widgets =
            "Microphone", "Headphone Jack",
            "Headphone", "Headphone Jack",
            "Line", "Line In Jack";

        codec_dai: simple-audio-card,codec {
            clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1>;
            sound-dai = <&wm8904_1a>;
        };

        simple-audio-card,cpu {
            sound-dai = <&sai1>;
        };
    };

    /* Enable I2C3 */
    &i2c3 {
        status = "okay";
    };

    /* Audio Codec on I2C4 */
    &i2c1 {
        status = "okay";

        wm8904_1a: audio-codec@1a {
            compatible = "wlf,wm8904";
            reg = <0x1a>;
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_sai1>;
            #sound-dai-cells = <0>;
            clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1>;
            clock-names = "mclk";
            AVDD-supply = <&reg_1p8v>;
            CPVDD-supply = <&reg_1p8v>;
            DBVDD-supply = <&reg_1p8v>;
            DCVDD-supply = <&reg_1p8v>;
            MICVDD-supply = <&reg_1p8v>;
        };
    };

    /* Verdin I2S_1 */
    &sai1 {
        assigned-clocks = <&clk IMX8MP_CLK_SAI1>;
        assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
        assigned-clock-rates = <24576000>;
        fsl,sai-mclk-direction-output;
        status = "okay";
    };

    /* Pin Control for SAI1 */
    &pinctrl_sai1 {
        fsl,sai1-bclk {
            fsl,pins = <
                MX8MP_IOMUXC_SAI1_TXFS__SAI1_TX_BCLK 0x1c6
            >;
        };

        fsl,sai1-tx {
            fsl,pins = <
                MX8MP_IOMUXC_SAI1_TXD0__SAI1_TX_DATA0 0x1c6
            >;
        };

        fsl,sai1-rx {
            fsl,pins = <
                MX8MP_IOMUXC_SAI1_RXD0__SAI1_RX_DATA0 0x1c6
            >;
        };

        fsl,sai1-mclk {
            fsl,pins = <
                MX8MP_IOMUXC_SAI1_MCLK__SAI1_MCLK 0x1c6
            >;
        };
    };

};

The errors i’m getting are

2025-01-28 18:38:16,250 - torizon.tcbuilder.cli.build - INFO - 
=> Adding device-tree overlay 'overlays/mallow-verdin-i2s-overlay.dts'
2025-01-28 18:38:16,402 - torizon.tcbuilder.backend.dt - ERROR - Error: overlays/mallow-verdin-i2s-overlay.dts:28.39-40 syntax error
FATAL ERROR: Unable to parse input tree
2025-01-28 18:38:16,403 - torizon.tcbuilder.cli.dto - ERROR - error: cannot apply overlays/mallow-verdin-i2s-overlay.dts.

I think this is related to the device-tree missing some flags, but of right now I don’t know how to overcome this, i’m a bit on high water here and still learning by trial.

I would appreciate any guidance/help you could provide me, or point me to the right path.
Thanks in advance :slight_smile:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.148-6.8.0+git.8c5c2dcbf6ba #1-TorizonCore SMP PREEMPT Tue Aug 6 10:01:59 UTC 2024
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.0/torizon/4ba8fb87dbcbe4eef169c350696ae1ce34e2585cf534963f9395709a06466082/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=6.8.0-build.22
Distro variant:           VARIANT="Docker"
Hostname:                 verdin-imx8mp-15459446
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus on Verdin Development Board
Toradex version:          0063 V1.1B
Serial number:            15459446
Processor arch:           aarch64
------------------------------------------------------------

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

Thank you for reaching out with your question. It sounds like you’re on the right track with your project, and I’d be happy to help you troubleshoot the syntax error you’re encountering in your device tree overlay.

The error message indicates a syntax issue at line 28 of your device tree source file. Here are some steps you can take to resolve this:

  1. Check Syntax and Structure:

    • Ensure all braces {} and semicolons ; are correctly placed. A missing or misplaced brace or semicolon can lead to syntax errors.
    • Verify that all node and property names are correctly spelled and formatted.
  2. Review the Error Line:

    • Focus on the specific line mentioned in the error message (line 28). Compare it with similar lines in a working device tree overlay to spot any discrepancies.
  3. Validate Node References:

    • Make sure all references to nodes, such as &codec_dai and &wm8904_1a, are correctly defined and match the expected names in the device tree.
    • Check that the sound-dai property correctly references the codec node.
  4. Use Correct Compatible Strings:

    • Ensure the compatible strings, like “wlf,wm8904”, are accurate and match the expected values for your hardware.
  5. Consult Reference Designs:

    • Since your design is based on the Dahlia board, compare your overlay with the reference device tree files for the Dahlia and Verdin boards to ensure consistency.
  6. Test Incrementally:

    • If the error persists, try simplifying your device tree overlay by removing sections and testing incrementally to isolate the problematic part.

By carefully reviewing these aspects, you should be able to identify and correct the error. If you continue to experience issues, consider checking other parts of the overlay for similar syntax problems. This approach will help ensure that your WM8904 codec is correctly configured on the Mallow board.

I hope this helps, and I wish you success with your project!

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Deployment of custom audio codec driver.

According to the error message you provided, the compiler cannot recognize the IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1 symbol

Try to add

#include <dt-bindings/clock/imx8mp-clock.h>

to your overrlay source code.

Hi Alex,

Thanks for the insight. You were correct but the header is missing the value I was using IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1, so I defined it.

Now I can create the image with the overlay but I think I’m missing something or doing something wrong.
The Audio DAC is using the I2S_1 of the Mallow adapter and the I2C_1
My .dts file right now:

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx8mp-clock.h>

#define IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1 1

/ {
    compatible = "toradex,verdin-imx8mp-mallow";

    /* Simple Audio Card */
    sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "Mallow-I2S";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&cpu_dai>;
        simple-audio-card,frame-master = <&cpu_dai>;
        simple-audio-card,mclk-fs = <256>;

        simple-audio-card,routing =
            "Headphone Jack", "HPOUTL",
            "Headphone Jack", "HPOUTR",
            "IN2L", "Line In Jack",
            "IN2R", "Line In Jack",
            "Headphone Jack", "MICBIAS",
            "IN1L", "Headphone Jack";

        simple-audio-card,widgets =
            "Microphone", "Headphone Jack",
            "Headphone", "Headphone Jack",
            "Line", "Line In Jack";

        simple-audio-card,cpu {
            sound-dai = <&sai1>;
        };

        simple-audio-card,codec {
            sound-dai = <&wm8904_1a>;
        };
    };
};

/* Enable I2C3 */
&i2c3 {
    status = "okay";
};

/* Verdin I2C_1 */
&i2c1 {
    status = "okay";

    /* Audio Codec */
    wm8904_1a: audio-codec@1a {
        compatible = "wlf,wm8904";
        reg = <0x1a>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai1>;
        #sound-dai-cells = <0>;
        clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1>;
        clock-names = "mclk";
        AVDD-supply = <&reg_1p8v>;
        CPVDD-supply = <&reg_1p8v>;
        DBVDD-supply = <&reg_1p8v>;
        DCVDD-supply = <&reg_1p8v>;
        MICVDD-supply = <&reg_1p8v>;
    };
};

/* Verdin I2S_1 */
&sai1 {
    assigned-clocks = <&clk IMX8MP_CLK_SAI1>;
    assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <24576000>;
    fsl,sai-mclk-direction-output;
    status = "okay";
};

The overlay was created and is being loaded when installing the image, but I’m getting this error:

U-Boot 2022.04-6.8.1+git.a31fdd543bee (Jan 01 1970 - 00:00:00 +0000)

CPU:   i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 39C
Reset cause: POR
DRAM:  4 GiB
Core:  89 devices, 23 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex 0063 Verdin iMX8M Plus Quad 4GB IT V1.1B
Serial#: 15459446
Carrier: Toradex UNKNOWN CARRIER BOARD V1.1B, Serial# 11420286
SEC0:  RNG instantiated

 BuildInfo:
  - ATF 3c1583b

flash target is MMC:2
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000 [PRIME]
Fastboot: Normal
Saving Environment to MMC... Writing to MMC(2)... OK
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc2(part 0) is current device
Scanning mmc 2:1...
Found U-Boot script /boot.scr
973 bytes read in 1 ms (950.2 KiB/s)
## Executing script at 50280000
7247 bytes read in 2 ms (3.5 MiB/s)
89810 bytes read in 2 ms (42.8 MiB/s)
149 bytes read in 2 ms (72.3 KiB/s)
Applying Overlay: verdin-imx8mp_hdmi_overlay.dtbo
2219 bytes read in 2 ms (1.1 MiB/s)
Applying Overlay: verdin-imx8mp_dsi-to-hdmi_overlay.dtbo
3652 bytes read in 2 ms (1.7 MiB/s)
Applying Overlay: verdin-imx8mp_spidev_overlay.dtbo
561 bytes read in 2 ms (273.4 KiB/s)
Applying Overlay: mallow-verdin-i2s-overlay.dtbo
2583 bytes read in 2 ms (1.2 MiB/s)
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND
libfdt fdt_path_offset() returned FDT_ERR_BADMAGIC
13441371 bytes read in 43 ms (298.1 MiB/s)
6151961 bytes read in 20 ms (293.3 MiB/s)
   Uncompressing Kernel Image
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
SCRIPT FAILED: continuing...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
MMC: no card present
Scanning disk mmc@30b50000.blk...
Disk mmc@30b50000.blk not ready
Scanning disk mmc@30b60000.blk...
Found 2 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image

my tcbuild.yaml

customization:
  # Customization section items.
  device-tree:
    include-dirs:
      - overlays/linux_5.15-2.2.x-imx/include    
    overlays:
      add:
        - overlays/mallow-verdin-i2s-overlay.dts        

Can you point me on the right direction?
Thanks :slight_smile:

Hello @af-silva,

This is not recommended.
If the definition is missing, it means that it is either in another file or that you need a different definition.
These definitions have important values, so just defining it to 1 may not help to achieve the intended configuration.

In your case, it seems that you may need IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1, which coincidentally has the value 1.

One problem I see is that you are using i2c1, but this I2C bus is only available internally on the Verdin SoM.
Do you intend to use I2C1 from the Verdin Specification?
If so, the correct node to use is i2c4.
Otherwise, the configuration seems to be overall correct, but I would also recommend that you change the compatible string to the following:

compatible = "toradex,verdin-imx8mp";

Best Regards,
Bruno

Hi Bruno,

Do you intend to use I2C1 from the Verdin Specification?

I intend to use the the I2C_1 of the Mallow board on pins 10 (SDA) and 11 (SCL).
image

I have correct my .dst file with your purposed changes and right now is as follow:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright 2020-2022 Toradex
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx8mp-clock.h>

/ {
    compatible = "toradex,verdin-imx8mp";

    /* Simple Audio Card */
	sound {
		compatible = "simple-audio-card";
		simple-audio-card,bitclock-master = <&codec_dai>;
		simple-audio-card,format = "i2s";
		simple-audio-card,frame-master = <&codec_dai>;
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "verdin-wm8904";
		simple-audio-card,routing =
			"Headphone Jack", "HPOUTL",
			"Headphone Jack", "HPOUTR",
			"IN2L", "Line In Jack",
			"IN2R", "Line In Jack",
			"Headphone Jack", "MICBIAS",
			"IN1L", "Headphone Jack";
		simple-audio-card,widgets =
			"Microphone", "Headphone Jack",
			"Headphone", "Headphone Jack",
			"Line", "Line In Jack";

		codec_dai: simple-audio-card,codec {
			clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1>;
			sound-dai = <&wm8904_1a>;
		};

		simple-audio-card,cpu {
			sound-dai = <&sai1>;
		};
	};
};

/* Verdin I2C_1 */
&i2c4 {
	status = "okay";

	/* Audio Codec */
	wm8904_1a: audio-codec@1a {
		compatible = "wlf,wm8904";
		reg = <0x1a>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_sai1>;
		#sound-dai-cells = <0>;
		clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1>;
		clock-names = "mclk";
		AVDD-supply = <&reg_1p8v>;
		CPVDD-supply = <&reg_1p8v>;
		DBVDD-supply = <&reg_1p8v>;
		DCVDD-supply = <&reg_1p8v>;
		MICVDD-supply = <&reg_1p8v>;
	};
};


/* Verdin I2S_1 */
&sai1 {
	assigned-clocks = <&clk IMX8MP_CLK_SAI1>;
	assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
	assigned-clock-rates = <24576000>;
	fsl,sai-mclk-direction-output;
	status = "okay";
};

But looking to the logs when the board is booting up I can see this:

U-Boot 2022.04-6.8.1+git.a31fdd543bee (Jan 01 1970 - 00:00:00 +0000)

CPU:   i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 42C
Reset cause: POR
DRAM:  4 GiB
Core:  89 devices, 23 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex 0063 Verdin iMX8M Plus Quad 4GB IT V1.1B
Serial#: 15459446
Carrier: Toradex UNKNOWN CARRIER BOARD V1.1B, Serial# 11420286
SEC0:  RNG instantiated

 BuildInfo:
  - ATF 3c1583b

flash target is MMC:2
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000 [PRIME]
Fastboot: Normal
Saving Environment to MMC... Writing to MMC(2)... OK
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc2(part 0) is current device
Scanning mmc 2:1...
Found U-Boot script /boot.scr
973 bytes read in 1 ms (950.2 KiB/s)
## Executing script at 50280000
7247 bytes read in 1 ms (6.9 MiB/s)
89810 bytes read in 3 ms (28.5 MiB/s)
149 bytes read in 2 ms (72.3 KiB/s)
Applying Overlay: verdin-imx8mp_hdmi_overlay.dtbo
2219 bytes read in 3 ms (721.7 KiB/s)
Applying Overlay: verdin-imx8mp_dsi-to-hdmi_overlay.dtbo
3652 bytes read in 3 ms (1.2 MiB/s)
Applying Overlay: verdin-imx8mp_spidev_overlay.dtbo
561 bytes read in 2 ms (273.4 KiB/s)
Applying Overlay: mallow-verdin-i2s-overlay.dtbo
2520 bytes read in 2 ms (1.2 MiB/s)
13441371 bytes read in 43 ms (298.1 MiB/s)
6151962 bytes read in 21 ms (279.4 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 50200000
   Booting using the fdt blob at 0x50200000
   Loading Device Tree to 00000000ffac0000, end 00000000ffaf8fff ... OK

Starting kernel ...

[    1.027707] pca953x 3-0021: failed writing register
[    1.065409] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.081591] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.092150] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    2.368806] +V3.3_SW: Underflow of regulator enable count
[    2.611417] [drm:drm_bridge_attach] *ERROR* failed to attach bridge /soc@0/bus@32c00000/mipi_dsi@32e60000 to encoder DSI-37: -517
[    2.623222] imx_sec_dsim_drv 32e60000.mipi_dsi: Failed to attach bridge: 32e60000.mipi_dsi
[    2.631523] imx_sec_dsim_drv 32e60000.mipi_dsi: failed to bind sec dsim bridge: -517
Starting version 250.5+
[    4.334256] systemd[1]: syslog.socket: Socket service syslog.service not loaded, refusing.
[    4.342788] systemd[1]: Failed to listen on Syslog Socket.
[FAILED] Failed to listen on Syslog Socket.
[DEPEND] Dependency failed for System Logging Service.
[    5.672562] ina2xx 3-0040: error configuring the device: -6
[    5.920702] fsl-aud2htx 30cb0000.aud2htx: failed to pcm register
[    5.938442] fsl-aud2htx 30cb0000.aud2htx: failed to pcm register
[    6.117849] imx-hdmi sound-hdmi: snd_soc_register_card failed (-517)
[    6.315220] fsl-aud2htx 30cb0000.aud2htx: failed to pcm register
[    6.326970] imx-hdmi sound-hdmi: snd_soc_register_card failed (-517)
[    6.369539] OF: /sound/simple-audio-card,codec: could not find phandle 176
[    6.376575] asoc-simple-card sound: parse error -22

If I change the i2c4 to i2c2 I get the following on the boot up logs:
The reason I’m trying the i2c2 is because of the verdin-i2c2 -> i2c-1

U-Boot 2022.04-6.8.1+git.a31fdd543bee (Jan 01 1970 - 00:00:00 +0000)

CPU:   i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 42C
Reset cause: POR
DRAM:  4 GiB
Core:  89 devices, 23 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex 0063 Verdin iMX8M Plus Quad 4GB IT V1.1B
Serial#: 15459446
Carrier: Toradex UNKNOWN CARRIER BOARD V1.1B, Serial# 11420286
SEC0:  RNG instantiated

 BuildInfo:
  - ATF 3c1583b

flash target is MMC:2
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000 [PRIME]
Fastboot: Normal
Saving Environment to MMC... Writing to MMC(2)... OK
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc2(part 0) is current device
Scanning mmc 2:1...
Found U-Boot script /boot.scr
973 bytes read in 1 ms (950.2 KiB/s)
## Executing script at 50280000
7247 bytes read in 1 ms (6.9 MiB/s)
89810 bytes read in 3 ms (28.5 MiB/s)
149 bytes read in 2 ms (72.3 KiB/s)
Applying Overlay: verdin-imx8mp_hdmi_overlay.dtbo
2219 bytes read in 3 ms (721.7 KiB/s)
Applying Overlay: verdin-imx8mp_dsi-to-hdmi_overlay.dtbo
3652 bytes read in 2 ms (1.7 MiB/s)
Applying Overlay: verdin-imx8mp_spidev_overlay.dtbo
561 bytes read in 3 ms (182.6 KiB/s)
Applying Overlay: mallow-verdin-i2s-overlay.dtbo
2520 bytes read in 3 ms (820.3 KiB/s)
13441371 bytes read in 44 ms (291.3 MiB/s)
6151962 bytes read in 21 ms (279.4 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 50200000
   Booting using the fdt blob at 0x50200000
   Loading Device Tree to 00000000ffac0000, end 00000000ffaf8fff ... OK

Starting kernel ...

[    1.028326] pca953x 3-0021: failed writing register
[    1.064402] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.080819] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.091400] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    2.368634] +V3.3_SW: Underflow of regulator enable count
[    2.610532] [drm:drm_bridge_attach] *ERROR* failed to attach bridge /soc@0/bus@32c00000/mipi_dsi@32e60000 to encoder DSI-37: -517
[    2.622340] imx_sec_dsim_drv 32e60000.mipi_dsi: Failed to attach bridge: 32e60000.mipi_dsi
[    2.630633] imx_sec_dsim_drv 32e60000.mipi_dsi: failed to bind sec dsim bridge: -517
Starting version 250.5+
[    4.257706] systemd[1]: syslog.socket: Socket service syslog.service not loaded, refusing.
[    4.265981] systemd[1]: Failed to listen on Syslog Socket.
[FAILED] Failed to listen on Syslog Socket.
[DEPEND] Dependency failed for System Logging Service.
[    5.568282] ina2xx 3-0040: error configuring the device: -6
[    5.571385] imx8mp-pinctrl 30330000.pinctrl: pin MX8MP_IOMUXC_SAI1_MCLK already requested by 1-001a; cannot claim for 3-001a
[    5.574013] wm8904 1-001a: Failed to read ID register: -6
[    5.585340] imx8mp-pinctrl 30330000.pinctrl: pin-102 (3-001a) status -22
[    5.597622] imx8mp-pinctrl 30330000.pinctrl: could not request pin 102 (MX8MP_IOMUXC_SAI1_MCLK) from group sai1grp  on device 30330000.pinctrl
[    5.610908] nau8822 3-001a: Error applying setting, reverse things back
[    5.684881] fsl-aud2htx 30cb0000.aud2htx: failed to pcm register
[    5.702773] fsl-aud2htx 30cb0000.aud2htx: failed to pcm register
[    5.758277] fsl-aud2htx 30cb0000.aud2htx: failed to pcm register
[    5.854495] imx-hdmi sound-hdmi: snd_soc_register_card failed (-517)

This are our connections:

Thanks again for the help :slight_smile:

Hello @af-silva,

Unfortuantely, the i2c numbering in the device tree and Linux are not the same.
As you are using I2C1 from the Verdin specification, you need to use i2c4 when using the Verdin iMX8MP.

To ensure that you are testing only your intended scenario here, please make sure to do the following:

  • Set the device tree to the one for the Mallow Carrier Board: imx8mp-verdin-nonwifi-mallow.dts

This can be done by adding an entry under customizationdevice-tree:

customization:
  device-tree:
    custom: <device tree path>
  • Clear other overlays, to avoid spurious messages:

This can be done by adding the following configuration under customizationdevice-treeoverlays:

customization:
  device-tree:
    overlays:
      clear: true

Please test again with such configuration and still using i2c4.

Best Regards,
Bruno

Hi @bruno.tx,

Following your suggestions:

my tcbuild.yaml snippet looks like this:

customization:
  # Customization section items.
  device-tree:
    include-dirs:
      - overlays/linux_5.15-2.2.x-imx/include    
    overlays:
      clear: true
      add:        
        - overlays/linux_5.15-2.2.x-imx/arch/arm64/boot/dts/freescale/imx8mp-verdin-nonwifi-mallow.dts     
        - overlays/imx8mp-verdin-wm8904-overlay.dts

My imx8mp-verdin-wm8904-overlay.dts is has follow:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright 2020-2022 Toradex
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx8mp-clock.h>

/ {
    compatible = "toradex,verdin-imx8mp";

    /* Simple Audio Card */
	sound {
		compatible = "simple-audio-card";
		simple-audio-card,bitclock-master = <&codec_dai>;
		simple-audio-card,format = "i2s";
		simple-audio-card,frame-master = <&codec_dai>;
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "verdin-wm8904";
		simple-audio-card,routing =
			"Headphone Jack", "HPOUTL",
			"Headphone Jack", "HPOUTR",
			"IN2L", "Line In Jack",
			"IN2R", "Line In Jack",
			"Headphone Jack", "MICBIAS",
			"IN1L", "Headphone Jack";
		simple-audio-card,widgets =
			"Microphone", "Headphone Jack",
			"Headphone", "Headphone Jack",
			"Line", "Line In Jack";

		codec_dai: simple-audio-card,codec {
			clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1>;
			sound-dai = <&wm8904_1a>;
		};

		simple-audio-card,cpu {
			sound-dai = <&sai1>;
		};
	};
};

/* Verdin I2C_1 */
&i2c4 {
	status = "okay";

	/* Audio Codec */
	wm8904_1a: audio-codec@1a {
		compatible = "wlf,wm8904";
		reg = <0x1a>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_sai1>;
		#sound-dai-cells = <0>;
		clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1>;
		clock-names = "mclk";
		AVDD-supply = <&reg_1p8v>;
		CPVDD-supply = <&reg_1p8v>;
		DBVDD-supply = <&reg_1p8v>;
		DCVDD-supply = <&reg_1p8v>;
		MICVDD-supply = <&reg_1p8v>;
	};
};


/* Verdin I2S_1 */
&sai1 {
	assigned-clocks = <&clk IMX8MP_CLK_SAI1>;
	assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
	assigned-clock-rates = <24576000>;
	fsl,sai-mclk-direction-output;
	status = "okay";
};

The boot up sequence of the board looks like this:

U-Boot 2022.04-6.8.1+git.a31fdd543bee (Jan 01 1970 - 00:00:00 +0000)

CPU:   i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 43C
Reset cause: POR
DRAM:  4 GiB
Core:  89 devices, 23 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex 0063 Verdin iMX8M Plus Quad 4GB IT V1.1B
Serial#: 15459446
Carrier: Toradex UNKNOWN CARRIER BOARD V1.1B, Serial# 11420286
SEC0:  RNG instantiated

 BuildInfo:
  - ATF 3c1583b

flash target is MMC:2
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000 [PRIME]
Fastboot: Normal
Saving Environment to MMC... Writing to MMC(2)... OK
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc2(part 0) is current device
Scanning mmc 2:1...
Found U-Boot script /boot.scr
973 bytes read in 1 ms (950.2 KiB/s)
## Executing script at 50280000
7247 bytes read in 2 ms (3.5 MiB/s)
89810 bytes read in 2 ms (42.8 MiB/s)
81 bytes read in 2 ms (39.1 KiB/s)
Applying Overlay: imx8mp-verdin-nonwifi-mallow.dtbo
89637 bytes read in 2 ms (42.7 MiB/s)
Applying Overlay: imx8mp-verdin-wm8904-overlay.dtbo
2520 bytes read in 2 ms (1.2 MiB/s)
13441371 bytes read in 44 ms (291.3 MiB/s)
6151961 bytes read in 21 ms (279.4 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 50200000
   Booting using the fdt blob at 0x50200000
   Loading Device Tree to 00000000ffac0000, end 00000000ffaf8fff ... OK

Starting kernel ...

[    0.892875] imx-drm display-subsystem: no available port
[    1.032311] pca953x 3-0021: failed writing register
[    1.070257] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.084136] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.094888] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    2.374551] +V3.3_SW: Underflow of regulator enable count
Starting version 250.5+
[    4.033119] systemd[1]: syslog.socket: Socket service syslog.service not loaded, refusing.
[    4.041475] systemd[1]: Failed to listen on Syslog Socket.
[FAILED] Failed to listen on Syslog Socket.
[DEPEND] Dependency failed for System Logging Service.
[    5.451547] ina2xx 3-0040: error configuring the device: -6
[    5.605254] OF: /sound/simple-audio-card,codec: could not find phandle 176
[    5.612293] asoc-simple-card sound: parse error -22

For what I can tell from this two lines:

[    5.605254] OF: /sound/simple-audio-card,codec: could not find phandle 176
[    5.612293] asoc-simple-card sound: parse error -22

The DAC is not initiating, any suggestion??

Thanks,
Best regards,
André Silva

Hello @af-silva,

The Mallow device tree needs to be configured as the custom device tree, not as an overlay.
Therefore, your snippet should be instead the following:

customization:
  # Customization section items.
  device-tree:
    include-dirs:
      - overlays/linux_5.15-2.2.x-imx/include    
    custom: overlays/linux_5.15-2.2.x-imx/arch/arm64/boot/dts/freescale/imx8mp-verdin-nonwifi-mallow.dts
    overlays:
      clear: true
      add:        
        - overlays/imx8mp-verdin-wm8904-overlay.dts

It is possible that the overlays/linux_5.15-2.2.x-imx/arch/arm64/boot/dts/freescale needs to be added as an include directory as well.

Best Regards,
Bruno

Hi @bruno.tx ,

Following your suggestions this is my tcbuild.yaml snippet right now:

customization:    
  # Customization section items.
  device-tree:
    include-dirs:
      - overlays/linux_5.15-2.2.x-imx/include    
      - overlays/linux_5.15-2.2.x-imx/arch/arm64/boot/dts/freescale
    custom: overlays/linux_5.15-2.2.x-imx/arch/arm64/boot/dts/freescale/imx8mp-verdin-nonwifi-mallow.dts
    overlays:
      clear: true
      add:        
        - overlays/imx8mp-verdin-wm8904-overlay.dts    

The startup boot sequence is as follow, some of the errors don’t show anymore:

U-Boot 2022.04-6.8.1+git.a31fdd543bee (Jan 01 1970 - 00:00:00 +0000)

CPU:   i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 40C
Reset cause: POR
DRAM:  4 GiB
Core:  89 devices, 23 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex 0063 Verdin iMX8M Plus Quad 4GB IT V1.1B
Serial#: 15459446
Carrier: Toradex UNKNOWN CARRIER BOARD V1.1B, Serial# 11420286
SEC0:  RNG instantiated

 BuildInfo:
  - ATF 3c1583b

flash target is MMC:2
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000 [PRIME]
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc2(part 0) is current device
Scanning mmc 2:1...
Found U-Boot script /boot.scr
973 bytes read in 0 ms
## Executing script at 50280000
7288 bytes read in 1 ms (7 MiB/s)
89637 bytes read in 3 ms (28.5 MiB/s)
47 bytes read in 2 ms (22.5 KiB/s)
Applying Overlay: imx8mp-verdin-wm8904-overlay.dtbo
2520 bytes read in 3 ms (820.3 KiB/s)
13441371 bytes read in 43 ms (298.1 MiB/s)
6151962 bytes read in 21 ms (279.4 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 50200000
   Booting using the fdt blob at 0x50200000
   Loading Device Tree to 00000000ffac0000, end 00000000ffaf8fff ... OK

Starting kernel ...

[    0.892857] imx-drm display-subsystem: no available port
[    1.032846] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.047713] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    1.058287] clk: failed to reparent hsio_axi to sys_pll2_500m: -16
[    2.340546] regulator-dummy: Underflow of regulator enable count
Starting version 250.5+
[    3.968126] systemd[1]: syslog.socket: Socket service syslog.service not loaded, refusing.
[    3.976609] systemd[1]: Failed to listen on Syslog Socket.
[FAILED] Failed to listen on Syslog Socket.
[DEPEND] Dependency failed for System Logging Service.
[    6.008294] tpm tpm0: [Firmware Bug]: TPM interrupt not working, polling instead
[    6.018641] tpm tpm0: A TPM error (256) occurred attempting the self test

But from what I can tell the soundcard is still not loaded into the system:

torizon@verdin-imx8mp-15459446:~$ cat /proc/asound/cards
--- no soundcards ---

Any ideas ?
Thanks again for the quick response and support,

Best regards,
André Silva

Hello @af-silva,

Sorry, I did not notice this detail before:
In your overlay, please adjust the compatible part so that it follows the following format:

/ {
	compatible = "toradex,verdin-imx8mp";
};

&{/} {
    /* Simple Audio Card */
	sound {
        /* Rest of file */

Otherwise, the configuration seems correct.
So, if it still does not work with the new overlay, please send us your board schematics so we can check if there is a problem there.
This can be done either via a private message to the moderators on the community or via support.eu@toradex.com.

Best Regards,
Bruno

Hi @bruno.tx ,

First many thanks for the support.
It worked, I have now been able to record sound and to reproduce sound with the purposed changes.
It work on booth:

  • linux_5.15-2.2.x-imx (OS Verions 6)
  • linux_6.6-2.1.x-imx (OS Version 7)

Now i’m facing another issue regarding the recording, it seems only the left channel is recording but maybe this is a problem with the alsa configuration. On the other hand, when testing the device with speaker-test -D hw:0,0 -c 2 -t sine I can hear each channel individually but at the start if i’m not mistaken it should play booth Left and Right channel simultaneously and only the left channel is playing. If you have any pointers on this I would appreciate, nevertheless I will continue my tests and mark the previous answer as the solution.

Note: I’m following the tutorial nxpfreescale-imx-8m-miniplus-based-modules from the Torizon documentation.

Again, thanks Bruno
My best regards,
André Silva

Hello @af-silva,

Thanks for the update, it is good to know that you were able to get this working.

Regarding the single-channel recording, it could be the recording configuration used.
Can you open another topic on the community with more information about this problem?
Which commands you are using to record and play the files would be useful.

Best Regards,
Bruno

Hi @bruno.tx

I was following this Turorial by Toradex the provided commands:

amixer -c 0 set "Capture" cap 
amixer -c 0 set 'Left Capture Inverting Mux' 'IN1L' 
amixer -c 0 set 'Right Capture Inverting Mux' 'IN1R' 
amixer -c 0 set 'Capture' '31' 
arecord -D hw:0,0 -V mono -c 2 -f S16_LE -r 48000 -t wav mic.wav

This creates an audio file but I think is expected only the left channel is recorded, since we are using the microphone and not the Lin-In. But we need to reproduce on both channels Left and Right, so after some search I was able to solve this by running the following commands:

amixer -c 0 cset name='HPL Mux' 'DAC'
amixer -c 0 cset name='HPR Mux' 'DAC' 
amixer -c 0 cset name='DACL Mux' 'AIFOUTL'
amixer -c 0 cset name='DACR Mux' 'AIFOUTR'

I don’t think opening a new topic is worth, but if the behavior on Toradex tutorial is expected (record only the left channel) I think it should be explicit on the documentation, and if one want to reproduce on both channels this configuration is working for me.

Again, many thanks for all the support and guidance.
Have a great weekend,
My Best Regards
André Silva

Hello @af-silva,

If only one of the input channels is connected, it would make sense that this is recorded only on the left channel.
What you can do to force a mono recording is to use the following command instead:

arecord -D plughw:0,0 -V mono -c 1 -f S16_LE -r 48000 -t wav mic.wav

I think that this will depend on the actual configuration of the hardware.
Regardless, I will add a note about how to force actual mono recording.
Thanks for the feedback!

Best Regards,
Bruno