Jump to content

I2S Problems with Respeaker MIC2 Hat on Banana PI Zero M2


FordPrfkt

Recommended Posts

Hi,

 

i am trying to get the Respeaker 2 Mic Pi hat working on a Banana Pi Zero M2. The HAT uses the WM8960 codec and generates its own I2S MCLK.
After some trouble i got the i2c interface working and i2cdetect shows a device at address 0x1a which is correct.

But i can not get the I2S interface working.

I have added a user overlay with the following .dts:

 

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";

        fragment@0 {
                target = <&i2c0>;
                __overlay__ {
                        #address-cells = <0>;
                        #size-cells = <0>;
                        status = "okay";

                        wm8960: wm8960{
                                compatible = "wlf,wm8960";
                                reg = <0x1a>;
                                #sound-dai-cells = <0>;
                        };
                };
        };

        fragment@1 {
                target = <&i2s0>;
                __overlay__ {
                        status = "okay";
                        pinctrl-0 = <&i2s0_pins>;
                        sound-dai = <&wm8960>;
                        pinctrl-names = "default";
                };
        };

        fragment@2 {
                target-path = "/";
                __overlay__ {
                        sound_i2s {
                                compatible = "simple-audio-card";
                                simple-audio-card,name = "I2S-master";
                                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>;
                                status = "okay";

                                simple-audio-card,widgets =
                                "Microphone", "Mic Jack",
                                "Speaker", "Speaker",
                                "Headphone", "Headphone Jack";

                                simple-audio-card,routing =
                                "Headphone Jack", "HP_L",
                                "Headphone Jack", "HP_R",
                                "Speaker", "SPK_LP",
                                "Speaker", "SPK_LN",
                                "LINPUT1", "Mic Jack",
                                "LINPUT3", "Mic Jack",
                                "RINPUT1", "Mic Jack",
                                "RINPUT2", "Mic Jack";

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

                                codec_dai,codec {
                                        sound-dai = <&wm8960>;
                                };
                        };
                };
        };
};

 

I do not see errors in dmesg but aplay -l only shows the HMDI sound interface.

I am stuck here and have not found a good explanation how .dts files exactly work for audio or how to get some error messgae from the kernel to see what is wrong.

Kernel Version is 5.15.62-sunxi

 

Edited by FordPrfkt
There was a typo
Link to comment
Share on other sites

From this very helpful thread:

 

I learned that I2S0 is disabled in the Banapi Zero M2 by default.

I enabled it in my overlay using

fragment@0 {
                target-path = "/soc/i2s@1c22000";
                __overlay__ {
                        status = "okay";
                };
        };

 

and with this dts:

Spoiler

// Definitions for G-Dis DAC
/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";

        fragment@0 {
                target-path = "/soc/i2s@1c22000";
                __overlay__ {
                        status = "okay";
                };
        };

        fragment@1 {
                target = <&i2c0>;
                __overlay__ {
                        #address-cells = <0>;
                        #size-cells = <0>;
                        status = "okay";

                        wm8960: wm8960{
                                compatible = "wlf,wm8960";
                                reg = <0x1a>;
                                wlf,shared-lrclk;
                                #sound-dai-cells = <0>;
                        };
                };
        };

        fragment@2 {
                target-path="/";
                __overlay__ {
                        wm8960_mclk: wm8960_mclk {
                        compatible = "fixed-clock";
                        #clock-cells = <0>;
                        clock-frequency = <12288000>;
                        };
                };
        };


        fragment@3 {
                target = <&i2s0>;
                __overlay__ {
                        pinctrl-0 = <&i2s0_pins>;
                        pinctrl-names = "default";
                        sound-dai = <&wm8960>;
                        status = "okay";
                };
        };

        fragment@4 {
                target-path = "/";
                __overlay__ {
                        sound_i2s {
                                simple-audio-card,name = "2MicHAT";
                                compatible = "simple-audio-card";
                                simple-audio-card,format = "i2s";
                                status = "okay";
                                simple-audio-card,bitclock-slave = <&dailink0_slave>;
                                simple-audio-card,frame-slave = <&dailink0_slave>;
//                              simple-audio-card,mclk-fs = <512>;
                                 simple-audio-card,widgets =
                                        "Microphone", "Mic Jack",
                                        "Speaker", "Speaker",
                                        "Headphone", "Headphone Jack";
                                simple-audio-card,routing =
                                        "Headphone Jack", "HP_L",
                                        "Headphone Jack", "HP_R",
                                        "Speaker", "SPK_LP",
                                        "Speaker", "SPK_LN",
                                        "LINPUT1", "Mic Jack",
                                        "LINPUT3", "Mic Jack",
                                        "RINPUT1", "Mic Jack",
                                        "RINPUT2", "Mic Jack";

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

                                dailink0_slave: simple-audio-card,codec {
                                        sound-dai = <&wm8960>;

                                       clocks = <&wm8960_mclk>;
                                        clock-names = "mclk";
                                };
                        };
                };
        };

};

 

i now have the sound interface!

daniel@bananapim2zero:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: D2MicHAT [2MicHAT], device 0: 1c22000.i2s-wm8960-hifi wm8960-hifi-0 [1c22000.i2s-wm8960-hifi wm8960-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sun9ihdmi [sun9i-hdmi], device 0: SUN9I-HDMI PCM i2s-hifi-0 [SUN9I-HDMI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

 

and also some kernel error messages:

[   53.784092] wm8960 0-001a: failed to configure clock
[   53.784107] wm8960 0-001a: ASoC: error at snd_soc_dai_hw_params on wm8960-hifi: -22
[   53.784124]  1c22000.i2s-wm8960-hifi: ASoC: soc_pcm_hw_params() failed (-22)
<goes on very long>

 

So now it seems there is something wrong with the clocking.

Probably i did not configure the I2S correctly to take MCLK from the HAT but at the moment i got no idea

 

Link to comment
Share on other sites

I found the Problem.

The Banana Pi M2 Zero claims to be Pin compatible to a Raspberry Pi 3 but it is not.

The RPI 3 (and Zero) have I2S_CLK and LRCLK on Pins 12 and 35 of the GPIO Header and the BPI has them on Pin 28 and 27.

I throw it in the bin and try to find another board that is compatible (RPIs are unobtainable at the moment)

Link to comment
Share on other sites

That's unfortunate to hear. I also bought a BPi M2 Zero based on the premise that the PIN's are compatible with Raspberry Pi and hence my Hifiberry Digi would be supported.

 

Did you eventually get it to work by re-wiring the PINs somehow?

 

Did you get your HAT working on another board?

 

 

Link to comment
Share on other sites

Hello,

 

Solution to run a pcm5102a module on a BPi M2 Zero board (Allwinner H2+/H3).

 

Becarfull , the connection is different compared to the GPIO 40 of the Raspberry !

 

Wiring of the DAC on GPIO40 of the BPi M2 Zero:

 

SCLK (not connected)

BCK on CON2-P27 (PA19-EINT19)

LCK on CON2-P28 (PA18-EINT18)

DIN on CON2-P40 (PA20-EINT20)

VIN (5v) on CON2-P02 or CON2-P04

GND on CON2-P06

 

Image linux Armbian used :

Armbian_22.11.0-trunk_Bananapim2zero_bullseye_edge_6.0.9.img

Enabled i2s via overlay :

 

 

Create a file sun8i-h3-I2S-out.dts containing the text of the discussion indicated above /boot/overlay-user

The contents of sun8i-h3-I2S-out.dts should look like:
 

/dts-v1/;
/plugin/;

/ {
    compatible = "allwinner,sun8i-h3";

    fragment@0 {
        target-path = "/soc/i2s@1c22000";
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 { 
        target-path = "/"; 
        __overlay__ { 
            pcm5102a: pcm5102a {
                #sound-dai-cells = <0>;
                compatible = "ti,pcm5102a";
                pcm510x,format = "i2s";
            };
        };
     };

    fragment@2 {
        target = <&i2s0>;
        __overlay__ {
            status = "okay";
            pinctrl-0 = <&i2s0_pins>;
            sound-dai = <&pcm5102a>;
            pinctrl-names = "default";
        };
    };

    fragment@3 {
        target-path = "/";
        __overlay__ {
            sound_i2s {
                compatible = "simple-audio-card";
                simple-audio-card,name = "I2S-master";
                simple-audio-card,mclk-fs = <256>;
                simple-audio-card,format = "i2s";
                status = "okay";
                simple-audio-card,cpu {
                    sound-dai = <&i2s0>;
                };
                simple-audio-card,codec {
                    sound-dai = <&pcm5102a>;
                };
            };
        };
    };
};

 

Launch the command :

armbian-add-overlay ./sun8i-h3-I2S-out.dts


The sun8i-h3-I2S-out.dtbo file is created

The /boot/armbianEnv.txt file is modified, now you should find the line "user_overlays=sun8i-h3-I2S-out"

reboot BPi M2 Zero

 

The aplay -l command verifies the presence of the pcm5102a DAC.


aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: I2Smaster [I2S-master], device 0: 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0 [1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sun9ihdmi [sun9i-hdmi], device 0: SUN9I-HDMI PCM i2s-hifi-0 [SUN9I-HDMI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

 

Thanks to everyone who writes in the forums otherwise I wouldn't have been able to get the whole thing working.

For information, works very well with Logitech Media Server and the Squeezlite player (and certainly others but I haven't tried).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines