Orangepi CM4 with Dac PCM5102 on PCB via i2s1

Good evening
after my successful test of activating the I2S on the hat40 connector and the first test of the PCM5102 dac I decided to set up a small ultra simple sound server with LMS to power an amplifier associated with its speakers
To start I had this assembly


then I drew a small PCB to connect the PCM5102 to the hat40 as well as a connection for the fan ofthe box

And finally everything is assembled in an acrylic box found on the web

I control this small server from my smartphone
simple and efficient

1 Like

Hello, i have found this thread and would like to ask you something. In order for pcm5102 to work it needs to be also communicating on i2c? Or why is sck pin connected to i2c pin on orange pi? Or this pin is used for something else? Maybe if you know how it is configured in dts file would be helpfull. Thanks

Hello Adam369

More info here about the OPI CM4 with a custom dtb file

The PCM5102 just need a i2s bus and i put for my pcm5102a somme connection with the hat
PI0 → I2S SCK–>pin29
PI1 → I2S BCK–>pin12
PI2 → I2S LCK–>pin35
PI3 → I2S DATA–>pin40
5V → to VIN power of DAC board–>pin4
GND → to GND power of DAC board–>pin6

Hope it can help you

Hello all
@MichaIng , after some days with the orangepi zero2w for implementation of i2s

I’m be back with my OPI CM4 with a fresh image of OPI 3B with Dietpi 9.13.2(beta)

The deal, create a script initiated by MichaIng to implement i2s1 on this board with
a overlay-user and deployed it to have sound on a PCM5102A dac board connected
via the 40pin connector

The script

# Create the directory for user overlays
mkdir -p /boot/overlay-user
cd /boot/overlay-user
# Create the overlay source file
cat << '_EOF_' > i2s1.dts
/dts-v1/;
/plugin/;
/ {
   compatible = "rockchip,rk3566";
   fragment@0 {
        target-path = "/";
        __overlay__ {
                my_soundcard {
                    compatible = "simple-audio-card";
                    simple-audio-card,name = "PCM5102A";
                    simple-audio-card,format = "i2s";
                    status="okay";

                   simple-audio-card,cpu {
                        sound-dai = <&i2s1_8ch>;
                        //dai-tdm-slot-num = <2>;
                        //dai-tdm-slot-width = <32>;
                   };
                   simple-audio-card,codec {
                        sound-dai = <&codec_dummy>;
                   };

                };                   
                codec_dummy: codec_dummy {
                compatible = "rockchip,dummy-codec";
                #sound-dai-cells = <0>;
                status = "okay";
            };
        };
    };

    fragment@1 {
        target = <&i2s1_8ch>;
        __overlay__ {
            #sound-dai-cells = <0>;
            rockchip,clk-trcm = <1>;  //0: both tx_lrck/bclk and rx_lrck/bclk are used; 1: only tx_lrck/bclk is used; 2: only rx_lrck/bclk is used
            pinctrl-0 = <&i2s1m1_sclktx &i2s1m1_lrcktx &i2s1m1_sdo0 &i2s1m1_sdi0>;
            rockchip,playback-channels = <2>;
            rockchip,capture-channels = <2>;
            status = "okay";
        };
    };
        fragment@2{
                target = <&i2s2_2ch>;
                __overlay__ {
                        status = "disabled";
                };
        };
        fragment@3{
                target-path = "/";
                __overlay__ {
                        hdmi-sound{
                        status = "disabled";
                       };
                };
        };
        fragment@4{
                target-path = "/";
                __overlay__ {
                        sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "PCM5102A";
		       };
                };
        };
};
_EOF_
# Install the device tree compiler
apt install device-tree-compiler
# Compile the overlay binary file
dtc -I dts -O dtb -o i2s1.dtbo -@ i2s1.dts
# To see the result of the compiler uncommit next line
#fdtdump i2s1.dtbo
# Enable the user overlay via U-Boot environment file
G_CONFIG_INJECT 'user_overlays=' 'user_overlays=i2s1' /boot/dietpiEnv.txt

In a terminal just a few command when you are connected

sudo nano i2s1.sh

Copy and past the script

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

Run the script

sh i2s1.sh

Inject the user-overlay

G_CONFIG_INJECT 'user_overlays=' 'user_overlays=i2s1' /boot/dietpiEnv.txt

And reboot

in the script I only kept the PCM5102A sound card active because I use it with LMS under chromium kiosk

1 Like