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

Re: I2S Success (at last) !

Mon Dec 07, 2015 6:24 pm

Any idea why there are no files in my /sys/kernel/debug/ ?

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

Re: I2S Success (at last) !

Wed Dec 09, 2015 3:17 pm

I am trying to make i2s work on my raspi a+ (Jessie). More specifically, I am trying to connect TLV320AIC3204 as input device. I compiled its module from latest sources, installed the module. It loads with modprobe succesfully, but arecord -l does not show any new recording device. Please, help me to get it working

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

Re: I2S Success (at last) !

Wed Dec 09, 2015 5:46 pm

When I try to follow this http://www.peteronion.org.uk/I2S/, I get error trying to compile my_loader:

Code: Select all

make: Entering directory '/home/pi/linux-bc1669c846b629cface0aaa367afb2b9c6226faf'
  CC [M]  /home/pi/i2s/loader/my_loader.o
/home/pi/i2s/loader/my_loader.c:31:3: error: unknown field ‘fmt’ specified in initializer
   .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM,
   ^
/home/pi/i2s/loader/my_loader.c:35:3: error: unknown field ‘fmt’ specified in initializer
   .fmt = 0,
   ^

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

Re: I2S Success (at last) !

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?

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

Re: I2S Success (at last) !

Mon Dec 14, 2015 7:52 am

exander wrote: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?
Check if I2S device is properly supplied and puts out its word- and bit-clocks. If it does not, check its configuration with datasheet. When the codec is in master mode, it should give clocks even without raspi. If it does, then something is wrong with raspi itself. Check if pins are right. Another test is to configure raspi as master in my_loader.c , and shorting the data pin to 3.3V, it should record all 'FF's (all bits high)

correct pinout:
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

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

Re: I2S Success (at last) !

Thu Dec 17, 2015 8:25 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
Do you have any suggestions?
Last edited by kazimk on Mon Dec 21, 2015 4:06 pm, edited 3 times in total.

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

Re: I2S Success (at last) !

Thu Dec 17, 2015 8:47 pm

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.Looking for suggestion.

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

Re: I2S Success (at last) !

Mon Dec 21, 2015 4:30 pm

By the way, has anyone got duplex I2S working? As I understand wolfson soundcard for raspi can play and record simultaneously, but is there a generic codec that can do it dmic-style?

bricolodu13
Posts: 38
Joined: Tue Aug 07, 2012 2:05 pm

Re: I2S Success (at last) !

Tue Jan 26, 2016 12:13 pm

Hello,

I just received some OSH boards from MCHamster
Did someone has already build this kit ?
Please could you send me a schematic to build the ADCs, as it doesn't look it is an exact "copy" of the original sparkfunkit that is no longuer available.


Thank you,
Jean

alaimodiloro
Posts: 2
Joined: Wed Feb 03, 2016 8:22 am

Re: I2S Success (at last) !

Wed Feb 03, 2016 8:39 am

ruddyRudeman wrote:When I try to follow this http://www.peteronion.org.uk/I2S/, I get error trying to compile my_loader:

Code: Select all

make: Entering directory '/home/pi/linux-bc1669c846b629cface0aaa367afb2b9c6226faf'
  CC [M]  /home/pi/i2s/loader/my_loader.o
/home/pi/i2s/loader/my_loader.c:31:3: error: unknown field ‘fmt’ specified in initializer
   .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM,
   ^
/home/pi/i2s/loader/my_loader.c:35:3: error: unknown field ‘fmt’ specified in initializer
   .fmt = 0,
   ^
Hello,
I am encountering the same error and could use some help to fix it. any ideas?

dummy.bullet
Posts: 1
Joined: Sun Feb 28, 2016 8:27 am

Re: I2S Success (at last) !

Sun Feb 28, 2016 8:43 am

Hello everyone.

I'm trying to inputing sound from ADMP441(I2S microphone) to Raspberry Pi 2.
But I got no sounds in output's file of arecord.(File isn't blank, but no sounds.)
Please help me. What's wrong?

Pins are connected as followings.
  • GPIO18 to ADMP441's SCK
  • GPIO19 to ADMP441's WS
  • GPIO20 to ADMP441's SD ( And SD pin is pull down with 100 kΩ)
My loader's code is followings.

Code: Select all

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/platform_device.h>
#include <sound/simple_card.h>
#include <linux/delay.h>
/*
modified for linux 4.1.5
inspired by https://github.com/msperl/spi-config
with thanks for https://github.com/notro/rpi-source/wiki
as well as Florian Meier for the rpi i2s and dma drivers

to use a differant (simple-card compatible) codec
change the codec name string in two places and the
codec_dai name string. (see codec's source file)

fmt flags are set for vanilla i2s with rpi as clock slave

N.B. playback vs capture is determined by the codec choice
 */

void device_release_callback(struct device *dev) { /* do nothing */ };

static struct asoc_simple_card_info snd_rpi_simple_card_info = {
	.card = "snd_rpi_simple_card", // -> snd_soc_card.name
	.name = "simple-card_codec_link", // -> snd_soc_dai_link.name
	.codec = "snd-soc-dummy", // -> snd_soc_dai_link.codec_name
	.platform = "3f203000.i2s",
	.daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFM,
	.cpu_dai = {
		.name = "3f203000.i2s", // -> snd_soc_dai_link.cpu_dai_name
		.sysclk = 0
	},
	.codec_dai = {
		.name = "snd-soc-dummy-dai", // -> snd_soc_dai_link.codec_dai_name
		.sysclk = 0
	},
};
static struct platform_device snd_rpi_simple_card_device = {
	.name = "asoc-simple-card", //module alias
	.id = 0,
	.num_resources = 0,
	.dev = {
		.release = &device_release_callback,
		.platform_data = &snd_rpi_simple_card_info, // *HACK ALERT*
	},
};
int hello_init(void)
{
	const char *dmaengine = "bcm2708-dmaengine"; //module name
	int ret;

	ret = request_module(dmaengine);
	pr_alert("request module load '%s': %d\n",dmaengine, ret);
	ret = platform_device_register(&snd_rpi_simple_card_device);
	pr_alert("register platform device '%s': %d\n",snd_rpi_simple_card_device.name, ret);

	pr_alert("Hello World :)\n");
	return 0;
}
void hello_exit(void)
{// you'll have to sudo modprobe -r the card & codec drivers manually (first?)
	platform_device_unregister(&snd_rpi_simple_card_device);
	pr_alert("Goodbye World!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_DESCRIPTION("ASoC simple-card I2S setup");
MODULE_AUTHOR("Plugh Plover");
MODULE_LICENSE("GPL v2");
lsmod result after `insmod my_loader.ko` is followings.
Module Size Used by
my_loader 1469 0
snd_soc_simple_card 6115 0
cfg80211 389253 0
rfkill 16036 2 cfg80211
8192cu 519604 0
snd_soc_bcm2708_i2s 6670 2
regmap_mmio 2842 1 snd_soc_bcm2708_i2s
snd_soc_core 127477 3 snd_soc_simple_card,snd_soc_bcm2708_i2s
snd_compress 7689 1 snd_soc_core
snd_pcm_dmaengine 3231 1 snd_soc_core
bcm2835_gpiomem 2860 0
bcm2835_rng 1763 0
uio_pdrv_genirq 2944 0
uio 7753 1 uio_pdrv_genirq
snd_pcm_oss 37389 0
snd_mixer_oss 13919 1 snd_pcm_oss
snd_bcm2835 19802 3
snd_pcm 73442 4 snd_bcm2835,snd_pcm_oss,snd_soc_core,snd_pcm_dmaengine
snd_timer 18792 1 snd_pcm
snd 50779 13 snd_bcm2835,snd_pcm_oss,snd_soc_core,snd_timer,snd_pcm,snd_compress,snd_mixer_oss
bcm2708_rng 961 0
i2c_dev 5671 0
fuse 80694 3
ipv6 338574 32
dmesg's result is followings.
[10891.967047] request module load 'bcm2708-dmaengine': 0
[10891.980160] asoc-simple-card asoc-simple-card.0: snd-soc-dummy-dai <-> 3f203000.i2s mapping ok
[10891.988838] register platform device 'asoc-simple-card': 0
[10891.994363] Hello World :)

vjvarada
Posts: 14
Joined: Wed Mar 16, 2016 7:12 pm

Re: I2S Success (at last) !

Mon Mar 28, 2016 8:00 am

My issue was with the select line. When i connect select to ground, DATA OUT wouldn't show anything. It would record when Select was given HIGH

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Tue Apr 19, 2016 12:48 pm

carla_sch wrote:It compiles and recording works - but I did not yet check the result
Don't forget to change master to slave for your knowles mic :
............
.codec_dai = {
.name = "snd-soc-dummy-dai", //"dmic-codec", // -> snd_soc_dai_link.codec_dai_name
.sysclk = 0 },
};
.........
Hi. I'm trying with an SGTL5000 on RPi3. I can put in snd-soc-sgtl5000 for the .codec field of asoc_simple_card_info, but then it will accept nothing I can find for the .name in .codec_dai. I tried snd-soc-sgtl5000, I tried sgtl5000-hifi (after Plugh's example), I tried 3f203000.i2s, I tried snd-soc-dummy-dai (which exists in /sys/kernel/debug/asoc/dais).
I have the sgtl5000 module loaded, but no matter what value I put there, in place of "snd-soc-dummy-dai" above, it says it is not registered.

If I use Carla's version as is, it compiles, loads, and even shows me a dummy card, but, of course, I can't configure my codec, as its kernel module is not linked anywhere, and I have no sound in or out.
Where else can I find a value to try for .codec_dai's .name field???

Much thanks!
-Chuckk

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Tue Apr 19, 2016 10:22 pm

I'm still struggling.
I have a question for clarification. With Carla's version of Plugh's loader, using names taken from my own /sys/kernel/debug/asoc, I can manage to at least load a module and see a soundcard; now, the actual codec I have is, unfortunately, programmed extensively through I2C. So am I to understand that, if I have the wiring done right and manually send all the necessary I2C messages, then use this dummy loader, RPi (3) will not worry about what card is there but will start sending and reading I2S data?
It seems such a waste when the makers of my SGTL5000 published a codec driver which is part of the mainline kernel, but I can find no way to get it to register itself as DAI.
I'll be gritting my teeth over it, but I can write scripts to control my codec without the help of the driver, IF I know that this solution is supposed to send I2S data without asking questions. Is that the goal?

Thanks.
-Chuckk

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

Re: I2S Success (at last) !

Wed May 18, 2016 10:49 pm

if I have the wiring done right and manually send all the necessary I2C messages, then use this dummy loader, RPi (3) will not worry about what card is there but will start sending and reading I2S data?
The soundcard must provide the clocks and the data from the microphones, the RPi has to be slave,
You have to program the card so that it behaves that way via I2C.

If you want to use the SGTL5000 codec driver you may have to look in the source code of the kernel module to find
the correct names.

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Tue Jun 07, 2016 11:27 am

I've been working on this in every spare second for almost 2 months.
I can manually set up the codec, no problem. i even managed to modify some testing code from Simon Hughes to match the BCM's I2S format with the codec's I2S format, and to synthesize a saw wave that plays at the right frequency and volume on both sides. Theoretically, the next step is to send audio frames to this program through a named pipe; then I can at least use my own programs.
But I can't control the timing of arbitrary audio programs from a makeshift driver that isn't registered as an audio device with the system.
My problem with your loader was always that it plays at the wrong speed, even though the codec, as timing master, was sending the correct bit clock speeds. I tried turning off resampling the ALSA way and manually telling every program to use the sampling rate I wanted, but it still played back 1 1/3 times the correct speed.

I'm back to trying to work this out, and i see that bcm2835-i2s and simple card are both actually platform drivers. I understand that your/Plugh's loader represents a machine driver, which is supposed to unite a platform driver and a codec driver. Could you, or someone, tell me, then, in this loader, what is the codec driver??

-Chuckk

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

Re: I2S Success (at last) !

Mon Jun 13, 2016 11:00 pm

1/3 faster looks as if you are sending 24 bits instead of 32 bits /Audio sample and Channel.

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Wed Jun 15, 2016 3:37 pm

carla_sch wrote:1/3 faster looks as if you are sending 24 bits instead of 32 bits /Audio sample and Channel.
I thought of that, too, but it's not so. If I could set RPi I2S to send at 8000 SPS, I could verify the output with my Arduino logic analyzer, but I have no control over the output sample rate. Changing Audacity to use 8000 by default has no effect on the sound. I'm baffled. If I manually set up I2S, it plays perfectly, but there is no sound device on the system and I don't have DMA set up. It is only with this loader that some rate somewhere is wrong.

Chuckk

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Wed Jun 15, 2016 3:40 pm

Incidentally, I tried to use my codec's ALSA driver, sgtl5000, according to Plugh's instructions, but the codec is never listed in /sys/kernel/debug/asoc/codecs. Another aspect about which I can find no info online. Any idea how to get my codec listed there. This would be thrilling!

Chuckk

gargle
Posts: 3
Joined: Thu Jun 16, 2016 9:09 am

Re: I2S Success (at last) !

Thu Jun 16, 2016 9:14 am

Hi all,

I would like to create a sound card using the sgtl5000 (teensy audio board) for Raspberry 2.
When I wire the power and I2C, i2cdetect don't see anything.
I miss something ?

Thanks for your answer
Phi

User avatar
audio-badger
Posts: 15
Joined: Wed Jun 15, 2016 9:44 am

Re: I2S Success (at last) !

Thu Jun 16, 2016 9:16 am

Hi All,
has anyone had success in getting a simple I2S input device working on Rpi3 with a recent build of jessie? (I'm using 4.4.13-v7+)

Getting simple I2S output working is now very easy by adding the following to /boot/config.txt:

Code: Select all

dtoverlay=hifiberry-dac
..and it all just works beautifully after a reboot. I tried all of the other overlays including dtoverlay=rpi-proto and see no devices. I also monitored I2C pins on /dev/i2c-1 to see if wanted to see a slave and nothing...

So I have followed the steps mentioned in this thread, build my_loader.c and insmod'd it into the kernel and dmesg just gives:

Code: Select all

asoc-simple-card asoc-simple-card.0: ASoC CPU DAI not registered
I have esured the following line in /boot/config.txt is set too

Code: Select all

device_tree=
Has anyone has this working? It would be good to get some confidence that this is still the right route. Any pointers very greatly appreciated!

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Thu Jun 16, 2016 9:59 am

gargle wrote:Hi all,

I would like to create a sound card using the sgtl5000 (teensy audio board) for Raspberry 2.
When I wire the power and I2C, i2cdetect don't see anything.
I miss something ?

Thanks for your answer
Phi
The datasheet for the SGTL5000 explains that, until it has a "master clock" input, it is effectively dead. Here is how I did it:
viewtopic.php?p=957996#p957996
and some more details with a hopeless plea for suggestions:
viewtopic.php?p=970660

I do not have the thing working correctly, but that first post at least tells you how to get it to show up with i2cdetect.
I'm happy to see more people are trying to use this board. It's better designed than the mbed board, which seems to have a pretty amateur approach to separating analog/digital power sources, i.e., not separating them at all; and it's cheaper than most of the "supported" Pi boards. It also doesn't cover the entire GPIO header. The only problem is ALSA.

-Chuckk

larrycz
Posts: 1
Joined: Thu Jun 16, 2016 5:46 pm

Re: I2S Success (at last) !

Thu Jun 16, 2016 5:50 pm

audio-badger wrote:So I have followed the steps mentioned in this thread, build my_loader.c and insmod'd it into the kernel
I thought I would share how I built the my_loader module on Jessie with this kernel version. Default update repositories didn't include build files for the running kernel so I used a script written by notro to get them:

https://github.com/notro/rpi-source

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

Re: I2S Success (at last) !

Thu Jun 16, 2016 5:52 pm

When the codec is i2s master it is setting the sampling rate, not the raspberry, so if
you want to change the sampling rate you have to tell the codec to use
a different one, or change the frequency of the master clock.

chuckkh
Posts: 54
Joined: Fri Apr 01, 2016 8:03 am

Re: I2S Success (at last) !

Thu Jun 16, 2016 6:56 pm

Right, I know. But, with the codec putting out a verified 44100 set of clocks and RPi playing a 44100 sr wav file, something is resampled or misinterpreted. With RPi as timing master, it still plays too fast.
If I'm manually configuring the codec with i2c, ALSA doesn't know how the codec ia configured. Today I tried 8000 sr with Pi as master to use a logic analyzer... and the device wouldn't load...

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