No sound card detected for Opi zero 2w

I’m tracking to have it finally tested by a Lyman :wink:

Hello all
@MichaIng , just a question
Can you put in the folder sound/soc/codecs of the new kernel before rebuilding it the files pcm5122. Ko and pcm5122-i2c. Ko

The new build contains the i2s0-hat overlay:

cd /tmp
wget https://dietpi.com/downloads/binaries/testing/linux-{dtb,image}-current-sunxi64.deb
sudo dpkg -i linux-{dtb,image}-current-sunxi64.deb

Maybe test it once the way it is now. I mean this has worked for others, and it makes perfectly sense that it never worked on DietPi before without adjustments, simply because codec, HDMI and jack nodes were all disabled.

Similarly, I would leave sound-dai = <&hdmi>; inside for now. It has been added by Armbian like that, and obviously works on Orange Pi Zero 3 like that. So I don’t think it causes issues, and I would like to keep our patch and diff minimal.

You mean adding a kernel module? One cannot just put compiled kernel modules (.ko files) inside, you would not be able to load them. It would require the source code of the driver(s) patched into kernel sources, before compiling the kernel.

Luckily mainline Linux has a driver, which would just need to be enabled: Making sure you're not a bot!

CONFIG_SND_SOC_PCM512x_I2C=m

But similarly, please test first whether the otherwise chosen (fallback) driver works sufficiently well. I need to find a way to merge back our commits into Armbian around Igors ban, before continuing to accumulate more and more fixes, enhancements etc, which all need to be rebased and in case conflicts resolved over and over. It is 25 commits already :disappointed_face:: Commits · MichaIng/build · GitHub

Hello @MichaIng , i try this morning your new compiled skernell but unfortunatly
it doesn’t work , the command aplay -l return no sound card
I inject the i2s0-hat.dtbo in dietpiEnv.txt with no more succes
Finally i inject the script sound.sh and recover the three soundcard with the aplay command

For the pcm5122.ko and pcm5122-i2c.ko , i don’t see it in the kernell folder
i found the pcm5102a.ko like before

I make a capture of the dmesg of the new kernell

and i have a look to the dtb file with a conversion from dtb to dts
the log of the output in this text file
2wdtbtodts-log.txt (4,9 Ko)
There are some part that disturb me like ahub-i2s1 ahub-i2s2 and ahub-i2s3 :wink:

To be continued

Yes, as said, it is not enabled in the kernel config at the moment, so while mainline Linux ships this driver, it is not currently compiled.

Uff, tedious task to grab together the bits and peaces around all the patches to this device tree. I will apply them all to a clean Linux tree and try to track down the complete relevant nodes, so we can compare them with your functional dts.

Indeed, something is pretty much messed up, with duplicate conflicting definitions.

Yessss @MichaIng

It’s complicated by the fact that the board have an expansion board and some pin accessible on the 40 pin hat

I think that it’s perhaps better to stay on a user overlay for the sound via i2s0

And activated the HDMI and Jack in the dtb file like it seem to work on the opi zero 3 dtb

This is exactly what the patch tries to do. Obviously the Zero 3 and Zero 2W, after all other patches were applied, still differ in some other relevant point.

User overlay or kernel overlay or fixed dts entry does not make any difference. They all need to define the same nodes and properties to function.

I will have a nother look into it later today.

1 Like

I think that the patch are not apply
Correctly because the conversion of the dtb file in dts show nodes disable
I don’t understand why

Hi guys, not sure if it is related.

I tried a clean install and exchange the dtb in order to have sound, but I then cannot have the GPU overlay active. It will hang at boot.

So I figured to use my GPU activated dtb. Now the boot hangs as well, same story.

Hello Arafat

It’s normal, the gpu is disabled by de fault, you need to extend the script to enable it, tell me if you want that i do in this way, it’s just create a fragment

Hi totof,

Thanks for all your work.

I’m not sure what the extension of the script means. If it solves the issue then yes please.
GPU and sound required.

My builds don’t work anymore since patch .13ish. I cannot Dietpi-update any of my versions, stuck at boot. The recent clean install did not provide me the audio so I tried exchanging dtb again.

I’ll try it again this week.

Hello Arafat

I extend the script tonight after work
And make a little “how to” to make and run the script
With a fresh install and the normal dtb you just applied the script to enable audio :blush:

1 Like

Hi everyone, I need to configure Orange Pi Zero 2W as I2S Slave to work with ADAU1701 DSP chip as the master clock generator.
My setup:

Orange Pi Zero 2W
ADAU1701 DSP board (needs to be I2S Master)
Need custom sampling rates

What I need:

How to configure OPi Zero 2W in I2S Slave mode
Device tree modifications required
Any working examples or overlays

Has anyone successfully configured OPi Zero 2W as I2S Slave? Any device tree examples or step-by-step guides would be extremely helpful.

Hello flothero

Unfortunately there is no orangepi zero 2w’s module kernel for the adau1701
so not possible to use the adau1701 in master mode
The only way for you is the raspberrypi wich have the module kernel avalaible

Hello @Arrafar

For your question about the gpu i tested my script and it seems to work fine on my OPI zero 2w

With your fresh install of the last Dietpi 9.14.2 version

the script

# Create the directory for user overlays
mkdir -p /boot/overlay-user
cd /boot/overlay-user
# Create the overlay source file
cat << '_EOF_' > sound-hdmi-jack-i2s0-hat.dts
/dts-v1/;
/plugin/;
/ {
	compatible = "allwinner,sun50i-h618";
	fragment@0 {
		target = <&pio>;
		__overlay__ {
			ahub_daudio0_pins_d: ahub_daudio0_sleep {
				pins = "PI0", "PI1", "PI2", "PI3", "PI4";
				function = "gpio_in";
				drive-strength = <0x14>;
				bias-disable;
			};
			ahub_daudio0_pins_a: ahub_daudio0@0 {
				pins = "PI0", "PI1", "PI2";
				function = "i2s0";
				drive-strength = <0x14>;
				bias-disable;
			};
			ahub_daudio0_pins_b: ahub_daudio0@1 {
				pins = "PI3";
				function = "i2s0_dout0";
				drive-strength = <0x14>;
				bias-disable;
			};
			ahub_daudio0_pins_c: ahub_daudio0@2 {
				pins = "PI4";
				function = "i2s0_din0";
				drive-strength = <0x14>;
				bias-disable;
			};
		};
	};
	fragment@1 {
		target-path = "/soc";
		__overlay__ {
			ahub0_plat: ahub0_plat {
				#sound-dai-cells = <0>;
				compatible = "allwinner,sunxi-snd-plat-ahub";
				apb_num = <0>; /* for dma port 3 */
				dmas = <&dma 3>, <&dma 3>;
				dma-names = "tx", "rx";
				playback_cma = <128>;
				capture_cma = <128>;
				tx_fifo_size = <128>;
				rx_fifo_size = <128>;
				pinctrl-names = "default", "sleep";
				pinctrl_used;
				pinctrl-0 = <&ahub_daudio0_pins_a>, <&ahub_daudio0_pins_b>, <&ahub_daudio0_pins_c>;
				pinctrl-1 = <&ahub_daudio0_pins_d>;
				status = "okay";
			};
			ahub0_mach: ahub0_mach {
				compatible = "allwinner,sunxi-snd-mach";
				soundcard-mach,name = "ahubi2s0";
				soundcard-mach,format = "i2s";
				soundcard-mach,frame-master = <&ahub0_cpu>;
			        soundcard-mach,bitclock-master = <&ahub0_cpu>;
			        soundcard-mach,slot-num = <2>;
			        soundcard-mach,slot-width = <32>;
				status = "okay";

				ahub0_cpu: soundcard-mach,cpu {
					sound-dai = <&ahub0_plat>;
					soundcard-mach,pll-fs = <4>;
				        soundcard-mach,mclk-fs = <0>;
				};

				soundcard-mach,codec {
				};
			};
		};
	};
	fragment@2 {
		target-path = "/soc";
		__overlay__ {
			codec: codec {
			                       compatible = "allwinner,sun50i-h616-codec";
			                       status = "okay";
			                       allwinner,audio-routing = "Line Out", "LINEOUT";
			                       };
			 };
	};
	fragment@3 {
		target-path = "/soc";
		__overlay__ {
			ahub_dam_plat: ahub_dam_plat {
			                       compatible = "allwinner,sunxi-snd-plat-ahub_dam";
			                       status = "okay";
			                       };
			 };
	};
	fragment@4 {
		target-path = "/soc";
		__overlay__ {
			ahub1_plat: ahub1_plat {
			                       compatible = "allwinner,sunxi-snd-plat-ahub";
			                       #sound-dai-cells = <0x00>;
			                       status = "okay";
			                       };
			 };
	};
	fragment@5 {
		target-path = "/soc";
		__overlay__ {
			ahub1_mach: ahub1_mach {
			                       compatible = "allwinner,sunxi-snd-mach";
			                       soundcard-mach,name = "HDMI";
			                       soundcard-mach,format = "i2s";
			                       status = "okay";
			                       
			                       soundcard-mach,cpu {
					           sound-dai = <&ahub1_plat>;
				                   };

				               soundcard-mach,codec {
				                   };
			                       };
			 };
	};
	fragment@6 {
		target-path = "/soc";
		__overlay__ {
			gpu: gpu {
			                       compatible = "allwinner,sun50i-h616-mali", "arm,mali-bifrost";
			                       status = "okay";
			                       };
			 };
	};
};
_EOF_
# Install the device tree compiler
apt install device-tree-compiler
# Compile the overlay binary file
dtc -I dts -O dtb -o sound-hdmi-jack-i2s0-hat.dtbo -@ sound-hdmi-jack-i2s0-hat.dts
# To see the result of the compiler uncommit next line
#fdtdump sound-hdmi-jack-i2s0-hat.dtbo
# Enable the user overlay via U-Boot environment file
G_CONFIG_INJECT 'user_overlays=' 'user_overlays=sound-hdmi-jack-i2s0-hat' /boot/dietpiEnv.txt

In a terminal just a few command when you are connected

sudo nano sound.sh

Copy and past the script

Ctrl+o to write the line and Ctrl+x to save and exit

Run the script

sh sound.sh

Inject the user-overlay

G_CONFIG_INJECT 'user_overlays=' 'user_overlays=sound-hdmi-jack-i2s0-hat' /boot/dietpiEnv.txt

And reboot

That’s all :wink:

1 Like

Do I need to make it executable?
I’ll try it straight away

when you are connected with “ssh root@192.168.1.xx”
type in the terminal nano sound.sh and paste the script above
save and type in the terminal again " sh sound.sh" and after
the commandline “G_CONFIG_INJECT ‘user_overlays=’ ‘user_overlays=sound-hdmi-jack-i2s0-hat’ /boot/dietpiEnv.txt”

1 Like

Thanks a lot Totof, this worked great!!

I was forced to go through the installation menu first, but once installed I used your script and am stunned :melting_face::star_struck:

1 Like

Thanks for answer @totof!

I’m sorry, are you sure it can’t be done on OrangePI? I have seen successful cases of running i2s in Slave. Or am I wrong?

DIY аудиоплеер Volumio2 на Orange Pi PC с ADAU1701 (This is where the configuration in Slave is used)
GitHub - xio4/allwinner-h5-i2s-slave: I2S-slave patches for Allwinner H5. Tested on Orangepi PC2.

But it for old orange pi

Here is my overlay:

&{/soc@3000000/ahub3_plat} {
    status = "okay";
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&ahub_daudio3_pins_a>, <&ahub_daudio3_pins_b>;
    pinctrl-1 = <&ahub_daudio3_pins_d>;

    daudio_master = <0>;       // Orange Pi in slave mode
    playback_cma = <256>;
    capture_cma = <0>;
};

&{/soc@3000000/ahub3_mach} {
    status = "okay";
};

Hello flothero

Perhaps it work for the H618 core , ai took a eye tonight on your github link

Try to run the script to activate the i2s0 on your board and read the post for the position of the pin on the 40pin hat

1 Like