How to enable I2S0 for audio output

I just bought the Rock PI S v1.2 and wanted to attach a simple I2S audio amplifier (Adafruit I2S 3 W CLASS D AMPLIFIER Breakout MAX98357A)

I installed the Ubuntu Bionic image from the downloads page.

aplay -L is showing the rockchip acodec device (default:CARD=rockchiprk3308a) and I can start speaker-test to play something on the device. However, there is no sound. All of the SDO and LRCK pins as well as whe MCLK pins stay quiet.

After some digging in the device tree it looks like the I2S0 device is disabled and I found the DMIC overlay. The DMIC overlay seems to work and activates the MCLK but still no sound output.

My knowledge of device trees is extremely limited and I have not been able to hack something together that would expose I2S0.

I cannot believe that noone has tried to play sound through the digital interface?

I searched through all the forums and google, is there an existing overlay to activate this?

I found the Hifiberry overlay for the RockPi4 and decompiled it but it looks sufficiently different that I am pretty sure it wouldn’t work just like this.

That enables the I2S and pins even though she concentrates on mic input the output is working because it turns off the codec line out as I found.

But why you want to add a dac to a board with built in codec is a mystery to me but yeah you can.
Not sure why Radxa haven’t created an overlay yet but editing the DTS & DTB is pretty easy.

Cool, I had seen this post at some point but then forgot about it again. This actually worked now!

It would still be better to have working through an overlay but I may be able to figure that out.

Regarding using an external dac, I didn’t realise when I bought the board that it has on-board audio apart from the digital one so I had the dac. I also need something powerful but 3W is not much anyway so I’ll end up adding another amp anyway and the on-board dac might work fine.

The audio out needs DC blocking caps and still to try, but does have some dc hum without caps.

Same about overlays as not hard to provide, dunno why radxa don’t.

This is my fave tpa3116 board of the moment as has a mute input also. Good value but get a 24vDC supply and run the RockPiS off a 5v buck regulator.

I am planning to use this amplifier as a last stage. Wuns off 12V and 60W is plenty loud. It’s also very small.

https://www.amazon.de/gp/product/B07KQDKVLC/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Its got a mute and you might want to set something up with gpio as all the tpa can give a bit of an annoying hum in idle.

I initially tired with different overlays, but didn’t really manage -

I would be extremely interested to know when you manage to get it working! I haven’t found the time to tinker around with this board since, but would like to get it working as it’s the a blocker for making it a nice media streamer (Volumio/Spotify etc) out of this board.

It works only thing you need to mind is the @baronets is using a custom kernel and the dtb & dts names are wrong.
If you check through the boot is using the rk3308-rock-pi-s.dtb not the rock rock-pi-s-linux.dtb or whatever its called.

@ash

This actually worked now!

Also haven’t checked output but I2S input certainly works with the above, when you get the right .dtb name.

PS with the I2S mics the cheaper ones seem identical in perf as different more expensive models.

https://www.aliexpress.com/item/4000045517597.html like all the I2S prob need a softvol for digital gain in asound.conf

pcm.array {
type hw
card 1
}

pcm.array_gain {
 type softvol
   slave {
   pcm "array"
   }
 control {
   name "Mic Gain"
   count 2
   card 1
   }
 min_dB -40.0
 max_dB 10.0
 resolution 80
}

Something approx like that but should get you going for a google.
Strange thing about softvols or often something that will confuse, it will not exist in alsamixer until you aplay or arecord first.

I created a new device tree file which you can find here (this is part of my open source effort to build a home automation system):

Installation:

  1. copy rk3308-rock-pi-s-mod.dtb to /boot/dtbs/4.4.143-52-rockchip-g7ed61b60d176/rockchip/ (I think your specific folder might vary depending on board version)

  2. edit /boot/uEnv.txt and change the following line:
    fdtfile=rockchip/rk3308-rock-pi-s.dtb
    to
    fdtfile=rockchip/rk3308-rock-pi-s-mod.dtb

  3. edit /etc/asound.conf and insert this:

    pcm.!default {
    type hw
    card 1
    }

    ctl.!default {
    type hw
    card 1
    }

This should set the default sound device to the correct one and now play through the I2S0 pins:
12: I2S0_8CH_SCLK_TX
18: I2S0_8CH_SDO0
22: I2S0_8CH_LRCK_TX

I will still try making an overlay when I find the time.

1 Like

Yeah had the RockPiS for a while and it did a bit of dust gathering but doing something similar in terms of a Alexa/Google voice AI.

Anyway before I forget if you get an urge to add mics I forgot to say the cheap and cheerful I2s seem to be just as good as any other I2S mics.
Good value and easy to wire up.

I am waiting for a crew called Linto to see if they are going to do anything more with their KWS and tensorflow model creator.
Hence things started to gather dust a bit, but https://linto.ai/ if of any interest.

I have been looking at https://github.com/badaix/snapcast to stream after KWS to a ASR server and the RockPiS is just at an excellent price point for that.
Hence why my amp is slightly bigger as the idea is to have x2 in a stereo pair that are also distributed mic arrays.
Snapcast is a great bit of opensource sonos like RTP latency adjusted client/server but still got a bit of a KWS hurdle.

Radxa are quite open about wiki submissions and will usually give you an account it would be great if you did a tutorial and maybe provided an overlay, but getting something on the wiki would be great.
Its a great audio soc at a really great price and find it bemusing they haven’t added much audio info.