LibreELEC 7.0 builds with Wolfson/Cirrus Logic Audio Card drivers

  • These are unofficial / community builds for the Raspberry Pi with support for the Wolfson Audio Card and Cirrus Logic Audio Card from element14.

    Lastest builds and detailled installation/configuration instructions are available on my website.

    Here are direct links to builds based on the LE 7.0.1 release:
    7.0.1 build for original RPi
    7.0.1 build for RPi2/3

    The source code of these builds is available in my LibreELEC github repository.

    Quick first-time installation instructions:

    • First install an official LibreELEC RPi build
    • Download the Wolfson/Cirrus build and do a manual update (copy the tar file to the Update share or to /storage/.update/ on the command line and reboot)
    • After reboot add the following line to /flash/config.txt
      Code
      dtoverlay=rpi-cirrus-wm5102
    • Reboot again to activate the config change
    • Go to Kodi system settings and change the audio output device to ALSA (snd_rpi_wsp S/PDIF)


    Upgrading from OpenELEC 6.x:

    A manual update with the tar file should work just fine but can't be 100% guaranteed - better make a backup of your SD card in case something goes wrong.

    If the sound card no longer works check if you have the correct dtoverlay line in config.txt. In OpenELEC builds using "dtoverlay=rpi-cirrus-wm5102-overlay" (note the additional "-overlay" at the end) worked, too, but that's no longer the case with the current kernel versions. In that case remove the "-overlay" at the end, reboot and you should be fine again.

    so long,

    Hias

  • Hi Hias,

    I've installed your LibreELEC build on my RPi3 & CLAC and it all went very smoothly - thanks.

    I went for a new install, rather than upgrade from OpenELEC, so I'd just be able to quickly swap SD cards if anything went wrong - it didn't.

    The following might be better placed in a different sub-forum:
    One thing I'm confused about is whether I should be able to use the setup to play back audio from remote devices using BT (eg. iPod). I know about the early issues as discussed in the "Possible I2S master/slave bug in RPi3" thread (Possible I2S master/slave bug in RPi3 · Issue #1321 · raspberrypi/linux · GitHub), but didn't really understand the outcome, except that audio started to work using your updated OpenELEC build. I can see that devices such as iPods are connected to the Pi, but can't get any audio out. Any ideas?

    Cheers,

    John

  • Hi John,

    first of all thanks for your feedback!


    The following might be better placed in a different sub-forum:
    One thing I'm confused about is whether I should be able to use the setup to play back audio from remote devices using BT (eg. iPod).

    If I understand you right you'll need the RPi to do 2 things:

    • Act as a bluetooth audio sink (receiver)
    • Mix the received bluetooth audio stream into the ALSA output


    I think the latter could be possible with some pulseaudio configuration, maybe the former as well.

    But as I have zero knowledge about both bluetooth and pulseaudio I think it'd be better to ask that question in the general forum. I'm sure there are some experts around who can answer if and how that can be done.

    so long,

    Hias

  • Hello HiassofT

    Thanks a lot for your work

    I have tried your instructions on a Raspberry 2 with a Wolfson card and I didn't succeed.

    I can activate the

  • Hi xavi!

    Please post the link to a full debug log after trying to play a file - see the wiki for instructions:
    HOW TO:Provide Logfile - LibreELEC

    The linux kernel log would also be interesting, please run the following command:

    Code
    dmesg | pastebinit

    BTW: Do you hear the GUI sounds (eg "clicks" and "squish"es) when navigating through the menus?

    so long,

    Hias

  • Hello HiassofT

    I`ve installed the build with your hints in my RPi2 and everything works fine. THX for that! But the audio-Ins: None of your standard "usecase" scripts for "Record-" take any effect. I can switch on and off the options for playback only.
    Maybe it is a case of misunderstanding, how and what to do with the audio-inputs, and the "listen scripts" by Ragnar Jensen are far away from a initial starting point for me. I am not shure about where and how to execute the scripts.
    My target is to have a 2nd. input source on the line-out like described at "Listen_to_SPDIF_on_LineOut.sh" from Ragnar Jensen with the abillity to tune a bit at the equalizer. Are there any options to get some examples (step-by-step) or to read about getting the scripts to work in LibreELEC or a basic education about the audio-in options?

    Cheers

  • Hi ReiniB!


    My target is to have a 2nd. input source on the line-out like described at "Listen_to_SPDIF_on_LineOut.sh" from Ragnar Jensen with the abillity to tune a bit at the equalizer. Are there any options to get some examples (step-by-step) or to read about getting the scripts to work in LibreELEC or a basic education about the audio-in options?


    The Record-... scripts are for setting up recording (eg when using arecord), these are of no much use with LibreELEC/Kodi. The listen scripts are what you need.

    There are 2 gotchas when using SPDIF:

    First the easy to solve one: You have to slightly modify the mixer settings and change "SPDIF in Switch" to "SPDIF In Switch" and "SPDIF out Switch" to "SPDIF Out Switch" (note the capital "I" and "O" in "In"/"Out").

    But the next one is tough: If you want to use SPDIF in you have to manually configure the card to the correct rate. If you only use 44.1kHz audio on SPDIF you could change the Kodi audio settings to only use 44.1kHz - when playing video or audio file Kodi the will resample everything to 44.1kHz. Likewise, if you want to use 48kHz audio on SPDIF set Kodi to 48kHz.

    If the configured rate doesn't match the rate of the SPDIF signal you'll end up in a mess: The audio chip tries to adjust the configured rate (eg 44.1kHz) to the one on SPDIF in (eg 48kHz) and usually fails miserably - that feature is intended to adjust for slight variations in clock speed (eg 44105 Hz instead of 44100).

    So mixing the SPDIF input signal into the output is very limited and might not work as expected if the SPDIF samplerate varies.

    Mixing the analog inputs (Line In, DMIC, Headphone in) into the output is a lot more practical:

    You don't have the samplerate restriction here, Kodi can choose whatever samplerate it likes and the soundchip just uses that one to digitize the analog signal and mix it with the output.

    I'd suggest you try the "Listen_to_LineIn_on_Lineout.sh" script, that should work out of the box and produce the expected result.

    If you start it with "eq" as a parameter it'll set up some equalizer settings as well.

    Just play around with the "EQ...Volume" settings in the script and adjust them to your likes. You can find more background info in the linked discussions on my website.

    so long,

    Hias


  • First the easy to solve one: You have to slightly modify the mixer settings and change "SPDIF in Switch" to "SPDIF In Switch" and "SPDIF out Switch" to "SPDIF Out Switch" (note the capital "I" and "O" in "In"/"Out").

    THX for quick reply

    Sounds EZ...
    sorry, I`m a complete newbee:
    1. Where lives the mixer setting to modify? In the Listen_to_SPDIF_on_LineOut.sh ?
    2. Where to store the listen files to let them execute from

    Code
    90-wolfson.rules


    ?

    Regards


  • sorry, I`m a complete newbee:
    1. Where lives the mixer setting to modify? In the Listen_to_SPDIF_on_LineOut.sh ?


    Yes, exactly.

    BTW: Just noticed that I had already uploaded fixed versions of the scripts to my website:
    listen-scripts.tgz

    Just use these and you don't have to change the stuff yourself

    Quote


    2. Where to store the listen files to let them execute from

    Code
    90-wolfson.rules

    For simplicity just copy the listen script directly into /storage/ - eg /storage/Listen_to_LineIn_on_Lineout.sh

    For testing run the script from a terminal, edit it, run it again... until you are happy with the result.

    Then, if you want to make it permanent (i.e. automatically activated at each boot) add it to the 90-wolfson.rules file. It should look somthing like this:

    Code
    # enable SPDIF plus all analog outputs
    SUBSYSTEM=="sound", ACTION=="add|change", ATTR{id}=="sndrpiwsp", \
    RUN+="/usr/bin/SPDIF_playback.sh -q", \
    RUN+="/usr/bin/Playback_to_Lineout.sh -q", \
    RUN+="/usr/bin/Playback_to_Headset.sh -q", \
    RUN+="/usr/bin/Playback_to_Speakers.sh -q", \
    RUN+="/storage/Listen_to_LineIn_on_Lineout.sh eq"

    so long,

    Hias


  • Just use these and you don't have to change the stuff yourself
    For simplicity just copy the listen script directly into /storage/ - eg /storage/Listen_to_LineIn_on_Lineout.sh

    For testing run the script from a terminal, edit it, run it again... until you are happy with the result.

    Then, if you want to make it permanent (i.e. automatically activated at each boot) add it to the 90-wolfson.rules file. It should look somthing like this:

    Code
    # enable SPDIF plus all analog outputs
    SUBSYSTEM=="sound", ACTION=="add|change", ATTR{id}=="sndrpiwsp", \
    RUN+="/usr/bin/SPDIF_playback.sh -q", \
    RUN+="/usr/bin/Playback_to_Lineout.sh -q", \
    RUN+="/usr/bin/Playback_to_Headset.sh -q", \
    RUN+="/usr/bin/Playback_to_Speakers.sh -q", \
    RUN+="/storage/Listen_to_LineIn_on_Lineout.sh eq"

    wow, thank you, first time to have an effect...

    ...but just in testing. It doesn't work permanentely as you described. Wrong path?

    Cheers

    P.S. Next issue: How to avoid the 2 plop noises during switch between the inputs without setting the volume to 0 / by setting the volume to 50 in Row 12 + 13 in Listen_to_LineIn_on_Lineout.sh ? (Plop noise is getting louder by increasing the value)

    Edited once, last by ReiniB (June 16, 2016 at 3:34 PM).

  • Hello again, here are both pastebins after trying to play an ogg

    JHbF
    LXDd

    GUI interface is hanged.

    Maybe I'm dumb here, I just connected a headset in the "HeadSet", and I don't changed the rules on "Audio card configuration"

    Code
    /storage/.config/udev.rules.d/90-wolfson.rules
    
    
    Thanks a lot!

  • wow, thank you, first time to have an effect...

    ...but just in testing. It doesn't work permanentely as you described. Wrong path?


    You probably have a typo or some error in the udev rules file, check for that in the system log:

    Code
    journalctl -a | grep udevd


    Quote


    P.S. Next issue: How to avoid the 2 plop noises during switch between the inputs without setting the volume to 0 / by setting the volume to 50 in Row 12 + 13 in Listen_to_LineIn_on_Lineout.sh ? (Plop noise is getting louder by increasing the value)


    You could try muting the output before changing the settings and unmuting it afterwards:

    Code
    amixer cset name='HPOUT2 Digital Switch' off
    ...
    amixer cset name='HPOUT2 Digital Switch' on

    so long,

    Hias
    [hr]


    Hello again, here are both pastebins after trying to play an ogg


    Thanks for the logs!

    The soundcard seems to be detected fine, but this line in dmesg is very suspicious:

    Code
    bcm2835-dma 3f007000.dma: DMA transfer could not be terminated

    I've seen that, too, if the card was unconfigured, eg if you have some error in the udev rule file (are you sure you didn't change that)? In that case I also get the "snd_pcm_writei returned -5" errors in kodi.log.

    Just remove the udev file and reboot (then it'll be recreated with default contents). It might need a second reboot for the change to take effect.

    Code
    rm /storage/.config/udev.rules.d/90-wolfson.rules
    reboot

    If it still doesn't work please upload the system log

    Code
    journalctl -a | paste

    so long,

    Hias

    Edited once, last by HiassofT (June 17, 2016 at 3:20 PM).


  • The scripts for using the inputs with the DSP aren't of help aswell for me and I'm getting tired to look for sources with suitable informations. Any suggestions (pics + samples ) for absolute beginners?
    Thanks for now, for you patience and your help,
    Cheers
    ReiniB

  • Code
    journalctl -a | grep udevd

    no effect with the code


    Crap, that's a bug in LE (it already rotated away the important log entries) - I've reported it here:
    LibreELEC

    But there's another method we can use and even get more info on what might be failing with the udev rule.

    First we tell udevd to output debug messages as well:

    Code
    udevadm control --log-priority=debug


    Then simulate a change event for the sound subsystem, this causes the 90-wolfson.rules file to be run again:

    Code
    udevadm trigger -s sound


    Now check the system log, do a "journalctl -a | grep udev". If you mistyped the script filename you should get an error message like this:

    Code
    LibreELEC systemd-udevd[1584]: failed to execute '/this/is/a/wrong/path' '/this/is/a/wrong/path': No such file or directory

    If you can't figure out what's going on just upload the whole journalctl output to a paste site and I'll have a look at it:

    Code
    journalctl -a | paste

    If you spotted the error and corrected the 90-wolfson.rules file you first have to tell udevd about the change, then you can trigger the change again. So, after editing run these 2 commands:

    Code
    udevadm control --reload
    udevadm trigger -s sound

    Then look at the journalctl output for any errors until you got it working.

    Quote


    agree, but executing script between switching is no option.


    I meant that you should try to add these lines at the very beginning/end of the listen script - before the first "amixer" line and after the "fi" at the very end.

    Quote


    The scripts for using the inputs with the DSP aren't of help aswell for me and I'm getting tired to look for sources with suitable informations. Any suggestions (pics + samples ) for absolute beginners?
    Thanks for now, for you patience and your help,


    What do you mean with DSP? The wm5102 has a DSP inside which could indeed be used for very interesting stuff. But unfortunately the tools to create the DSP code aren't publically available so we can't use that

    Or do you mean the integrated equalizer/mixing/... functionality? The mixer is documented fairly well in the datasheet and there's some further info about the equalizers available as well in the discussions on the element14 forum. But, yes, this is rather advanced stuff

    so long,

    Hias


  • But there's another method we can use and even get more info on what might be failing with the udev rule.
    First we tell udevd to output debug messages as well:

    Code
    udevadm control --log-priority=debug
    udevadm trigger -s sound


    Now check the system log, do a "journalctl -a | grep udev".

    Got it: A simple change in the properties of my scripts let them execute, as and where I want to.


    The "switching problem" is maybe my one in general understanding of how and when scripts can be used. I try to hang on. Minor at the moment, I'm happy to have my equalizer working...

    ...and again: Thanx Hias

    so long

    ReiniB

  • Hi Hias,

    Just to report that I've installed your 7.0.2 build and all is good.

    John

    PS. Have given up on the Bluetooth playback idea for the moment - Too much hassle. Thanks for your thoughts on this a few weeks ago.

    Edited once, last by JohnnyL (June 29, 2016 at 11:30 AM).

  • Thank you so much for this build! I had been looking arround forums for different OS solutions compatible with the Cirrus DAC. Tried RuneAudio which say to be compatible with it but in fact wasn't. I have finally been able to enjoy playing music via the card and have been surprised by the quality of it!