lhoic
Posts: 14
Joined: Wed Sep 19, 2012 1:16 pm
Location: Auterive, France

Re: I2S sound: Anyone got it running? (answer is yes!)

Tue Apr 14, 2015 4:43 pm

Hi

First, thank you for all the work you have achieved.
I have a device (similar to an ADC) which the output is as shown in the following screenshot.
pic_130_3.gif
pic_130_3.gif (29.18 KiB) Viewed 11879 times
In yellow, the data that I will wish to play (2x16 payload bits) (only the first 32 bits).
In blue, the frame sync.

This is similar to I2S bus with some changes.
It seems that this mode is called the DSP mode.
Example for Texas Instrument:

Image

Do you think it is possible to change the I2S driver to work?
Can you help me with this?

Thank you in advance for your answers.

Loïc

rondadon
Posts: 11
Joined: Thu Feb 02, 2012 12:36 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Fri Apr 24, 2015 10:09 pm

Hi there!

I want to use the RPI2 withthe CurrymanDAC (ES9023) directly over the GPIO Pins. Volumio is working and the Sound is playing through the crappy 3,5mm Audio Port of the RPI2.

I connected the RPI2 to the currymanDAC like this:

RPI2<->CurrymanDAC
PIN12<->BCK
PIN35<->LRCK
PIN39<->GND
PIN40<->SDI

I changed the I2S Settings though the WebUI to "Generic", restarted the RPI but still the sound only comes out through the crappy 3,5mm Audio port.
I also tried some other I2S Settings from the Dropdown menue but it didn't help me with my problem.

Did I oversee something important/essential? Do I need to install or load drivers/modules?!

Can anyone help me to get the RPI 2 with volumio working with I2S and the currymanDAC?!

Thanks in advance!

trexualhealing
Posts: 1
Joined: Tue May 12, 2015 12:45 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Tue May 12, 2015 1:17 pm

Hi,

Here's my challenge:

Read out 8 microphones simultaneously with the Pi in the most simple way, at min. sample frequency of 16 kHz, with a maximum error in the timing in the order of microseconds. The timing errors are allowed to be bigger they are known and constant so they can be accounted for later in the software.

Would it be possible to use digital (MEMS) microphones which give I2S output and connect them to the Pi?

Can someone point me in the right direction?

carla_sch
Posts: 17
Joined: Wed Mar 18, 2015 5:23 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Sat May 16, 2015 11:06 am

There is only one i2s interface on the raspberry pi.
Stereo is supported so you can connect two microphones to an
i2s adc board which is connected to the i2s interface.
If you need 8, maybe you can do this with an FPGA board
or use 4 raspberries.

shahid_ce131001
Posts: 1
Joined: Sat May 09, 2015 5:53 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Sun May 17, 2015 2:46 pm

hello everyone. is there possible to interface I2s Pulse Density Modulation PDM microphone through Raspberry pi as it is mentioned in peripheral interface but, i never see someone used it, and none of examples. please someone suggest some detail.
thanks

yaz
Posts: 1
Joined: Sun May 17, 2015 6:50 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Sun May 17, 2015 10:08 pm

Hi,
I have a basic question:
I donot have a DAC but I want like to measure the BCLK,LRCLK and SDATA using an oscilloscope directly from the gpio pins 18, 19 and 21 respectively of my RPi 2 model B.
I have already activated the i2s modules using the dtparams (since I use raspbian 3.18.xx)
I have connected my oscilloscope contact to gpio 18 (clk) and ground. Now, If I play a .wav file of 48kHz fs, using command:
aplay -D sound48k.wav
I expect to see a signal at oscilloscope. But I don't at any of the 3 pins! What am I missing here? I may sound silly :roll: here, but plz guide me. Thanks

carla_sch
Posts: 17
Joined: Wed Mar 18, 2015 5:23 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Tue May 19, 2015 6:28 am

You need a sound device for i2s to output something e.g.
aplay -D hw:1,0 sound48k.wav
Otherwise the sound goes to the default sound output.
I only did sound input this way. I had
to use a kernel module that creates this device and sets some
parameters (rate and sample format, e.g 48000 and S24_LE and who ist master)
first. There seems to be a program to do this for
audio output: http://archphile.org/howto/i2s-dacs-and ... pberry-pi/

erotavlas
Posts: 41
Joined: Wed Mar 11, 2015 5:26 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Sat Jul 04, 2015 11:30 am

Dantell wrote:New to this, looking for a bit of help. I have a B+ and am trying to interface it with my MiniDSP using I2S. I've read through everything i could find. The only real pin outs with explanations i could find were for using the P5 header. I saw one diagram and pic with pin outs for the B+, to connect a different DAC but none of the pins were labelled.

I've read how someone got the two interfaced with general descriptions but it was the previous model. It looks to me like:

Pin 40: SCLK = DATA
Pin 39: Ground
Pin 35: MISO = LRCLK
Pin 14: PCM_C = BCLK

The article i read on connecting the two states:

"The output of the ADAU1701 is an I2S master. That means it can be used also as the master clock for the input. With this setup – output BCLK and LRCLK connected to input BCLK and LRCLK, there is no need for an external clock source. The ADAU1701 can create all the necessary clocks with the onboard resonator."

So my PIN 40 Data would connect to PIN 10 on the MiniDSP I2S_DATA_IN 1&2 ?
PIN 39 would connect to one of the Ground pins on the MiniDSP like 25
PIN 35 would connect to PIN 14 on the MiniDSP - I2S_IN_LRCLK
PIN 14 would connnect to PIN 15 on the MiniDSP - I2S_IN_BCLK

Or would 35 and 14 on RPi be connected to the LRCLK and BCLK outputs of the MiniDSP since it is the clock source? Am i correct in thinking the clock signals have to fed back to the RPi to synchronize the data flow?

just trying to understand, thank you for the help.
Hi Dantell,
I'm trying to connect my miniDSP to the Raspberry Pi B+ via I2S too. I saw your post in this thread, I found a mistake. The correct Pin out of Raspberry Pi B+ is this:

Pin 40: SCLK = DATA
Pin 39: Ground
Pin 35: MISO = LRCLK
Pin 12: PCM_C = BCLK // not Pin 14 which in Raspberry Pi B+ is a ground

Moreover, you should connect as you the second time:
Pin 40 -> Pin 10 MiniDSP DATA_IN
Pin 39 -> Pin 25 MiniDSP Ground
Pin 35 -> Pin 14 MiniDSP LRCLK_OUT
Pin 12 -> Pin 15 MiniDSP BCLK_OUT
In this way the miniDSP clock should drive the I2S bus.

Let me know if it works.

erotavlas
Posts: 41
Joined: Wed Mar 11, 2015 5:26 pm

Re: I2S: Anyone got it running? (answer is yes!)

Fri Jul 10, 2015 2:24 pm

kruesn wrote:I run the MCLK_In of the ADAU from a 12.288MHz crystal for 48kHz. From this the ADAU creates his master clock and the LRCLK and BCLK which I put out on MP10+11. Since the ADAU needs those clocks on his serial input ports as well, I connect them to its MP4+5 ports (LRCLK_In and BCLK_In) and to the corresponding I2S pins on P5 of the Raspi.

I2S data runs from P5 of the RPi to Sdata_In (MP0) and grounds are connected, too.

In that way the serial output ports of the ADAU act like a controller in the I2S specification (see image).
Hi kruesn,
I read about your post and your configuration of RPi and ADAU1701. I did the same and so I found a confirm of my work. How, I'm a looking for a way to enable software support on raspbian. I read that you used Sabre ESS901 driver with Frame Sync Freq equal to 48kHz (ADAU1701 master clock /1024) and BCLK is 3,072MHz (master clock /16). Moreover, you changed the SND_SOC_DAIFMT_CBS_CFS to SND_SOC_DAIFMT_CBM_CFM, compiled, copied the kernel and modules and changed some parameter in the /etc/modules and /etc/asound.conf.
Your post is quite hold. The current support in main kernel https://github.com/raspberrypi/linux/tr ... soc/codecs. Are there any news?
Thank you

LisaJK
Posts: 14
Joined: Sat Jul 11, 2015 6:21 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Sat Jul 11, 2015 6:49 am

I'm trying to get an I2S mic working, no control GPIO, no I2C, no SPI.

I followed Plugh's log. Everything seems to work except that when I load the module, i get the following from dmesg:

[ 95.409720] asoc-simple-card asoc-simple-card.0: ASoC: CPU DAI bcm2708-i2s.0 not registered
[ 95.409845] platform asoc-simple-card.0: Driver asoc-simple-card requests probe deferral

I have also tried with the code from here:

viewtopic.php?f=44&t=91237&p=749707

It loads but doesn't seem to work, dmic seems to be replaced by dummies.

Anyone any ideas?

ub_ob
Posts: 3
Joined: Thu Jul 30, 2015 9:42 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Jul 30, 2015 9:47 am

did anyone use the mikroe wm8731 / protoboard recently?

i'm trying with the device tree overlay (ie, dtoverlay=rpi-proto) but i'm not getting any sound, instead dmesg just says:

Code: Select all

 I2S SYNC error!

Code: Select all

bcm2708-dmaengine bcm2708-dmaengine: DMA transfer could not be terminated
aplay just seems to be stuck at 0%:

Code: Select all

#+                                                 | 00%
any hints, anyone? dmesg also says:

Code: Select all

snd-rpi-proto sound: wm8731-hifi <-> 20203000.i2s mapping ok
so i assume the codec is ok?

ub_ob
Posts: 3
Joined: Thu Jul 30, 2015 9:42 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Wed Aug 05, 2015 12:30 pm

anyone?
fwiw, same behaviour with 4.0.9, i2s-mmap-overlay doesn't make a difference either.

is there anything i might miss re: asound.conf? mine simply looks like this:

Code: Select all

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

also, fwiw, here's my i2s signals:

wm8731 --> model A+

BLCK --> PCM_CLK / GPIO18 / pin #12
DACLRC/ADCLRC --> PCM_FS / GPIO19 / pin #35
ADCDAT --> PCM_DIN / GPIO20 / pin #38
DACDAT --> PCM_DOUT / GPIO21 / pin #40

i2c seems to be ok; power looks good, too.

weirdly enough, arecord / the ADC seems to sort of work, at least it doesn't get stuck with the "DMA transfer could not be terminated" error (though the "I2S SYNC error!" persists). in that case, i'm seeing ~ 3.072 MHz at GPIO18, which sounds about right; and 48kHz at GPIO19.

still no dice with aplay though, or speaker-test, or mplayer.
Last edited by ub_ob on Tue Aug 11, 2015 2:03 pm, edited 3 times in total.

LisaJK
Posts: 14
Joined: Sat Jul 11, 2015 6:21 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Mon Aug 10, 2015 10:57 pm

FYI, got the Knowles I2S microphone working on the I2S, sounds great!

SND_SOC_DAIFMT_CBS_CFS as part of .fmt in the loader means that it expects the CODEC to be slave and therefore the RPi provides the clocks.

If you want the Rpi to be slave, then you must use SND_SOC_DAIFMT_CBM_CFM.

ub_ob
Posts: 3
Joined: Thu Jul 30, 2015 9:42 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Fri Aug 14, 2015 8:00 am

edit, so after playing around a bit more, I seem to be getting this new item with dmesg:

Code: Select all

wm8731 1-001a: Assuming static MCLK
snd-rpi-proto sound: wm8731-hifi <-> 20203000.i2s mapping ok
Not sure whether that's something to do with me upgrading to 4.1.5+; anyways, not quite sure what this means, ie "assuming static MCLK". Is it a bad sign, or simply to do with the fixed 12.288 clock?

mhelin
Posts: 128
Joined: Wed Oct 17, 2012 7:18 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Aug 27, 2015 4:17 pm

I have been playing with the philpoole's Pi I2S driver (https://github.com/philpoole/snd_pi_i2s ... m_pi_i2s.c), trying to make it use DMA (just for learning the ALSA, the ASoC driver works perfectly). However, I can't get it produce anything but the sound of a broken CD-player. It seems that the DMA part works fine, and aplay plays the noise for the time the wav file should last. Also there are no errors in any DMA buffer allocations or anywhere (using DMA channel 2 for playback). I'm yet to look at the signal at scope, but the DAC works fine using the Hifiberry DAC driver. I'm on 4.1.4+ kernel. Any ideas what to do? I'm using the ALSA PCM DMAEngine (sound/core/pcm_dmaengine.c) for what it can be used for (no DT support etc). The sound produced sounds like the same buffer is played again and again even though the DMA completion callback seems to be triggered just fine.
Last edited by mhelin on Thu Aug 27, 2015 4:29 pm, edited 1 time in total.

mhelin
Posts: 128
Joined: Wed Oct 17, 2012 7:18 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Aug 27, 2015 4:23 pm

Nevermind, got it working. The normal preallocation doesn't seem to be working on RPi.

With the "normal" I mean the one most often used:
ret = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), 16*4096,16*4096);

(or snd_pcm_lib_preallocate_pages_for_all in device init).

Instead this one works fine (I think also the SoC Generic DMAEngine uses it):
ret = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_IRAM,
chan->device->dev, 16*4096,16*4096);

For some reason the ASoC driver sounds yet better, got to fine tune the PCM interface parameters.

mjubes
Posts: 36
Joined: Thu Oct 01, 2015 8:17 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 8:28 am

I2S ADC capture and Jessie

I have managed to get I2S capture working on a RPI P2 running Jessie by just installing the built in snd-soc-dmic.ko driver and the my_loader.ko driver "as is" using insmod, as mentioned in plugh's post:

viewtopic.php?f=44&t=8496&start=575#p604231


All very simple, but I have a small problem. When I (programmatically) open alsa for capture using
snd_pcm_open(&fd, "plughs:1,0"...) etc. I get a sample clock only 24 times the frame clock.

However, if I then open alsa for playback, close it, then open for capture as above, I get the correct 32:1 ratio. And it stays at 32:1 no matter how often I open and close (until a reboot of course)

Sounds to me like the capture subsystem is not initialising the hardware correctly, or perhaps missing some initialisations out.

Any suggestions where to look, or what to change?

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 9:43 am

I'm about to embark on getting my PCM1803A adc to work on Jessie. First problem is that rpi-source seems to have downloaded the wrong kernel version :-(
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mjubes
Posts: 36
Joined: Thu Oct 01, 2015 8:17 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 9:52 am

I just downloaded the latest kernel 4.1.7-v7 from the information given in:

(1) http://www.raspberrypi.org/documentatio ... uilding.md
(2) http://www.raspberrypi.org/documentatio ... iguring.md
(2) http://elinux.org/Raspberry_Pi_Kernel_Compilation

I didn't follow the instructions in the rpi-source document as the dmic.ko was already present and could be loaded with
an insmod command. But I did compile "my_loader.c" using the above.


>I'm about to embark on getting my PCM1803A adc to work on Jessie. First problem is that rpi-source seems to have downloaded >the wrong kernel version :-(
>PeterO

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 9:56 am

mjubes wrote:I just downloaded the latest kernel 4.1.7-v7 from the information given in:

(1) http://www.raspberrypi.org/documentatio ... uilding.md
(2) http://www.raspberrypi.org/documentatio ... iguring.md
(2) http://elinux.org/Raspberry_Pi_Kernel_Compilation

I didn't follow the instructions in the rpi-source document as the dmic.ko was already present and could be loaded with
an insmod command. But I did compile "my_loader.c" using the above.
Thanks, I'll try following those instead. rpi-source used to work, and I think I can update it on git if it is broken !
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 2:31 pm

I've put my source files in the right places. added appropriate entries to Kconfig files and run make menuconfig and set my modules to "M", but make modules isn't compiling them. Have I missed a step ?
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mjubes
Posts: 36
Joined: Thu Oct 01, 2015 8:17 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 3:40 pm

I didn't do any of that, as I found the driver was already there:

/linux/sound/soc/codecs/snd-soc-dmic.ko

I just added a line to /etc/rc.local to load it dynamically on boot.
insmod /linux...../dmic.ko


The only other thing I did was compiling the "my_loader.c" file into "my_loader.ko" and then add another line in /etc/rc.local:

insmod /.../my_loader.ko

That's all I did. Didn't do any of the instructions in the rpi- text.

TBH. I am not too sure exactly what I am doing, but it all seemed to work.



>I've put my source files in the right places. added appropriate entries to >Kconfig files and run make menuconfig and set my modules to "M", but make >modules isn't compiling them. Have I missed a step ?
>PeterO7

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Thu Oct 01, 2015 8:19 pm

mjubes wrote:TBH. I am not too sure exactly what I am doing, but it all seemed to work.
:D
I have to agree with you. On my A+ running weezy My I2S codec is all loaded via a device tree overlay that does the job the proper way. Sadly I can't find the notes I made at the time I got it going hence I'm having to "re-work it out" again :-(

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mjubes
Posts: 36
Joined: Thu Oct 01, 2015 8:17 am

Re: I2S sound: Anyone got it running? (answer is yes!)

Fri Oct 02, 2015 2:40 pm

To get RPI working as an I2S player, I only placed the following files in /etc/modules:
(an did nothing else)

snd_soc_core
snd_soc_bcm2708_i2s
bcm2708_dmaengine
snd_soc_pcm1794a
snd_soc_rpi_dac

And it all started to work OK. No idea what I did, or which of the above files are important or redundant.
All black magic stuff!!! :-)



>/I have to agree with you. On my A+ running weezy My I2S codec is all loaded via a device tree overlay that does the job the >proper way. Sadly I can't find the notes I made at the time I got it going hence I'm having to "re-work it out" again :-(

Bitplayer
Posts: 2
Joined: Sat Oct 10, 2015 3:12 pm

Re: I2S sound: Anyone got it running? (answer is yes!)

Sat Oct 10, 2015 4:03 pm

I am interested in using I2S with external clocks. Having gone through the thread, I am still not clear about how to set this up. I would be grateful if someone could do a summary for beginners!

Do any of the available configurations make the emphasis bit available externally?

Is it possible to output left or right-justified data rather than I2S format?

Return to “Interfacing (DSI, CSI, I2C, etc.)”