Page 1 of 13

How to setup and test

Posted: Sun Jul 24, 2016 9:54 pm
by flatmax
I have some scripts which allow you to easily setup your /boot/config.txt to load the correct audio injector device tree. The raspbian inastallable .deb package is attached, first unarchive it and then install the deb package.
audio.injector.scripts_0.1-1_all.deb.tar.gz
The installable package for setup, mixer settings and testing
(3.9 KiB) Downloaded 5744 times
To setup your system (if you want to do this manually, look at the end of this message) :
Automated setup method
  • Download and install the attached deb file.
  • Run audioInjector-setup.sh command from the command line (by typing it in and pressing return).

    Code: Select all

    audioInjector-setup.sh
    This script will update your firmware firstly (by running rpi-update) and then alter your /boot/config.txt file to add the device tree to load (dtoverlay=audioinjector-wm8731-audio).
  • Reboot to force the correct device tree to load.
Mixer settings
Turn up the manual volume control knobs on the card - to a desired level !
Included are also two reference alsa mixer files which will allow you to setup default output with either line input or microphone input :
* asound.state.MIC.thru.test : This will setup the microphone as the input and also setup the output. Run

Code: Select all

alsactl --file /usr/share/doc/audioInjector/asound.state.MIC.thru.test restore
* asound.state.RCA.thru.test : This will setup the RCA lines as the input and also setup the output. Run

Code: Select all

alsactl --file /usr/share/doc/audioInjector/asound.state.RCA.thru.test restore
Testing
There is a test script which plays a pulsing 10 kHz tone at high volume through the system. To use it, make sure you don't have speakers plugged in ! Plug in an RCA cable from input to output (Red to Red, White to White). Also plug cheap headphones into the headphone jack and place them near to the Audio Injector so that the microphone can hear them. Lastly run the script :

Code: Select all

audioInjector-test.sh
It should plot the spectrograms which show the pulsing 10 kHz signal
test.screenshot.png
Example screenshot of the test results.
test.screenshot.png (154.01 KiB) Viewed 59019 times
.

Manual setup method
  • Ensure you have the latest kernel : sudo rpi-update
  • Make sure the default audio device tree is not loaded for PWM output (/boot/config.txt), this is because it uses the same I2S bus. (Comment out dtparam=audio=on)
  • Make sure the Audio Injector device tree is loaded at boot time : dtoverlay=audioinjector-wm8731-audio
  • Reboot to force the correct device tree to load.

Re: How to setup and test

Posted: Mon Aug 01, 2016 8:46 am
by epalaima
Hi, I set up my sound card using your manual instructions. Updated kernel and commented out dtparam=audio=on and added dtoverlay=audioinjector-wm8731-audio. After rebooting I ran aplay -l and the sound card showed up as the only audio device, hw:0,0, which was a promising sign.

I tried to play a wave file with aplay to test it but I got the following error:

aplay: pcm_write:1939: write error: Input/output error

I tried a lot of different flags for aplay (manually setting sample rate, channels, output device, etc) but all got the same result. No audio out. Is there something I am missing?

Re: How to setup and test

Posted: Mon Aug 01, 2016 10:40 am
by flatmax
Hi epalaima,

Thanks for pointing out this step I missed in the manual setup option ... Easy problem to solve I think.
It isn't mentioned anywhere nor is it clear, but the codec has a DAPM control which needs to be enabled to enable playback. The automatic installation method does this for you ...

If you setup using the manual method, you also need to enable "Output Mixer HiFi" in the playback alsamixer setttings, see this post :
viewtopic.php?f=5&t=5

Matt

Re: How to setup and test

Posted: Tue Aug 02, 2016 12:09 am
by epalaima
Setup1

Re: How to setup and test

Posted: Tue Aug 02, 2016 12:10 am
by epalaima
Setup2

Re: How to setup and test

Posted: Wed Sep 21, 2016 1:37 am
by swlightn
Hi,

I just installed .deb file and run shell script, and reboot.
But, it seems not working as intended.

Kernel is updated, but no soundcards found after adding these two lines.
#dtparam=audio=on
dtoverlay=audioinjector-wm8731-audio

pi@jungraspberrypi:~ $ uname -a
Linux jungraspberrypi 4.4.21-v7+ #911 SMP Thu Sep 15 14:22:38 BST 2016 armv7l GNU/Linux
pi@jungraspberrypi:~ $ aplay -l
aplay: device_list:268: no soundcards found...

Please help me to set up this.

Re: How to setup and test

Posted: Wed Sep 21, 2016 12:10 pm
by swlightn
It seems wm8731-hifi is not loading properly.

[ 5.710350] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
[ 5.710381] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)
[ 5.746090] EXT4-fs (mmcblk0p7): re-mounted. Opts: (null)
[ 5.847273] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
[ 5.847304] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)
[ 5.855053] wm8731 1-001a: Assuming static MCLK
[ 5.855425] wm8731 1-001a: Failed to issue reset: -5
[ 5.855535] wm8731: probe of 1-001a failed with error -5
[ 5.857826] usbcore: registered new interface driver brcmfmac
[ 5.858302] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
[ 5.858312] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)

Re: How to setup and test

Posted: Wed Sep 21, 2016 10:44 pm
by flatmax
Hi there,

On a successful boot sequence you should see something like this (the initial -517 failures are due to a late probing codec driver) :

Code: Select all

[    5.290621] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)
[    5.293519] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
[    5.293551] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)
[    5.442223] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    5.523013] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
[    5.523038] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)
[    5.529486] usbcore: registered new interface driver brcmfmac
[    5.529503] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
[    5.529513] audioinjector-audio soc:sound: snd_soc_register_card failed (-517)
[    5.540252] wm8731 1-001a: Assuming static MCLK
[    5.547395] audioinjector-audio soc:sound: wm8731-hifi <-> 3f203000.i2s mapping ok
I just bumped my kernel version to match yours (4.4.21) and I still have success.

It seems that on your system the Pi can't talk with the sound card over i2c. There are most likely two possible reasons for this and a couple of other less likely reasons :
  • The card is broken and needs replacing.
  • The Pi's i2c or other GPIO lines are broken and the Pi needs replacing.
  • There is another add on card plugged in to the GPIO at the same time which is doing something to block comms or power ?
  • Another possibility is something else funky going on with your software ... however lets assume that isn't the problem for now.
Is it possible to test on a known working Pi ?

Matt
p.s. We test and quality control all products before they are shipped - however a very small percentage of broken items do slip through QA.

Re: How to setup and test

Posted: Tue Oct 18, 2016 7:18 am
by fnbassman
Same issue here. Thanks in advance for you help, Fred
Below please find result of aplay and a grep of kern.log

fred@rpi:aplay -l
aplay: device_list:268: no soundcards found...

fred@rpi:sudo grep wm8731 kern.log
Oct 17 13:00:08 rpi kernel: [ 6.196325] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
Oct 17 13:00:08 rpi kernel: [ 6.342640] wm8731 1-001a: Assuming static MCLK
Oct 17 13:00:08 rpi kernel: [ 6.370435] audioinjector-audio soc:sound: wm8731-hifi <-> 3f203000.i2s mapping ok
Oct 17 13:36:54 rpi kernel: [ 6.166911] audioinjector-audio soc:sound: ASoC: CODEC DAI wm8731-hifi not registered
Oct 17 13:36:54 rpi kernel: [ 6.263619] wm8731 1-001a: Assuming static MCLK
Oct 17 13:36:54 rpi kernel: [ 6.270143] audioinjector-audio soc:sound: wm8731-hifi <-> 3f203000.i2s mapping ok

Re: How to setup and test

Posted: Tue Oct 18, 2016 8:09 pm
by flatmax
Hi there,

I think your card is registering at boot, but something else is happening which is unloading it for some reason ?
This line : "audioinjector-audio soc:sound: wm8731-hifi <-> 3f203000.i2s mapping ok" indicates that it is setup up and ready to go.

When you start your system, can you run and capture the output of dmesg ?
dmesg > /tmp/dmesg.txt
If you don't see anything of note, please post here.

thanks
Matt