Hello MichaIng
Yes i install the device tree compiler on my OPI zero 2w et run the script
i try also to copy the file with prefix in the normal overlays folder without succes
I try again today this afternoon and tell you
Hello MichaIng
Yes i install the device tree compiler on my OPI zero 2w et run the script
i try also to copy the file with prefix in the normal overlays folder without succes
I try again today this afternoon and tell you
Did the overlay apply, i.e. do the ahub0
nodes exist?
ls -l /proc/device-tree/soc/ahub0_plat
ls -l /proc/device-tree/$(</proc/device-tree/__symbols__/pio)/ahub_daudio0_pins_a
Looks like something is missing, but I do not see what .
Hello MichaIng
After some research i finally copy the file dtbo created with the script in
/boot/dtb/allwinner/overlay/sun50i-h616-i2s0-audio-hat.dtbo
in the terminal i write
G_CONFIG_INJECT ‘overlays=’ ‘overlays=i2s0-audio-hat’ /boot/dietpiEnv.txt
and with the command gpio readall i obtain this
your command return
To be continued
So far so good. No idea why it was not applied via user_overlays
then, when located in /boot/overlay-user
(without prefix).
I missed one underscore to read the symbol correctly:
ls -l /proc/device-tree/$(</proc/device-tree/__symbols__/pio)/ahub_daudio0_pins_a
However, the ahub0_plat
node exists and the pins were assigned, so the second fragment seems to have been applied correctly as well.
Does the audio jack work as well with this?
I modified the script with this on the top
I run the script , that’s create the dtbo but the command G_CONFIG_INJECT inject was refused so i write it in the terminal
It work and create the node ahub0 see the capture
You can see that ahub1 is disabled and also codec@
i search further
This is wrong. The overlay-user
directory in supposed to be below /boot
. See /boot/boot.cmd
how user overlays are found. Where you put it, it has no effect. There, overlays are only read if they have correct prefix and are added via overlays=
instead of user_overlays=
in /boot/dietpiEnv.txt
. However, one should not add custom overlays to the /boot/dtb
sub directory, as this is part of the kernel package, and replaced with each kernel upgrade. Hence this directory choice.
I try tomorrow with /boot/
I think it work too ,the problem is to unclaimed the pin in the dtb file
with an overlay , tomorrow if i have time i extract the new dtb and compare with my custom version , in the back of the file you found the symbol
The symbols are generated when compiling the device tree, and not suppose to be in the sources. E.g.
ahub1_codec: soundcard-mach,codec {
...
};
Creates a symbol named ahub1_codec
for the device node named soundcard-mach,codec
. When you generate the source from the binary device tree, the (de)compiler cannot know where the symbols have been defined, so they are appended to the end of the generated source instead, while the symbol definitions within other nodes are missing. E.g. in your generated source above node looks like this, with the symbol stripped:
soundcard-mach,codec {
...
};
So this difference is expected.
Hello MichaIng
You’re rigth return to /boot/overlay-user with succes to see the pin with gpio readall
so the first fragment work, the status of ahub0-mach and ahub0-plat are “okay”
The pin stay unclaimed so i try to search in this direction
and how put the codec@05096000 “okay” they still “disable”
Have a good day
Hello everyone
@MichaIng, i’ve some news
in this script a enable sound card ( HDMIsound is lost for this moment )
# Create the directory for user overlays
mkdir -p /boot/overlay-user
cd /boot/overlay-user
# Create the overlay source file
cat << '_EOF_' > i2s0-audio-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";
status = "okay";
soundcard-mach,cpu {
sound-dai = <&ahub0_plat>;
};
soundcard-mach,codec {
};
};
};
};
fragment@2 {
target-path = "/soc";
__overlay__ {
codec: codec {
compatible = "allwinner,sun50i-h616-codec";
status = "okay";
};
};
};
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";
status = "okay";
};
};
};
fragment@5 {
target-path = "/soc";
__overlay__ {
ahub1_mach: ahub1_mach {
compatible = "allwinner,sunxi-snd-mach";
status = "okay";
};
};
};
};
_EOF_
# Install the device tree compiler
apt install device-tree-compiler
# Compile the overlay binary file
dtc -I dts -O dtb -o i2s0-audio-hat.dtbo -@ i2s0-audio-hat.dts
# To see the resultof the compiler uncommit next line
#fdtdump i2s0-audio-hat.dtbo
# Enable the user overlay via U-Boot environment file
G_CONFIG_INJECT 'user_overlays=' 'user_overlays=i2s0-audio-hat' /boot/dietpiEnv.txt
After reboot with aplay -l , i obtain this
Work in progress
I have tried them and the device has been recognized:
pi@orangepizero2w:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: CDC PCM Codec-0 [CDC PCM Codec-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ahubi2s0 [ahubi2s0], device 0: ahub_plat-snd-soc-dummy-dai snd-soc-dummy-dai-0 [ahub_plat-snd-soc-dummy-dai snd-soc-dummy-dai-0]
Subdevices: 0/1
Subdevice #0: subdevice #0
However, there is still no sound.
pi@orangepizero2w:~$ aplay -D hw:1,0 1.wav
aplay: main:831: audio open error: Device or resource busy
I also encountered an I/O error in some cases.
By the way, I’d like to ask if the file sun50i-h618-orangepi-zero2w-essai.dtb
supports I2C. I’ve tried various methods but haven’t been able to detect any I2C address.
Hi MichaIng
I obtain a result to be tested
First 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";
status = "okay";
soundcard-mach,cpu {
sound-dai = <&ahub0_plat>;
};
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 {
};
};
};
};
};
_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
The same in a file
Script-sound-i2s0.txt (3,5 Ko)
When i run this script the command aplay -l was full
Just write in the terminal the last line except if Micha can explain how to do inside the
script
The line
G_CONFIG_INJECT 'user_overlays=' 'user_overlays=sound-hdmi-jack-i2s0-hat' /boot/dietpiEnv.txt
If you can test it , thanks for the feedback
Hello sangto2906
yes the file sun50i-h618-orangepi-zero2w-essai.dtb
support i2C0
but no need with PCM5102
you can test it with the line
ls /dev/i2c-*
and the tool “i2c-tools” see manual
I also tried to detect devices, but got no results:
pi@orangepizero2w:~$ ls /dev/i2c-*
/dev/i2c-0 /dev/i2c-1 /dev/i2c-2 /dev/i2c-3
pi@orangepizero2w:~$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- UU -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Then I ran gpio readall
and got the following output:
... [output truncated for clarity] ...
| 264 | 0 | SDA.1 | OFF | 0 | 3 || 4 | | | 5V | | |
| 263 | 1 | SCL.1 | OFF | 0 | 5 || 6 | | | GND | | |
...
| 266 | 17 | SDA.2 | OFF | 0 | 27 || 28 | 0 | OFF | SCL.2 | 18 | 265 |
...
From what I can see, the I2C pins are present but not active (mode is OFF). I tried multiple ways to scan for I2C devices but couldn’t detect any addresses.
I also tried your script, but I encountered the same issue when playing audio — it only added HDMI:
pi@orangepizero2w:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: CDC PCM Codec-0 [CDC PCM Codec-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ahubi2s0 [ahubi2s0], device 0: ahub_plat-snd-soc-dummy-dai snd-soc-dummy-dai-0 [ahub_plat-snd-soc-dummy-dai snd-soc-dummy-dai-0]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 3: HDMI [HDMI], device 0: ahub_plat-i2s-hifi i2s-hifi-0 [ahub_plat-i2s-hifi i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
Then I ran:
pi@orangepizero2w:~$ aplay -D plughw:1,0 1.wav
aplay: main:831: audio open error: Device or resource busy
pi@orangepizero2w:~$ aplay -D plughw:0,0 1.wav
Playing WAVE '1.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: pcm_write:2127: write error: Input/output error
Under dietpi you select your souncard with dietpi-config
and with a the audiocodec try this
aplay -D hw:0,0 /usr/share/sounds/alsa/Noise.wav
For i2c , you need to aplied the i2c0 pi-pin
Thank you so much. So fragment 0 and 1 are the same, but you enabled a few more nodes, right? Let me compare with what is expected without doing this:
+ codec: codec@05096000 {
+ #sound-dai-cells = <0>;
+ compatible = "allwinner,sun50i-h616-codec";
+ reg = <0x05096000 0x31c>;
+ interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&ccu CLK_BUS_AUDIO_CODEC>,
+ <&ccu CLK_AUDIO_CODEC_1X>,
+ <&ccu CLK_AUDIO_CODEC_4X>;
+ clock-names = "apb", "audio-codec-1x", "audio-codec-4x";
+ resets = <&ccu RST_BUS_AUDIO_CODEC>;
+ dmas = <&dma 6>;
+ dma-names = "tx";
+ status = "disabled";
+ };
and+&codec {
+ allwinner,audio-routing =
+ "Line Out", "LINEOUT";
+ status = "okay";
+};
Now I see the problem: the first is added to sun50i-h616.dtsi
, which is included by the Zero 2W device tree. But the second is added to sun50i-h616-orangepi-zero.dtsi
, which is loaded by the Zero 3 device tree only, same for the other nodes you enable. This is the reason it worked OOTB with Zero 3 device tree: build/patch/kernel/archive/sunxi-6.12/patches.armbian/Sound-for-H616-H618-Allwinner-SOCs.patch at e03b1b543cda430fbffcb62c979aecabee42b044 · armbian/build · GitHubNo idea why the Zero 2W device tree does not include sun50i-h616-orangepi-zero.dtsi
. Most likely because it defines an Ethernet node. But everything else looks doubled. Would make sense to move the Ethernet port to an own include file, of the device specific dts files, and include above into Zero 2W as well.
However, so we know how to fix it. The codec
node alone enables HDMI audio already, right? So that we could patch as enabled statically. For the other nodes: I am still not sure which nodes refer to which hardware:
ahub0
nodes are for a HAT attached to I2S0 pins?ahub1
nodes are for a HAT attached to I2S1 pins?ahub_dam_plat
is needed for either HAT?ahub0
and ahub1
nodes to be enabled at the same time, or does it make sense to split this into dedicated overlays?About the Ethernet node: Your HAT comes with one, IIRC? Does that one have a static MAC address, or does it change every boot? Because usually, U-Boot requires an ethernet0
alias to assign a static MAC address, and that one is added with the sun50i-h616-orangepi-zero.dtsi
node as well. So we could add/expand the overlay to support this HAT, not only for audio but for a static Ethernet MAC address as well, and possibly other features.
Hello Micha
For the new node i can explain somme part
ahub0 is for i2s0 on the hat connector
ahub1 is for HDMI sound
ahub-dam is for jack sound
This line is for activate the sound in alsamixer because it is down by defaut
"Line Out", "LINEOUT";
it’s the same that put in the terminal the line in this picture
And yes it work for HDMI and jack OOTB with the zero3.dtb
For i2C if you applied the dtbo file in the folder /boot/dtb/allwinner/overlay
with the command
G_CONFIG_INJECT 'overlays=' 'overlays=i2c0-pi' /boot/dietpiEnv.txt
you can obtain new i2c device with the tools
ls /sys/devices/platform/soc*/*/i2c-* | grep "i2c-[0-9]"
give
Sorry sangto2906 for sda.1 & scl.1 it’s i2c1