PDA

View Full Version : Cirrus Logic Audio Card and Wolfson support in PCP 3.20



M-H
2017-04-25, 16:29
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 :
http://www.horus.com/~hias/cirrus-driver.html

/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

paul-
2017-04-26, 19:44
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.

M-H
2017-05-01, 01:36
...
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

paul-
2017-05-04, 10:01
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

http://forum.tinycorelinux.net/index.php/topic,14634.msg88856.html#msg88856

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.

M-H
2017-05-07, 05:01
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

http://forum.tinycorelinux.net/index.php/topic,14634.msg88856.html#msg88856

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 :


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.

paul-
2017-05-07, 05:13
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.

M-H
2017-05-19, 16:48
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 )


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

Girth
2017-05-19, 21:42
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?

M-H
2017-05-20, 02:39
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



pcm.plugequal {
type equal;
slave.pcm "plughw:1,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".

petar
2017-05-23, 02:28
Great stuff M-H. Would be good if this could somehow become part of PiCorePlayer, to allow for really simple configuration.

Thanks!!!

M-H
2017-10-25, 15:12
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:

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 :

[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

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

paul-
2017-10-26, 08:32
Creating an extension is easy.

http://wiki.tinycorelinux.net/wiki:creating_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.

M-H
2017-10-28, 15:19
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

paul-
2017-10-29, 07:31
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?

M-H
2017-10-30, 14:02
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

paul-
2017-10-30, 14:37
/opt/bootlocal.sh

just do your stuff before the line

#pCPstart------

M-H
2017-10-30, 15:16
Based on my own search I presume /opt/bootsync.sh is the best place to add system stuff before PCP script is started from /opt/bootlocal.sh
However the modprobe even if called through /sbin/modprobe is not working.
Any hints ?

grtz M-H

paul-
2017-10-30, 17:57
Log the output of the command, or hook up a monitor to watch the current Naples. You will probably have to wait for the card to be detected by the kernel.

M-H
2017-10-31, 01:27
/opt/bootlocal.sh/

just do your stuff before the line

#pCPstart------

Sorry Paul, I posted my own reply without seeing yours first.
indeed the start of /opt/bootlocal.sh/ is a good one, however I think this file might get replaced with an insitu upgrade, while /opt/bootsync.sh is more for the system , like my driver reload issue .

As my attempts failed anyway, I will retry in /opt/bootlocal.sh/ in a few days.
And organise a KBD/Video or serial console to monitor output and progress during boot.

Greetz M-H

Greg Erskine
2017-10-31, 05:40
Hi M-H,

Have you found [Main Page] in [Beta] mode -> [Diagnostics] -> [Boot]?

I added this to remind me of the boot process order, it may be helpful for reference.

Also [Main Page] in [Beta] mode -> [Diagnostics] -> [Logs] gives you access to some log files including some boot logs.

regards
Greg

M-H
2017-10-31, 13:52
Thanks Greg,
The boot order will help, and it is an easy way to remember the location.
The logs do no help me much, at least not more than when I tried to find the cause of the driver load failures.
I fear the timing is the key , and I will see if I can halt and split the automatic startup to check in that part of the process.
Regards M-H

paul-
2017-10-31, 15:03
Yes its timing, as you have to work around the soft dependencies.

I just finished integrating kmod mod utilities, which will upgrade pCP's modprobe to include support for the softdeps.

M-H
2017-11-02, 15:36
Paul ,

Can I help testing this at this moment ?

Edit:
Manually starting the script from the cli does work.
I reverted to starting a bump.sh, that now does copy a asound.conf and reload the modules and restart squeezelite
So it does give me an automated start in PCP322, crude but effective

greetz M-H

djtale
2018-02-15, 02:41
Hello all.

I have this thread and I still have issue to enable my Wolfson card.
I just bought it from reichelt.de : "rasp wolf audio"

I have a Raspberry Pi B and have installed piCorePlayer 3.22 :
piCorePlayer | piCorePlayer v3.22 | linux 4.9.50-pcpAudioCore | piCore v8.01 | Squeezelite v1.8.7-999

I have applied those actions :
tce-load -wi nano.tcz

mount /mnt/mmcblk0p1/
sudo nano -w /mnt/mmcblk0p1/config.txt
--> add dtoverlay=rpi-cirrus-wm5102 - then save your changes

When I do that, the system doesn't boot.
So I have removed this line for the moment.

sudo nano /etc/modprobe.conf
Add a the following line
softdep arizona-spi pre: arizona-ldo1

Then :
dmesg | egrep 'irrus|rizona'
--> Nothing found.

aplay -l

tc@piCorePlayer:~$ 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


squeezelite -l

tc@piCorePlayer:~$ squeezelite -l
Output devices:
null - Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=ALSA - bcm2835 ALSA, bcm2835 ALSA - Default Audio Device


I also tried these :
sudo modprobe arizona_micsupp
sudo modprobe gpio_arizona
sudo modprobe snd_soc_wm5102
sudo modprobe snd_soc_arizona

--> modprobe: module gpio_arizona not found in modules.dep


Could you please help me to make this card working on my Raspberry ?

I would be very thankful.

paul-
2018-02-15, 08:11
This card is not working under 3.22 without alot of tricks. The next version has support for this card. There is not a timeline yet for the next release, there are some bugs we are still working through

Greg Erskine
2018-02-15, 13:17
add dtoverlay= rpi-cirrus-wm5102

Remove space after "="

mikebainbridge
2018-02-27, 15:13
Pi Model B and Wolfson Card - It would be wonderful to get it up and running automatically. I'll give the solutions in the thread a go this weekend in the meantime

M-H
2018-06-01, 12:38
Pi Model B and Wolfson Card - It would be wonderful to get it up and running automatically. I'll give the solutions in the thread a go this weekend in the meantime
Hi mikebainbridge, and all others

The work we did to get the Wolfson and Cirrus Logic Audio Card to work with PiCorePlayer was continued in the development of the new version.
Starting from PCP 3.5.0. the configuration of these cards is automated and all supported from the web gui menu's
If you start with a new fresh PCP 3.5.0 sd image you should have the card up and running in less then 30 minutes, and without pitfalls to my knowledge.
If you do an upgrade, the 'bump' script is something you need to get rid of manually.

With the selection of the card ( named Cirrus Logic Audio Card ) in the squeezelight settings page and a reboot you will be able to see a card control button.
This will take you to a page where you can enable and disable the output options for the card.
Please select the right one(s) for your situation and connect the ports to the output devices ( Speakers , Headset , Line Out , Spdif )
If the page does not display, you could be in BASIC mode, set it to NORMAL and above from the main page and retry.

During final tests we did not encounter any issues, and even the original wolfson card was tested with success.
Let us know what your results are, and if you do not strike success right away, report and et some help here.

Regards M-H

Man in a van
2018-06-01, 12:57
Working well

https://forums.slimdevices.com/showthread.php?108852-Announce-piCorePlayer-3-5-0&p=912271&viewfull=1#post912271

Also had it running with Raspbian Stretch-Lite and the OMXPlayer

Ronnie

M-H
2018-06-02, 00:23
Thanks Man in a van,

Indeed I had seen your remark before, but as there are only a happy few with this card, I did not see much other chatter about it.

Currently I am working to add quite some to its special extension header, Ir inpu, Ir output, Rotary controller and buttons.
I might add some info on that in the coming month.

Regards M-H