-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WM8960 failed to configure clock #5849
Comments
Start by reducing your config.txt to that which is necessary:
You may save time by installing a stock RPiOS image onto a spare SD card, using the same config.txt, and running something like |
Add some diagnostic output. See: raspberrypi#5849 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Thanks for your answer, I will try to update my config.txt. One thing I did not mention is that speaker-test give me a clear "Front-left, Front-right". The error occurs only when launching alsamixer or when trying to acces the audio output through my Qt application. Then from my Qt application I am not able to ear anything. (It does work when I am only using the onboard audio so th problem does not come from herr) |
I've created a PR with some extra debug output that may help to understand what is going wrong: #5850 Wait for about 45 minutes - until the build checks have completed (it doesn't matter that the "Advisory checkpatch review" test has failed - then you will be able to install a trial kernel using |
Thanks, I will try it later with RPiOS lite and see what it give me. Also, is rpi-update working with open-embedded/yocto? So I can also test with it |
Add some diagnostic output. See: raspberrypi#5849 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
It should be fine with Yocto - you can always override the paths to the boot and root directories if necessary. |
So, my first tries led me to this, With RPiOS lite, everything seems fine aplay shows one card (wm8960-soundcard) and after settings the volume with alsamixer, speaker-test gives me "Front-left Front-right" and dmesg doesn't show any error (so no need for rpi-update there I guess) With my yocto build however I still cannot make it work (even after correcting config.txt) Maybe some kernell module is missing. so I will try the rpi-update to see what's wrong but I will first need to add config.txt looks like this
|
So after giving-up trying to make rpi-update work with my distro, I directly added your patch to my yocto build and here are the results: directly after boot
then after trying alsamixer:
Repeated multiple time Also, here is the result of lsmod:
P.S just so you know I am building following this: agherzan/meta-raspberrypi#861 |
See: raspberrypi#5849 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
It looks like ALSA is requesting a combination of channels + sample size + sample rate that the driver thinks it can't support. Please add one more debug line (pelwell@e2ec5a3), then we should have all the information required to work out if the request is reasonable, and hopefully how to proceed. |
So here is the result with the new patch
I've gotta say I don't quite understand what's appening. Could it be that since snd_soc_wm8960 is built into the kernel and not loaded as a module it is missing some dependencies? (I have already tried to build it as a module but with the same outcome) |
I now understand the error messages, but not why it isn't affecting everyone. The complaint is that there is no integer (*) divisor from the sysclk/mclk of 12288000 to the bclk of 1411200 (which is 44100 * 16 * 2). I'm guessing that speaker-test uses a different frequency - 32kHz, perhaps. (*) It's actually even more restrictive than that - there's a list of legal divisors - but you get the idea. |
Well it works with RPiOS apparently so I guess that's why noone noticed it. I have to say still that even speaker-test does not work now. At first, I was including asound.conf and wm8960_asound.state from waveshare repo and with that speaker-test worked but I had the error when running alsamixer or when running my Qt app. But since I rebuilt my distro to add the debug patches, I did not bother to add asound.conf and asound.state. So perhaps I can try to add them and see what is going on between those differents states:
|
So, there are the results of the differents tests I ran Simple yocto build: (/etc/asound.conf and /var/lib/alsa/asound.state are empty)
After speaker-test -t wav -c 2 -l 1
After alsamixer (It shows only the master channel and I have to press F6 to select the wm8960-soundcard)
Yocto build with asound.conf+wm8960_asound.state:
After speaker-test -t wav -c 2 -l 1 (no error but no sound)
After alsamixer (It shows only the master channel and I have to press F6 to select the wm8960-soundcard) (since I was there I cranked the volume up)
Rerun speaker-test -t wav -c 2 -l 1 (now I have sound)
Barebone RPiOS lite + rpi-update pulls/5850:
After speaker-test -t wav -c 2 -l 1 (Front-left, Front-right loud and clear)
After alsamixer (It directly select the wm8960-soundcard with all its channel)
I also have some difference in /proc/asound/devices Yocto
RPiOS lite
I really don't know if all of this is usefull but I hope it could help. |
It is very useful. Firstly, it confirms that sample rate is the fundamental problem, with 48000 working and 44100 not. Secondly, it prompted me to wonder why that might be, and my current thinking is that the audio mixing service - pulse audio or pipewire - is probably sample-rate converting everything to 48kHz. Your Yocto image is probably vanilla ALSA. One of the configuration files you linked to referred to resampling using the samplerate module (not speex), so you could look enabling that in your build. |
Also here is the result with my Qt app
|
So what module exactly should I add? |
The problem you are having is with a standard Linux driver, with third party hardware, and a third party operating system build. I've pointed you in the right direction - get ALSA to do sample rate conversion, or consider adding pulse audio - and that's where my contribution is going to end, unless somebody comes up with a driver patch which magically fixes the problem. |
You can enable others here, but it ships with only 48000Hz enabled (mostly as pipewire has a bug of not setting the AES bits which means no hdmi audio at frequencies other than 48000Hz - see #5525) |
For vanilla ALSA you probably need something like this (untested):
or perhaps just this:
Note that you may need to change the "hw:" numbers to match your setup. |
I did some more testing with RPiOS since it was working I wanted to find what was different between RPiOS and my yocto build. And it came out that on RPiOS pulseaudio wasn't installed and it is on my yocto build (it is installed by QtMultimedia) So I installed pulseaudio on RPiOS
So maybe pulseaudio is breaking things? Or the problem lies elsewhere |
And so here it is the solution! Since pulseaudio is installed it was just a matter of configuring it correctly by simply adding I wont close the issue just yet as I will still do some testing |
So the exact solution used to solve this problem on my distro can be found here https://github.com/Embi-OS/meta-embi For those wondering I had to override pulseaudio recipes to edit |
Thanks for this thread @Romain-Donze . I was able to solve my problem by: Brute force trying to solve with various approaches
amixer -c1 sset 'Headphone',0 80%,80%
amixer -c1 sset 'Speaker',0 80%,80%
amixer -c1 sset 'Left Input Mixer Boost' toggle
amixer -c1 sset 'Left Output Mixer PCM' toggle
amixer -c1 sset 'Right Input Mixer Boost' toggle
amixer -c1 sset 'Right Output Mixer PCM' toggle
One cause of errorsSomething to consider is that simply running
However, running TestI plugged in stereo headphones into my audio hat headphone jack and it works crystal clear: My setup in case it helps someoneDevice: Adafruit Voice Bonnet (which uses a WM8960) https://learn.adafruit.com/adafruit-voice-bonnet I am customizing a yocto image for Qt as well. Qt version 6.6.2. Note: I am a noob to yocto as well, just brute forcing. Here is my config for meta-raspberrypi:
My local.conf so that I can test with aplay and arecord and also edit files with vim:
|
One question for @pelwell, how can I change the asound.conf to make arecord work?
|
Fiddled a little more and got this for my asound.conf
Also had to brute force run these to get the audio to be audible otherwise it was recording with too low volume: amixer sget 'Capture'
amixer sset 'Capture' 80%
amixer sget 'Left Input Boost Mixer LINPUT1'
amixer sget 'Right Input Boost Mixer RINPUT1'
amixer sset 'Left Input Boost Mixer LINPUT1' 80%
amixer sset 'Right Input Boost Mixer RINPUT1' 80%
`` |
Describe the bug
So I tried to add support for the WM8960 waveshare hat to my yocto image.
My build is based on Boot2Qt (see here: https://doc.qt.io/Boot2Qt/b2qt-how-to-create-b2qt-image.html)
The wm8960-soundcard does appear in alsamixer but when launching alsamixer, dmesg return a lot of error
Steps to reproduce the behaviour
config.txt
Device (s)
Raspberry Pi 4 Mod. B
System
Linux b2qt-raspberrypi4-64 6.1.54-v8 #1 SMP PREEMPT Wed Sep 20 14:13:53 UTC 2023 aarch64 GNU/Linux
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: