Jump to content

How to enable I2S on a NanoPi NEO?


ygoe

Recommended Posts

Hello,

 

I've been playing on my Raspberry Pi 3B+ with an I2S audio amplifier and could play music from it. Now I want to add more devices to experiment with multi-room systems. The only other system with I2S support I have here is a NanoPi NEO. It has dedicated I2S pins so that shouldn't be too complicated. I thought. But it doesn't work. 'aplay -l' says "no soundcards found" and 'speaker-test -c2' essentially says the same. 'armbian-config' doesn't have a switch to enable I2S, only SPDIF, which sounds plausible considering that the SPDIF pin is multipurpose while the I2S pins are not.

 

A web search for several terms didn't bring up something useful. Searching this forum for "i2s" gives me even no result at all, which I consider an error because I've seen this topic discussed here from the web results already.

 

So I have no clue how to make I2S work on a NanoPi NEO with Armbian (all updated). The pins are connected correctly (I believe) but the software doesn't seem to know that these pins exist. On the RasPi I had to create the file /etc/asound.conf. I also tried that on Armbian but it has no effect. Maybe its contents does not apply here? What do I have to configure or install to make this work? Shouldn't it work on its own already as the other tools are also pre-installed?

Link to comment
Share on other sites

Oh dear, that is complicated. I don't have such an Armbian build system. I guess that needs to be a powerful Linux computer. What exactly is the trouble if this was enabled right in the distribution kernel? Is it unstable? Could it cause random noise or data loss? Does it eat kittens at night?

 

I'm actually looking towards a Raspberry Pi Zero with a USB Ethernet adapter for my project instead of the nice little NanoPi.

Link to comment
Share on other sites

On 10/4/2021 at 10:14 PM, ygoe said:

Oh dear, that is complicated. I don't have such an Armbian build system. I guess that needs to be a powerful Linux computer. What exactly is the trouble if this was enabled right in the distribution kernel? Is it unstable? Could it cause random noise or data loss? Does it eat kittens at night?

It doesnt do any harmful.....
The good thing is - I2S is compiled into the actual kernels, but had to be enabled in the .dtb (decompile .dtb to dts, enable it, compile .dts to .dtb)

This isnt available via armbian-config.....

 

Then compile a addon-overlay dts to  dtb onto the Neo via 1 commandline

 

You havent to use the armbian-build-system anymore  - all can be done on the Neo after installing armbian :)
See this Message in the old Thread:

 

Link to comment
Share on other sites

Okay, thank you, that looks much more like my skillset. I followed all the steps and gathered the mentioned files from the rest of the thread. I can see an I2S device but volume control and MP3 playback don't work yet.

 

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

 

aplay -L

null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=I2Smaster
    I2S-master, 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0
    Default Audio Device
dmix:CARD=I2Smaster,DEV=0
    I2S-master, 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0
    Direct sample mixing device
dsnoop:CARD=I2Smaster,DEV=0
    I2S-master, 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0
    Direct sample snooping device
hw:CARD=I2Smaster,DEV=0
    I2S-master, 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0
    Direct hardware device without any conversions
plughw:CARD=I2Smaster,DEV=0
    I2S-master, 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0
    Hardware device with all software conversions

 

alsamixer

cannot open mixer: No such file or directory

 

alsamixer -c 0

This sound device does not have any controls.

 

mpg123 some.mp3

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
        version 1.25.13; written and copyright by Michael Hipp and others
        free software (LGPL) without any warranty but with best wishes
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Segmentation fault

 

speaker-test

speaker-test 1.2.2

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Playback open error: -2,No such file or directory

 

Something seems to be different today than when you showed your log.

Link to comment
Share on other sites

I used the following short code as /etc/asound.conf :
 

pcm.!default {
    type hw
    card 0
    device 0
}

ctl.!default {
    type hw
    card 0
}

 

This only defined the card 0 subdevice 0 as standard and didnt create a soft-volume-control ( I also dont know if it would work when created).
I use the I2S without volume,control, because its digital I control the volume-level externally on the speakers.

 

for mpg123 you can also address the Card 0 directly (when there is no asound.conf) with the -a option like

mpg123 -v -b 1024 -a hw:0,0 ./your_song.mp3
see 
https://linux.die.net/man/1/mpg123

or use

speaker-test -DI2Smaster -c2
see
https://linux.die.net/man/1/speaker-test

 

Link to comment
Share on other sites

Well, I cannot reproduce your configuration. It just doesn't work on my copy of the device. Are you sure the kernel already knows what to do without recompiling? Can I verify this somewhere? Should I find a log entry somewhere? Or how else can I see why aplay lists a device that noone else can find? Are we talking about a current version of "Armbian 21.08.2 Focal with Linux 5.10.60-sunxi" on a NanoPi NEO? I'm using a fresh installation, latest download image as of yesterday, nothing else installed or modified so far.

 

BTW, in the meantime I've also tried out FriendlyElec's own Ubuntu Linux image. It already comes with all sorts of audio devices but none of them works either. I can't remember the details, I've posted it to their forum. But that looks pretty dead to me, my post as a new user wasn't moderation-approved within 3 days and I cannot see my post anymore/yet.

 

Here's the current output of

speaker-test -DI2Smaster -c2

speaker-test 1.2.2

Playback device is I2Smaster
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM I2Smaster
Playback open error: -2,No such file or directory

 

Link to comment
Share on other sites

I installed the bullseye version of Kernel 5.10.60-sunxi and my named asound.conf

 

Sound Test is right with this command:

speaker-test -Dhw:I2Smaster -c2

 

Inet-Radio Stream is playing here with

mpg123 -v -b 1024 http://mp3.ffh.de/radioffh/hqlivestream.mp3

 

dmesg onyl shows 

root@nanopineo:~# dmesg |grep -i sound
[    1.228909] Advanced Linux Sound Architecture Driver Initialized.
[    3.873701]   No soundcards found.
 

Link to comment
Share on other sites

Alright, I've retried with the Debian instead of Ubuntu image. Same steps as before.

 

I can indeed hear something now. Very loud. And very noisy. Nothing but noise actually. I've prepared a very quiet mp3 file (scaled down by -20 dB) because I knew 100% volume would be way too loud. And it just comes out of my speakers as loud noise. Seems like the device was actually found this time but the data it generates is completely unusable, near random. The noise stops as soon as I terminate mpg123. I'm afraid my speakers might get damaged by this. Totally unusable.

 

If this is all we get, I'll have to find a solution with Raspberry Pi really. I don't want that because these boards are much bigger, more expensive and need 3x the power. I haven't tried with a Raspberry Pi Zero (non-W), might need to get one of them. But their hardware is really old now. And I need an ugly external USB Ethernet adapter for it. I wish Raspberry Pi OS supported other hardware, too.

 

But I really need the software volume control as well because my amplifier or speakers have no control, they just do what they get. It's those tiny 3 W boards but I found they're totally enough for my ears (and also my neighbours').

 

BTW, is it normal that the second 'dtc' command to compile the device tree writes out 223 warnings?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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