Cirrus Logic Audio Card and Wolfson support in PCP 3.20

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • M-H
    Senior Member
    • Oct 2016
    • 218

    Cirrus Logic Audio Card and Wolfson support in PCP 3.20

    Starting from the new kernel ( 4.9.x ) in Picoreplayer 3.20 Beta the great work of Hias has started become available to people who like the simplicity and stability of running PCP as basis to squeezelite.
    The mentioned Pi audio card is one of the most advanced cards with great specs, that do go beyond what PCP will use.

    As I had 2 CLAC's gathering dust , and spare pi's to match, I started some test to revive the old hardware.

    Just recently I got the cards to become visible through :
    ~$ aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
    Subdevices: 7/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: RPiCirrus [RPi-Cirrus], device 0: WM5102 AiFi wm5102-aif1-0 []
    Subdevices: 1/1
    Subdevice #0: subdevice #0

    However the boot proces is not automatic and needs manual intervention.

    Currently the driver does only register if I change something on the USB bus roughly AFTER the boot message
    udevadm settle - timeout of 5 seconds reached, ....
    is displayed.
    The correct initialisation of the card can be seen from the RED led on the CLAC
    During the initial parts of the boot it turnd off , but at the end of the end of the 'loading extensions ' part it comes back on.
    If I plug in something 'new' on the usb bus the red led turns off again, and the output of aplay -l does alter, adding the RPiCirrus device.
    Currently I can reproduce the start of the driver/device by simply re-plugging my mouse from 1 to the other port on my KBD built-in USB hub, even if this is 2 minutes after boot time.
    It allows me to remotely log in over the WIFI , check through aplay -l , to verify the device is not jet seen.

    Obviously some modules prevent the driver / device to install properly and I jet do not know the cause and the solution.
    Who can help to crack the final parts , that allows me to document how this card can be used in PCP ?

    For anyone that want to replicate, you obviously need the hardware, and I am sorry to tell HW productions seems to have stalled, and proper driver support might have arrived too late to support sales and more production.
    The basic start is a clean PCP 320, although it was tested to work OK on Beta 7, and probably Beta 5 could work to.
    In the 320 Beta thread, most info is found but a short version :


    /etc/modprobe.d/cirrus.conf => /etc/modprobe.conf
    sqeezelite is started with '-n piCorePlayer-test -o hw:CARD=RPiCirrus -a 80 4 1'
    Backup! your changes with 'pcp bu' before any reboot !
    Save all your settings outside the PCP partitions if you do an isitu upgrade ( warnings are in the procedure )
    And as squeezelite does not have the card driver available at first start, be prepared to check and restart it .
    If al starts and there is no sound, verify the use the usescripts provided by Hias, and the volume.

    Regards M-H
    Edit: added dmesg file
    Attached Files
    Last edited by M-H; 2017-04-26, 00:49. Reason: Added dmesg output for debugging
    Pi based multi-room audio system powered by PiCorePlayer(s):
    Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...
  • paul-
    Senior Member
    • Jan 2013
    • 5777

    #2
    Yes, from what I've read the DAC has went out of production, so no more boards, unless someone has a stockpile of chips. That goes to show what happens if you don't have a functioning driver when you try to sell hardware. Seems to be a lesson that a lot never learn.


    If you can, hook up a monitor/keyboard, and just debug from the console.

    After pCP is fully started. Try running

    sudo udevadm trigger

    See if anything happens.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

    Comment

    • M-H
      Senior Member
      • Oct 2016
      • 218

      #3
      busybox does lack softdep ?

      Originally posted by paul-
      ...
      If you can, hook up a monitor/keyboard, and just debug from the console.

      After pCP is fully started. Try running

      sudo udevadm trigger

      See if anything happens.
      I did work from the console, but due to lack of knowledge , have not found a way to load all the modules in the correct order from the boot process only.

      The list is
      arizona/wm5102 depends on
      arizona_ldo1 depends on
      arizona

      Hias hinted to me the modprobe from busybox does lack softdep
      And his set relies on softdep, to work its way around the kernel module sequence problems.
      This is just the info he gave me, and I jet have to understand the way these techniques work to comment on that.

      Still It does wonder me that a USB insert does finish the module load procedure, and does allow me to use the driver from that moment.
      So if I was able to emulate that event, and if really needed load the squeezelite instance with a delay or from a test loop, the setup could work without human intervention to set to a working state.

      I will start to see how busybox modprobe does work , and find ways to perhaps make it more persistent to load the modules .

      Regards M-H
      Pi based multi-room audio system powered by PiCorePlayer(s):
      Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

      Comment

      • paul-
        Senior Member
        • Jan 2013
        • 5777

        #4
        Sorry missed this response. The lack of Softdep support sounds like the main problem, I've never heard of softdep before now. The only way around it would be to include the full version of modprobe in the initrd......

        Here is a reference link to rebuild your initrd



        You can also create a new initrd file system with just the new modprobe in it, then concatenate it to the end of the current initrd.
        piCorePlayer a small player for the Raspberry Pi in RAM.
        Homepage: https://www.picoreplayer.org

        Please donate if you like the piCorePlayer

        Comment

        • M-H
          Senior Member
          • Oct 2016
          • 218

          #5
          Loading all cirrus modules in PCP

          Originally posted by paul-
          The lack of Softdep support sounds like the main problem, I've never heard of softdep before now. The only way around it would be to include the full version of modprobe in the initrd......

          Here is a reference link to rebuild your initrd



          You can also create a new initrd file system with just the new modprobe in it, then concatenate it to the end of the current initrd.
          Thanks Paul.
          I've been reading on the modprob discussion, but attacking this issue with a custom built auto boot part is is bit out of my reach at this moment.

          However with lsmod I have identified 4 modules that are not loaded automatically and loaded them manually :
          Code:
          sudo modprobe arizona_micsupp
          sudo modprobe gpio_arizona
          sudo modprobe snd_soc_wm5102
          sudo modprobe snd_soc_arizona
          This does result in a similar lsmod output as when a usb device is plugged in, but the device is not recognised with f.i. aplay -l .
          But a usb add event will still finish the job, so it has not disturbed the process.
          Experimenting with udevadm trigger has not led to anything new.

          So to anyone: Can you give me hints on what I could do to either initialise the modules correctly after plain loading them .
          Or to emulate a USB-add-event that hopefully does the same as the manual action.
          Pi based multi-room audio system powered by PiCorePlayer(s):
          Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

          Comment

          • paul-
            Senior Member
            • Jan 2013
            • 5777

            #6
            You can ask the guy who built the driver if you can not use the dtoverlay, and then load all of the modules manually in the proper order.
            piCorePlayer a small player for the Raspberry Pi in RAM.
            Homepage: https://www.picoreplayer.org

            Please donate if you like the piCorePlayer

            Comment

            • M-H
              Senior Member
              • Oct 2016
              • 218

              #7
              First full auto startup of PCP3.20 with Cirrus Logic Audio Card

              Originally posted by paul-
              You can ask the guy who built the driver if you can not use the dtoverlay, and then load all of the modules manually in the proper order.
              Indeed, that did the trick.
              I've now got a setup that does boot and fix the drivers and set the specific routes within the audio card to come to a functional situation without any human intervention.
              I even got the alsa equalizer to work with card 1 ;-)
              But we are not there.
              ATM I have to reload the module arizona_spi after boot.
              and this takes a lot of time, and I even have to insert delays to get the script to function reliable, and restart squeezelite because it failed to see the card at initialisation.

              So I created the next script bump.sh and call it from the User commands in the web GUI ( TWEAKS tab )

              Code:
              sudo modprobe -r arizona_spi
              sleep 1
              sudo modprobe arizona_spi
              sleep 3
              /usr/local/etc/init.d/squeezelite restart
              sleep 1
              cd /home/tc/usescripts
              ./Playback_to_Speakers.sh
              How can we cleanup all this and put it in some form that is more usable ?
              Ultimately I would like it to be incorporated in PCP as a standard sound card that can just be chosen to be used by less experienced users.

              First I should see how to prevent the module arizona_spi to load at all during boot, and avoid to have it removed.
              Then the sleeps should get replaced with a proper decision wetter the initialisation has completed successfully.
              And the outputs should all be enabled , or some user selection should be allowed through predefined 'versions' of the driver/card.

              Lastly the integration with the alsa equalizer should be fixed.
              Perhaps it is due to te fact I have the card set as 1 with the analoge output as 0.

              Enough for now;
              People with interest to get a Cirrus Logic Audio Card Or Wolfson card working in PiCorePlayer try to trace my steps so far, wait for a write-up I will make later, or ask for hints.
              ( my set = pi B+ , CLAC, powered via barrel connector , speakers-out to reasonable big HIFI speakers, wifi dongle )

              Regards M-H
              Pi based multi-room audio system powered by PiCorePlayer(s):
              Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

              Comment

              • Girth
                Member
                • Mar 2014
                • 40

                #8
                Great! So what did you select for the soundcard in PCP web interface? I think that's required to load the i2s modules in the first place isn't it?

                Comment

                • M-H
                  Senior Member
                  • Oct 2016
                  • 218

                  #9
                  CLAC Selection fields

                  Originally posted by Girth
                  Great! So what did you select for the soundcard in PCP web interface? I think that's required to load the i2s modules in the first place isn't it?
                  Hi Girth ,
                  The sound card selected in the web interface is : Analog audio for the audio output field , and "equal" for the Squeezelite output field.
                  Combined with an edit of the \etc\asound.conf where

                  Code:
                  pcm.plugequal {
                          type equal;
                          slave.pcm "plughw:[B]1[/B],0";
                          controls "/home/tc/.alsaequal.bin"
                          library "/usr/local/lib/ladspa/caps.so"
                  was changed to use card 1 ( bold part ) .

                  If you do not care about the equalizer , it is simpler.
                  Forget about the \etc\asound.conf and set the squeezelite output to "hw:CARD=RPiCirrus".


                  Be sure to follow Hias his setup first to load the correct drivers and then tweak the arizona_spi to complete the initialisation of the modules till you get a 2nd soundcard ( #1) in your aplay -l output.
                  It is definitely not without tweaks at this moment.

                  Good luck. ! M-H

                  Edit: squeezelite output to "hw:CARD=RPiCirrus".
                  Last edited by M-H; 2017-05-20, 21:24.
                  Pi based multi-room audio system powered by PiCorePlayer(s):
                  Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

                  Comment

                  • petar
                    Junior Member
                    • Oct 2011
                    • 21

                    #10
                    Great work!!!

                    Great stuff M-H. Would be good if this could somehow become part of PiCorePlayer, to allow for really simple configuration.

                    Thanks!!!

                    Comment

                    • M-H
                      Senior Member
                      • Oct 2016
                      • 218

                      #11
                      With the update from PCP 3.20 to 3.22 I had to overcome a few problems.
                      Some obvious and some new.
                      The new problems are actually new functionality in PCP that is not jet setup to be used for the Cirrus Logic Audio Card or short CLAC
                      Getting this sorted and documented will help others to use and enhance it .

                      The current status has roughly 3 problem areas that need to be solved.

                      1) The driver does not load properly in the boot process . This has not changed in 3.22.
                      As this has a workaround through:
                      Code:
                      sudo modprobe -r arizona_spi
                      sleep 1
                      sudo modprobe arizona_spi
                      sleep 3
                      /usr/local/etc/init.d/squeezelite restart
                      sleep 1
                      I do not prioritise this, besides, it is outside my skill set now.
                      So help wanted on this issue....

                      2) The new functionality to setup dacs from the gui introduced in 3.21 interfered with manual setup I did.
                      Adopting the new configuration method and simplify the setup for users that do not want to know about already solved issues is best.
                      Currently the config file in Beta-state contains :
                      Code:
                      [COMMON]
                      ALSA_PARAMS="80:4::1"
                      GENERIC_CARD="RPiCirrus"
                      CONTROL_PAGE="soundcard_control.cgi"
                      LISTNAME="Cirrus Logic AudioCard"
                      RPI_MODEL="HAT_ALL_NO_HAT"
                      
                      [PCPAUDIOCORE]
                      DTOVERLAY="rpi-cirrus-wm5102"
                      CARD="RPiCirrus"
                      OUTPUT="hw:CARD=RPiCirrus"
                      
                      [PCPCORE]
                      DTOVERLAY="rpi-cirrus-wm5102"
                      CARD="RPiCirrus"
                      OUTPUT="hw:CARD=RPiCirrus"
                      and seems to work.
                      At least for me, tested on a Bplus with a fresh PcP 3.22 regular flashed to a sd card.
                      It does activate the correct addition of
                      Code:
                      dtoverlay=rpi-cirrus-wm5102
                      at the end of config.txt in the boot partition ( or at /mnt/mmcblk0p1 )
                      and it points squeezelight to the correct card for playback with output at hw:CARD=RPiCirrus

                      it is not automatic as the driver load described at 1) might not have completed and hence squeezelight can't be initialized.
                      And it is not possible to combine it with the alsa equal.
                      I found that altering the part in /etc/asound.conf from slave.pcm "plughw:,0"; to slave.pcm "plughw:1,0"; does the job. ( added a 1 if you missed it )
                      However this is not persistent due to some routines in the startup.
                      It either does not recognise the card at the correct number due to 1) or the card config file is not complete jet.
                      Help wanted here to......

                      3) The CLAC has multiple output paths that need to be setup for output to be observed.
                      These are setup through use-scripts provided by Hias who rewrote the driver too.
                      so with each CLAC setup, extra files on the PCP filesystem need to be installed.
                      I assume an extension would be the logical method to offer these extra files.
                      Although they are small, PCP is tiny and should not distribute something that is only needed for the happy few owning a CLAC.
                      Besides the CLI scripts, the soundcard_control.cgi gives us options to give GUI comfort to configure the output paths, possibly with sliders to adjust signal levels .
                      But to keep it realistic, the GUI is best for a second issue of the solution.
                      To get the extension going help is needed too....


                      Looking at the post, it seems like a mini project, where I welcome volunteers to chip in and where I have to learn a bit more on the inner workings of PCP.
                      So who can help and advise ?
                      Greetz M-H
                      Pi based multi-room audio system powered by PiCorePlayer(s):
                      Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

                      Comment

                      • paul-
                        Senior Member
                        • Jan 2013
                        • 5777

                        #12
                        Creating an extension is easy.

                        http://wiki.tinycorelinux.net/wiki:c...g_extensions?s[]=submit&s[]=extension

                        As I mentioned in the past, there is not much I can do to help without access to the actual hardware. I will take a look at fixing the code to not update the card number in asound.conf, if the device is not found......which is what is happening in your case.
                        piCorePlayer a small player for the Raspberry Pi in RAM.
                        Homepage: https://www.picoreplayer.org

                        Please donate if you like the piCorePlayer

                        Comment

                        • M-H
                          Senior Member
                          • Oct 2016
                          • 218

                          #13
                          I found a part of the problem.
                          As my sound card driver does not load properly at boot time, I have to use modprobe to unload and reload the driver.
                          Unfortunately , By then the regular startup must have configured /etc/asound.conf
                          So without disabling the on-board RPI audio card 0 is the only one, and configured properly with alsa
                          When disabled there is even no soundcard /proc/asound/cards and it shows as a quirk in /etc/asound.conf
                          Editing the file and restarting squeezelight does what is expected and even allows me to use alsaequal.

                          So what proces or script does initialise the alsa parts? And can I make changes that are retained over reboots ?
                          I rather not just rewrite /etc/asound.conf but delay parts till my driver is installed with a manual tweak.

                          The real solution would be to get the driver started correctly. Till then I have to work on the workarounds.

                          Greetz M-H
                          Pi based multi-room audio system powered by PiCorePlayer(s):
                          Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

                          Comment

                          • paul-
                            Senior Member
                            • Jan 2013
                            • 5777

                            #14
                            Without access to the hardware, it will be nearly impossible to work out support. I’ve addressed the asound.conf-alsaequal issue for the next release.

                            Have you tried loading your modules before pCP starts?
                            piCorePlayer a small player for the Raspberry Pi in RAM.
                            Homepage: https://www.picoreplayer.org

                            Please donate if you like the piCorePlayer

                            Comment

                            • M-H
                              Senior Member
                              • Oct 2016
                              • 218

                              #15
                              Originally posted by paul-
                              Without access to the hardware, it will be nearly impossible to work out support. I’ve addressed the asound.conf-alsaequal issue for the next release.

                              Have you tried loading your modules before pCP starts?
                              Hi Paul,
                              Indeed I can not expect you to solve my problem, and if you can not experience the issue first hand, debugging is quite difficult.
                              However the open source community is bigger than the 2 of us , and thus might give us a helping hand.
                              But let me give it a start.

                              Loading the modules after boot time through : modprobe -r and modprobe is quite successful, and in pcp 3.20 regular has always worked for me.
                              Through a script started from the user commands in the tweak page it worked 'OKE' but indeed squeezelight had to be restarted too, as it was already started and without finding the soundcard(drivers).

                              If you can tell me how picore starts its system scripts , and where pcp does tap in , I can do the tests with insertions.
                              I tried /etc/init.d/tc-config, but I do not think it is where pcp is started, and I need to make it reboot proof.
                              If I can secure the module load before the aconf is generated and squeezelite is started, we can test PCP as If the driver would have started normally.
                              Most of the issues seem to be caused by missing stuff at start up.

                              BTW starting the stuff manually does give me a working setup, both with and without Alsa equal, and with and without disabled Rpi analogue sound.

                              greetz M-H
                              Pi based multi-room audio system powered by PiCorePlayer(s):
                              Pi3B with Phat-dac in a Rasptouch, 2 pi B+ with Cirrus Logic Audio Card, Pi Zero with Phat-beat , and a few other tests...

                              Comment

                              Working...