Raspberry PI with I2S audio out, and trying I2S audio in.

The basic concept is that I2S Audio runs on SPI1 on the PI3.  The PI2/PI3 have 2 SPI’s (SPI1 and SPI0). With SPI0 evidently being a full featured interface with two enable pins, while SPI0 has only one enable pin.

It does appear possible to run 4 audio streams on I2S thru SPI0.  The speaker Bonnet would have 2 streams for stereo output, and the MEMS mic would have 2 streams for stereo input. To wire them together causes contention in the drive currently.  With two different drivers to drive two different audio functions on the same bus.   I have limited knowledge on how to use either SPI thru the new kernel interfaces (device tree).

RPI pinout

The Adafruit Speaker Bonnet uses I2S and a MISO (Master In Slave Out) pin.  The I2S mic uses a MOSI (Master Out Slave IN) pin. I2S is via SPI1.

The speaker out uses snd_bcm2835, and mic in uses a kernel module you have to build.

At the moment the two are conflicted;


[    3.540234] i2c /dev entries driver
[    3.644933] my_loader: loading out-of-tree module taints kernel.
[    3.650534] request module load 'bcm2708-dmaengine': 0
[    3.650955] register platform device 'asoc-simple-card': 0
[    3.651115] Hello World :)
[    3.841256] systemd-udevd[147]: starting version 215
[    4.285633] gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
[    4.334938] snd-hifiberry-dac soc:sound: pcm5102a-hifi <-> 3f203000.i2s mapping ok
[    4.546427] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    4.621951] bcm2835-i2s 3f203000.i2s: Trying to bind component to card "snd_rpi_simple_card" but is already bound to card "snd_rpi_hifiberry_dac"
[    4.621966] asoc-simple-card asoc-simple-card.0: ASoC: failed to instantiate card -19

So what would the next steps be to have both types of I2S audio working, microphone in, and speaker output through the same SPI1?

I already looked some at the kernel my_loader.c and other c sources. Not being familiar with Kernel module compiling it has some very special changes.

I think the easiest way to have both I2S devices working on the same Raspberry PI would be to use the two separate SPI’s one for each task. It wasn’t immediately apparent on how to do this, so I think it requires ‘digging’ to find a solution.

MEM’s mic module;
https://github.com/PaulCreaser/rpi-i2s-audio

https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/overview

 

Speaker Module;
https://learn.adafruit.com/adafruit-speaker-bonnet-for-raspberry-pi/overview

It’s just a start.

So these two bits of info talk about using SPI0, and that it has two enable pins out on the pin header.

https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md

https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial

eSpecialized's Blog

Bill Thompson

I am a mobile smartphone and embedded Linux engineer. I love to tinker with electronics and fly drones in spare time when not geeking out in a developers world!

3 thoughts on “Raspberry PI with I2S audio out, and trying I2S audio in.

  • September 13, 2017 at 5:03 am
    Permalink

    Running into the same issue here! Haven’t found a solution yet, but I’ll keep checking back, and I’ll post anything I figure out too. Good luck and thanks for making me feel less alone!

    Reply
  • February 10, 2020 at 8:20 pm
    Permalink

    Were you all able to solve the issue

    Reply
    • June 15, 2020 at 12:07 pm
      Permalink

      Right now, I don’t recall getting Audio Input to work via I2S, only output. Most projects use the Input Mic or a USB microphone (easiest method to get working) and I recall that was what I had to do, USB Microphone input.

      I2S is digital input, and you would need a DAC / PCM to I2S that is compatible (I don’t fully understand the details).

      I look around and see this as a potential lead; http://www.peteronion.org.uk/I2S/

      Your best way forward is to google “raspberry pi I2s audio in” I get lots of links to this.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.