Orbital6
Posts: 124
Joined: Sat Aug 08, 2015 6:32 pm

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

Sun Nov 22, 2015 5:38 pm

I've been trawling through posts about interfacing I2S, and 6by9 was kind enough to point me here, where i've been eyeing up bcm2835-i2s.c.

My question is, has anyone got the i2s bus on the RPi to decode audio IN (audio source is some other IC with master clock)?

kazimk
Posts: 8
Joined: Tue Nov 17, 2015 3:52 pm

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

Mon Dec 07, 2015 9:39 pm

I succesfully connect a stereo mems microphone to raspberry pi 2. My microphone is EVAL-ADMP441Z-FLEX Bottom-Port I2S Output MEMS. Do I need to load any driver to detect this microphone ?
Here it's user guide.
http://www.element14.com/community/serv ... uide_1.pdf

ruddyRudeman
Posts: 11
Joined: Wed Dec 09, 2015 3:11 pm

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

Fri Dec 11, 2015 3:16 pm

kazimk wrote:I succesfully connect a stereo mems microphone to raspberry pi 2. My microphone is EVAL-ADMP441Z-FLEX Bottom-Port I2S Output MEMS. Do I need to load any driver to detect this microphone ?
Here it's user guide.
http://www.element14.com/community/serv ... uide_1.pdf
Yes, you do. I advice you to read through this http://www.peteronion.org.uk/I2S/ , then use the guide from Plugh (http://www.raspberrypi.org/forums/viewt ... 75#p604231) , but on the part, where you compile my_loader.c, read carefully this thread (viewtopic.php?f=44&t=91237) and use the code that clara_sch provided.
It is not really straightforward, took me like two days to get it all working together.
I suppose the all-inclusive guide for fresh-flashed Jessie would be very welcome, and maybe I'll do it after I finish with i2s project myself.

exander
Posts: 11
Joined: Fri Feb 06, 2015 12:25 pm

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

Mon Dec 14, 2015 1:52 am

Hello, I am trying to record using I2S, compiled the module presented here, I am using PCM1803 in Master mode. But the recorded audio file is all zeroes. Any ideas?

kazimk
Posts: 8
Joined: Tue Nov 17, 2015 3:52 pm

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

Mon Dec 21, 2015 4:14 pm

Hi.I connected microphone and compiled and loaded my_loader as guided.I get this error.
bcm2708-i2s 3f203000.i2s: I2S SYNC error!
bcm2708-dmaengine 3f007000.dma: DMA transfer could not be terminated
I connected microphone
SD Serial digital output signal for I2S interface to DATA IN GPIO20
SCK Serial clock for I2S interface to BIT CLOCK GPIO18
WS Word select for I2S interface to DATA OUT GPIO21
and L/R Left/right channel select to LRCLOCK GPIO19
and Chip Enable to VDD 3.3
according to this guide
http://www.element14.com/community/serv ... uide_1.pdf

I changed SND_SOC_DAIFMT_CBM_CFM to SND_SOC_DAIFMT_CBS_CFS in my_loader.c.Error is gone but
arecord -D hw:1 -c 2 -r 48000 -f s32 -d 4 -t wav -v sample.wav
gives blank sample.wav.Do you have any suggestions?

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

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

Wed Dec 23, 2015 4:17 pm

Using the (modified my_loader) code from
viewtopic.php?p=803012#p803012
exactly "as is" what do you get when you enter:
aplay -l
arecord -l

kazimk
Posts: 8
Joined: Tue Nov 17, 2015 3:52 pm

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

Sun Dec 27, 2015 2:54 pm

Sorry for late answer.I bought a new microphone still no record. Outputs are
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndrpisimplecar [snd_rpi_simple_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: sndrpisimplecar [snd_rpi_simple_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

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

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

Mon Dec 28, 2015 12:14 pm

kazimk wrote:Sorry for late answer.I bought a new microphone still no record. Outputs are

arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: sndrpisimplecar [snd_rpi_simple_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

That is good news as it is exactly what I get. Though remember capture will be done on sound card 1, not card 0. (i.e. use "hw:1,0" rather than hw:0,0" ) Also google "asound.conf" on how to set the default card.

Also, checking your hardware connections, I suspect you may have two swapped wires. Signal "L/R" I guess needs to be hardwired to either gnd or vcc. Whereas "WS" needs to be connected to the I2S LR clock (GPIO19) Can you try this?

If this still doesn't work, and you have a scope, connect it to the LCK and SCK pins to see if a clock is generated when the capture program is started. .

kazimk
Posts: 8
Joined: Tue Nov 17, 2015 3:52 pm

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

Mon Dec 28, 2015 8:00 pm

Thank you so much.It worked after I changed conections like WS to LRCLOCK and Left/Right Channel to ground and setting volume with softvol example.From here
viewtopic.php?f=38&t=85845
Record quite noisy but at last it works.

Orbital6
Posts: 124
Joined: Sat Aug 08, 2015 6:32 pm

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

Sun Jan 10, 2016 8:08 pm

I finally got this working, but i have some minor clipping the captured audio.

Is it possible to know what the simple card / pi side / i2s standard is for attributes like:

*data read on clock falling or rising edge
*left/right justify?

Getting rid of those last clips by configuring the source device properly is proving a little difficult.

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

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

Sun Jan 10, 2016 8:19 pm

Are you referring to the occasional "tick" that I'm hearing in that file ? The don't sound like clipping but more like dropped frames. Have you looked at the saved waveform with an audio editor ?

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

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

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

Wed Jan 13, 2016 12:59 pm

Orbital6 wrote:I finally got this working, but i have some minor clipping the captured audio.

Is it possible to know what the simple card / pi side / i2s standard is for attributes like:

*data read on clock falling or rising edge
*left/right justify?

Getting rid of those last clips by configuring the source device properly is proving a little difficult.
The wrong left/right justify I2S format will result in very loud hiss type noise, so it isn't that.

Dropped frames would result in longer and louder clicks, so not that either.

Wrong clock polarity may result in the odd sample being misread, so could be that. Try inverting clock polarity.

Furthermore, a crude speed conversion (i.e. 44100 to 48000) may also result in similar clicks, so try changing sampling speed.

klawy.marcin
Posts: 1
Joined: Mon Jan 18, 2016 9:55 pm

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

Mon Jan 18, 2016 10:21 pm

Hi

We're having a problem with recording sound via I2S using PCM1803. If we record sound with e.g. arecord, everything works just fine, but the problem occurs when we try to record audio and video using picam (or ffmpeg). We figured out, that it has something to do with types of alsa drivers. USB devices uses mmap and I2S not. Because of that it is impossible to point hw device and to process signal "in real time"(but the same method works fine with USB sound cards) .We know that emulation of mmap can be turned on, but it doesn't work. With simulation turned on we record just noise. Do You have any solution to this problem?

Thank you in advance for your answer

Orbital6
Posts: 124
Joined: Sat Aug 08, 2015 6:32 pm

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

Tue Jan 19, 2016 3:47 pm

PeterO wrote:Are you referring to the occasional "tick" that I'm hearing in that file ? The don't sound like clipping but more like dropped frames. Have you looked at the saved waveform with an audio editor ?
PeterO
I've had success capturing long recordings on my RPi2 with no problems. When i use the same setup on my RPi1 i get strange results (Edit 1: i just set everything up again and after a few tries & resetting the rpi1 clock to 700 MHz, i was able to make what sounded like a perfect recording, though there is 1 click at the 32 second mark. I can't explain why it had problems before. ); I find that arecord spits out lots of overrun errors and my wav file is silent (all 0x00's), unless if i overclock my RPi1 to 800 (or 850, can't remember) MHz, which i can't explain. Now this presents a new problem that i'm guessing is linked to the changed clock speed, though i may be wrong: with arecord's captures at the correct sample rate (48 KHz) the audio is clearly shifted to a higher pitch, so i go to change the sample rate to some lower value like 44.1 KHz (the source is definitely 48 KHz) and the audio starts to sound correct but with a click at every second or so (similar to the dropbox link i provided earlier, but that wav file you can hear is not the same as my RPi1 captures, and the click on the RPi1 samples are perfectly equal in distance from one another). I will make another recording on the RPi1 as it seems i overwrote them with silent wav's, and look at the waveforms in audacity and probably post the findings here. Thanks Peter.
mjubes wrote: The wrong left/right justify I2S format will result in very loud hiss type noise, so it isn't that.
Dropped frames would result in longer and louder clicks, so not that either.
Wrong clock polarity may result in the odd sample being misread, so could be that. Try inverting clock polarity.
Furthermore, a crude speed conversion (i.e. 44100 to 48000) may also result in similar clicks, so try changing sampling speed.
You're absolutely right, originally even on my RPi1 i was getting a heck of a lot of noise. It turned out i needed to invert my clock polarity and change my BCLK frequency selection from 64fs to 32fs (not entirely sure what this is but by looking at the output of the i2s bus, it's clearly halving the length of a frame. You mention changing the sampling speed, do you mean changing that at my arecord command? I can't remember if i got the clicks at the higher pitched 48 KHz sample as mentioned above, but i thought that changing the sampling speed on arecord only changes the pitch, and not introduce clicks? I will capture some new samples at 48 KHz and see if i get the clicks their, and get back to you.
Edit 2: as mentioned in edit 1, for some reason this works now though there was 1 click. I'm using the clock polarity that worked on the rpi2, i'm not sure if should work exactly the same on the rpi1. I listened for a few minutes and didn't notice anything wrong, but if i do i'll invert the clock again and see if it fixes it.
klawy.marcin wrote:We're having a problem with recording sound via I2S using PCM1803. If we record sound with e.g. arecord, everything works just fine, but the problem occurs when we try to record audio and video using picam (or ffmpeg). We figured out, that it has something to do with types of alsa drivers. USB devices uses mmap and I2S not. Because of that it is impossible to point hw device and to process signal "in real time"(but the same method works fine with USB sound cards) .We know that emulation of mmap can be turned on, but it doesn't work. With simulation turned on we record just noise. Do You have any solution to this problem?
I too am trying to capture audio via the i2s bus, and view video from raspivid / picamera (python) simultaneously and am having errors on any pi / setup i use. the errors are 'overrun!!' errors when i try to make the audio captures. I wonder if our problems have the same solution? I couldn't quite understand yet why i am having this problem.
edit 3: turned out i could make captures while i had the camera connected but not the other device i have attached so we may have different solutions after all.

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

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

Thu Jan 21, 2016 4:28 pm

Orbital6 wrote: . You mention changing the sampling speed, do you mean changing that at my arecord command? I can't remember if i got the clicks at the higher pitched 48 KHz sample as mentioned above, but i thought that changing the sampling speed on arecord only changes the pitch, and not introduce clicks? I will capture some new samples at 48 KHz and see if i get the clicks their, and get back to you.
.
I do all my tests using C and the alsa development library, i.e. snd_pcm_open(), snd_pcm_readi() etc. A bit of heavy work to start with, but it shows exactly what happens when things go wrong, i.e. by inputting test patterns as audio inputs.

The 48 to 44.1 conversion clicks are caused (when using cheapo or simple sample converters) by sharp amplitude transitions caused when the difference between samples are not properly "smoothed" by the interpolator. The clicks will only happen when there is some input sound material that contains high frequencies. A fancy test is to feed a single high frequency sine wave to a loudspeaker. Move your head around to cancel the sine wave (time difference between the ears) and you will hear the conversion clicks clearly, if there are any.

Orbital6
Posts: 124
Joined: Sat Aug 08, 2015 6:32 pm

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

Thu Jan 21, 2016 4:54 pm

mjubes wrote:I do all my tests using C and the alsa development library, i.e. snd_pcm_open(), snd_pcm_readi() etc.
Interesting, what else can do you with the c + alsa dev lib? I ask as i'm having issues with my current setup, i can't capture i2s audio via arecord whilst having some other specific hardware running simultaneously, do you know any alternatives to arecord?

Also, did you use Plugh's loader (or a similar solution) for your i2s solution? I did successfully but i can't figure out why it's working when my codec is set to snd-soc-dummy (dmesg gives mapping errors when i used the dmic codec), as seen here. How does the system know what parameters are supported, such as what are usually provided in codecs?
mjubes wrote:The 48 to 44.1 conversion clicks are caused (when using cheapo or simple sample converters) by sharp amplitude transitions caused when the difference between samples are not properly "smoothed" by the interpolator. The clicks will only happen when there is some input sound material that contains high frequencies. A fancy test is to feed a single high frequency sine wave to a loudspeaker. Move your head around to cancel the sine wave (time difference between the ears) and you will hear the conversion clicks clearly, if there are any.
It seems i was getting strange behaviour when I had the pi overclocked. Your test is interesting and i will perform it when i get around to finding an appropriate sine wave.

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

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

Fri Jan 22, 2016 2:59 pm

Orbital6 wrote:
Interesting, what else can do you with the c + alsa dev lib?
Basic operations are capture incoming sound to a given RAM array (repeatedly on an interrupt basis) and send the contents of an array to the sound device (again, on an interrupt basis) The only thing you need to do is to fill the arrays using "C" with your own data (e.g. synthesized sinewaves) but do it fast enough before the next request!! .

A simple "echo" device consists of writing and reading from the same array!

In reality you need to do all this with overlapping circular buffers to avoid leapfrogging, but for simple tests you can get away with the simple stuff.

Orbital6 wrote:
Also, did you use Plugh's loader (or a similar solution) for your i2s solution?
.
Yes, I just copied the latest version and used it "as is". But have no idea how to set the small detail parameters (clock, bits, speed etc). My guess is that most of these have to be defined in the snd_soc_bcm2708.c source rather than here.
.

Orbital6
Posts: 124
Joined: Sat Aug 08, 2015 6:32 pm

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

Fri Jan 22, 2016 4:51 pm

mjubes wrote:Basic operations are capture incoming sound to a given RAM array (repeatedly on an interrupt basis) and send the contents of an array to the sound device (again, on an interrupt basis) The only thing you need to do is to fill the arrays using "C" with your own data (e.g. synthesized sinewaves) but do it fast enough before the next request!! .
So, would this be the equivalent to calling 'arecord .... sample.wav' as that's essentially what i'm after.
Was there some keywords or a site you can send me to so i can see some examples on how to get started with this stuff?
mjubes wrote:My guess is that most of these have to be defined in the snd_soc_bcm2708.c source rather than here.
.
I wasn't aware of such a file, where does that live?

I was getting confused by the .platform and .cpu_dai.name ("bcm2708-i2s.0", i know it's different like 203000.. for some people), as i did not know if this was referring to a file? Do you know? could it be referring to the snd_soc_bcm2708.c file you just mentioned?

jthorpe
Posts: 8
Joined: Mon Jan 18, 2016 1:36 am

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

Sat Jan 23, 2016 1:25 am

Hi All,

I'm attempting to interface an Si4735 (AM/FM Radio) which has an i2s output to a Raspberry Pi.

I've connected the following:
Si4735 DOUT -> PCM_DIN
Si4735 DFS -> PCM_FS
Si4735 DCLK -> PCM_CLK

The Si4735 is then programmed over i2c with the following parameters:
Output Format: i2s, 16-bit, sample on rising edge of DCLK.
Sample Rate: 48000

When I use the my_loader.c to set up the device, the module loads and arecord can see it:

Code: Select all

**** List of CAPTURE Hardware Devices ****
card 1: sndrpisimplecar [snd_rpi_simple_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
I then try to record:

Code: Select all

arecord -D hw:1 -c 2 -r 48000 -f s16 -v -t wav test.wav
Which fails, leaving the following in the dmesg output:

Code: Select all

[ 6884.089565] bcm2708-i2s 20203000.i2s: I2S SYNC error!
[ 6903.543898] bcm2708-dmaengine 20007000.dma: DMA transfer could not be terminated
The documentation for this device describes the digital audio interface as running in slave mode (https://www.silabs.com/Support%20Docume ... 35-D60.pdf page 23) which matches what I have in the my_loader.c (unmodified)

Code: Select all

.daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM,
There seems to be bit of an oddity with this device insofar as the programming documentation (https://www.silabs.com/Support%20Docume ... /AN332.pdf page 86) states "The system controller must establish DCLK and DFS prior to enabling the digital audio output else the device will not respond and will require reset.".

The question is, how do I establish DCLK and DFS before using the device?

One way I've tried (and failed) was to start arecord prior to using the device. This doesn't seem to change the behaviour however.

Does anyone have any advice on how I might be able to get i2s working on this device?

Edit:
Still no luck, but I have modified my program to use the alsaaudio Python library to set the properties for recording audio and actually start to attempt capturing before I set the Si4735 in digital audio mode.

Prior to resetting and enabling the chip, I'm doing:

Code: Select all

import alsaaudio
...
audio_device = "hw:CARD=sndrpisimplecar,DEV=0"
inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL, audio_device)
...
inp.setchannels(2)
inp.setrate(48000)
inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
And then do an actual capture within a separate thread which is started immediately before I enable the device for digital audio. I have this logging each frame capture (it's blocking) and it never seems to capture anything, resulting in the same error in the dmesg output:

Code: Select all

[  251.379650] bcm2708-i2s 20203000.i2s: I2S SYNC error!

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

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

Sat Jan 23, 2016 3:34 pm

Orbital6 wrote:
So, would this be the equivalent to calling 'arecord .... sample.wav' as that's essentially what i'm after.
Was there some keywords or a site you can send me to so i can see some examples on how to get started with this stuff?

Basically yes, with the added advantage that you can programmatically manipulate the buffers.
Here are some of the websites I used for learning about the ALSA API, a bit daunting to start with, but very straightforward once you have used it for a while.

http://alsamodular.sourceforge.net/alsa ... howto.html
http://equalarea.com/paul/alsa-audio.html
http://www.alsa-project.org/alsa-doc/al ... ample.html
Orbital6 wrote:
I was getting confused by the .platform and .cpu_dai.name ("bcm2708-i2s.0", i know it's different like 203000.. for some people), as i did not know if this was referring to a file? Do you know? could it be referring to the snd_soc_bcm2708.c file you just mentioned?
I have to admit this is all black magic territory to me. I just tried various combinations until it all worked.

The one thing I know for sure is that files beginning with 203000.. relate only to the raspberry Pi B+.
If you are using a P2 you must replace them with files beginning with 3f3000...

jthorpe
Posts: 8
Joined: Mon Jan 18, 2016 1:36 am

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

Sun Jan 24, 2016 1:31 am

Woohoo! Success with i2s and the Si4735!

The first issue I had was that I was incorrectly reading the my_loader.c as it if were referring to the Broadcom i2s bus which meant I had the clock and frame master/slave incorrect. Since the si4735 operates in slave mode only, changing this to the following results in no more Sync errors:

Code: Select all

.daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS
The next problem is that the Si4735 needs a clock source. This can either be provided by an external clock or using a crystal. The trick with this is that when you're using the digital audio mode, you have to supply a clock source rather than use the crystal.

Luckily, the rPI's GPIO 4 can be configured as the clock source I need. I just can't seem to find a way to do it in Python at the moment.

Once I did this, I was able to use the Python alsaaudio to open up the capture device, set the Si4735 in the appropriate mode and capture it (in this case, either a file or to the rPI's sound card - both which work great).

Edit:
Work in progress code if anyone is interested:
https://gist.github.com/JonathanThorpe/ ... ca62a28647
Last edited by jthorpe on Mon Jan 25, 2016 12:24 am, edited 1 time in total.

Orbital6
Posts: 124
Joined: Sat Aug 08, 2015 6:32 pm

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

Sun Jan 24, 2016 9:04 pm

Am i right in thinking that only a 32fs (BCK frequency selection [BCLK/frame]) works with the pi? If i set it to 64fs then all i hear is white noise. I'm trying to look for an ADC with i2s out but most of them seem to go to 64fs as a minimum, and i can't figure out how to change the bits per frame in the bcm2708 driver. Any ideas?
jthorpe wrote:I was able to use the Python alsaaudio to open up the capture device, set the Si4735 in the appropriate mode and capture it (in this case, either a file or to the rPI's sound card - both which work great).
Congratulations on your success! I've been using arecord to capture audio, just wondering how you captured audio in python, and if you could share any code you may or may not have found online so i can quickly replicate your setup.
mjubes wrote:
Orbital6 wrote:
So, would this be the equivalent to calling 'arecord .... sample.wav' as that's essentially what i'm after.
Was there some keywords or a site you can send me to so i can see some examples on how to get started with this stuff?

Basically yes, with the added advantage that you can programmatically manipulate the buffers.
Here are some of the websites I used for learning about the ALSA API, a bit daunting to start with, but very straightforward once you have used it for a while.

http://alsamodular.sourceforge.net/alsa ... howto.html
http://equalarea.com/paul/alsa-audio.html
http://www.alsa-project.org/alsa-doc/al ... ample.html
Thank you for the links :)

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

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

Tue Jan 26, 2016 11:29 am

Orbital6 wrote:Am i right in thinking that only a 32fs (BCK frequency selection [BCLK/frame]) works with the pi? If i set it to 64fs then all i hear is white noise. I'm trying to look for an ADC with i2s out but most of them seem to go to 64fs as a minimum, and i can't figure out how to change the bits per frame in the bcm2708 driver. Any ideas?

I don't know if this is relevant, but I found I keep getting the following strange results:

If I first open (using alsa_open) a capture device, set for 48000, 24 bits, 2channels. I get a i2s waveform consisting of a 48000 LCK, but with a BCK of just 2.4MHz (i.e. 50fs rather than the expected 64fs).

However, if I first open a playback device, set for 48000,24,2, the i2s waveform is now correct at 48000 LCK, and 3.07MHz (64fs as it should be).

If after that, I then open a capture device, I then get the right 64fs frequencies

Seems like opening just a capture device does not seem to be initialising the registers and clocks properly. You may need to do a dummy playback device open first

Odd?

Dunkan
Posts: 2
Joined: Tue Feb 16, 2016 9:41 am

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

Tue Feb 16, 2016 11:02 am

Hi.
I'm trying to interface the WM8731 audio codec on MICROE-506 proto audio board. I use Raspberry Pi Model B+ V1.2
I become the message „bcm2708-i2s 20203000.i2s: I2S SYNC error!“ and hear just noise and whistlling.

My board is connected as follow:

Code: Select all

SCK -> J8-Pin12
MISO -> J8-Pin38
MOSI -> J8-Pin40
ADCL,DACL -> J8-Pin35
SDA -> J8-Pin3
SCL -> J8-Pin5
3.3V -> J8-Pin17
GND -> J8-Pin39
Here some outputs:

Code: Select all

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpiproto [snd_rpi_proto], device 0: WM8731 HiFi wm8731-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
pi@raspberrypi:~ $ cat /proc/asound/cards
 0 [sndrpiproto    ]: snd_rpi_proto - snd_rpi_proto
                      snd_rpi_proto
pi@raspberrypi:~ $ cat /proc/asound/modules
 0 (null)
dmesg

Code: Select all

pi@raspberrypi:~ $ dmesg | tail -n 50
[    4.743905] systemd[1]: Started Create list of required static device nodes for the current kernel.
[    4.778996] systemd[1]: Started Load Kernel Modules.
[    4.802859] systemd[1]: Time has been changed
[    4.922277] systemd[1]: Started udev Coldplug all Devices.
[    5.140482] systemd[1]: Starting Apply Kernel Variables...
[    5.157466] systemd[1]: Mounting Configuration File System...
[    5.187557] systemd[1]: Mounted FUSE Control File System.
[    5.222705] systemd[1]: Starting Create Static Device Nodes in /dev...
[    5.239114] systemd[1]: Starting Syslog Socket.
[    5.255653] systemd[1]: Listening on Syslog Socket.
[    5.255982] systemd[1]: Starting Journal Service...
[    5.305266] systemd[1]: Started Journal Service.
[    5.637128] systemd-udevd[88]: starting version 215
[    6.813731] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    6.814090] snd-rpi-proto sound: ASoC: CODEC DAI wm8731-hifi not registered
[    6.814123] snd-rpi-proto sound: snd_soc_register_card() failed: -517
[    7.718180] bcm2835-rng 20104000.rng: hwrng registered
[    8.123049] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    8.393205] random: nonblocking pool is initialized
[    9.932621] systemd-journald[85]: Received request to flush runtime journal from PID 1
[   10.675770] snd-rpi-proto sound: ASoC: CODEC DAI wm8731-hifi not registered
[   10.675811] snd-rpi-proto sound: snd_soc_register_card() failed: -517
[   10.683478] spi spi0.0: setting up native-CS0 as GPIO 8
[   10.690387] snd-rpi-proto sound: ASoC: CODEC DAI wm8731-hifi not registered
[   10.690426] snd-rpi-proto sound: snd_soc_register_card() failed: -517
[   10.692314] spi spi0.1: setting up native-CS1 as GPIO 7
[   10.703154] snd-rpi-proto sound: ASoC: CODEC DAI wm8731-hifi not registered
[   10.703193] snd-rpi-proto sound: snd_soc_register_card() failed: -517
[   10.709729] snd-rpi-proto sound: ASoC: CODEC DAI wm8731-hifi not registered
[   10.709772] snd-rpi-proto sound: snd_soc_register_card() failed: -517
[   10.711017] wm8731 1-001a: Assuming static MCLK
[   10.711831] bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[   10.724673] snd-rpi-proto sound: wm8731-hifi <-> 20203000.i2s mapping ok
[   12.621474] cfg80211: Calling CRDA to update world regulatory domain
[   12.958287] cfg80211: World regulatory domain updated:
[   12.958332] cfg80211:  DFS Master region: unset
[   12.958347] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[   12.958369] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[   12.958385] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[   12.958401] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
[   12.958419] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[   12.958437] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[   12.958454] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
[   12.958470] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
[   12.958485] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
[   13.926402] Adding 102396k swap on /var/swap.  Priority:-1 extents:5 across:266236k SSFS
[   14.815435] bcm2708-i2s 20203000.i2s: I2S SYNC error!
[   15.266775] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[   16.742831] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1
[   46.786178] bcm2708-i2s 20203000.i2s: I2S SYNC error!
My /boot/config.txt:

Code: Select all

pi@raspberrypi:~ $ cat /boot/config.txt
# For more options and information see
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README
# i2s / DAC driver:
dtoverlay=rpi-proto
dtoverlay=i2s-mmap
#dtoverlay=hifiberry-dac


# memory split:
gpu_mem=16

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
dtparam=i2c_arm=on
Modules:

Code: Select all

pi@raspberrypi:~ $ lsmod
Module                  Size  Used by
snd_hrtimer             1945  1
snd_seq_dummy           1594  0
snd_seq_midi            5114  0
snd_rawmidi            22605  1 snd_seq_midi
snd_seq_oss            33353  0
snd_seq_midi_event      7515  2 snd_seq_oss,snd_seq_midi
snd_seq                57837  7 snd_seq_midi_event,snd_seq_oss,snd_seq_dummy,snd_seq_midi
snd_seq_device          5130  4 snd_seq,snd_rawmidi,snd_seq_oss,snd_seq_midi
cfg80211              477515  0
rfkill                 21439  1 cfg80211
i2c_bcm2708             6068  0
spi_bcm2835             7948  0
bcm2835_rng             2215  0
bcm2835_gpiomem         3703  0
uio_pdrv_genirq         3550  0
uio                    10002  1 uio_pdrv_genirq
snd_soc_bcm2708_i2s     7566  2
regmap_mmio             3556  1 snd_soc_bcm2708_i2s
snd_soc_rpi_proto       3100  0
snd_soc_wm8731         12466  1
snd_soc_core          167798  3 snd_soc_wm8731,snd_soc_rpi_proto,snd_soc_bcm2708_i2s
snd_compress            8813  1 snd_soc_core
snd_pcm_dmaengine       5778  1 snd_soc_core
snd_pcm_oss            38906  0
snd_mixer_oss          14957  1 snd_pcm_oss
snd_pcm                92397  5 snd_pcm_oss,snd_soc_wm8731,snd_soc_core,snd_soc_rpi_proto,snd_pcm_dmaengine
snd_timer              21932  3 snd_hrtimer,snd_pcm,snd_seq
snd                    66988  12 snd_pcm_oss,snd_soc_wm8731,snd_soc_core,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_seq_oss,snd_seq_device,snd_compress,snd_mixer_oss
regmap_spi              2315  1 snd_soc_wm8731
regmap_i2c              3346  1 snd_soc_wm8731
i2c_dev                 6406  0
ipv6                  354610  20
I used

Code: Select all

aplay test.wav -D sysdefault:CARD=0 -f dat -v -V mono
to play sound.

Can someone help me? What should I change to avoid I2S sync errors?

Dunkan
Posts: 2
Joined: Tue Feb 16, 2016 9:41 am

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

Wed Feb 17, 2016 9:43 am

I found out, that .wav files with 48000 Hz rate are played good, but it also comes to "I2S SYNC error".

Any idea?

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

Who is online

Users browsing this forum: No registered users and 13 guests