LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - ARM (https://www.linuxquestions.org/questions/slackware-arm-108/)
-   -   Sarpi / Raspberry (RPi 3) - sound issue under 5.4.18-v7-arm (https://www.linuxquestions.org/questions/slackware-arm-108/sarpi-raspberry-rpi-3-sound-issue-under-5-4-18-v7-arm-4175669409/)

eduardr 02-11-2020 09:17 PM

Sarpi / Raspberry (RPi 3) - sound issue under 5.4.18-v7-arm
 
omxplayer sound works.

RetroArch emulator sound no longer works (worked on 5.4.16 and everything earlier).

The problem may be somehow related to the module snd_bcm2835. In 5.4.16 and earlier, this module was always loaded automatically. With 5.4.18, module is not loaded at boot. I can modprobe it manually after boot, but there are errors appearing in dmesg when I do that, and even though it appears as loaded in lsmod, I get no sound in my RetroArch game emulator.

More details below, of differences I see in 5.4.16 vs 5.4.18. Don't have a clue yet of root cause.

Code:

[root@rpi2 ~]# uname -a
Linux rpi2.lan.qurious.net 5.4.16-v7-arm #2 SMP Fri Jan 31 13:12:13 GMT 2020 armv7l BCM2835 GNU/Linux

[root@rpi2 ~]# lsmod | grep snd
snd_bcm2835            24576  0
snd_pcm                94208  1 snd_bcm2835
snd_timer              32768  1 snd_pcm
snd                    69632  3 snd_timer,snd_bcm2835,snd_pcm

[root@rpi2 ~]# dmesg
...
...
[Tue Feb 11 19:07:27 2020] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[Tue Feb 11 19:07:27 2020] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[Tue Feb 11 19:07:27 2020] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[Tue Feb 11 19:07:27 2020] input: Microsoft X-Box 360 pad as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.3/1-1.1.3:1.0/input/input4
[Tue Feb 11 19:07:27 2020] bcm2835_audio soc:audio: card created with 8 channels
...
...

Code:

[root@rpi2 ~]# uname -a
Linux rpi2.lan.qurious.net 5.4.18-v7-arm #5 SMP Sat Feb 8 14:36:59 GMT 2020 armv7l BCM2835 GNU/Linux

[root@rpi2 ~]# lsmod | grep snd
[root@rpi2 ~]#

[root@rpi2 ~]# dmesg | grep snd_bcm
[root@rpi2 ~]#

[root@rpi2 ~]# modprobe snd_bcm2835

[root@rpi2 ~]# dmesg
...
...
[Tue Feb 11 18:52:42 2020] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[Tue Feb 11 18:52:42 2020] bcm2835_audio bcm2835_audio: Failed to get DT property 'brcm,pwm-channels'
[Tue Feb 11 18:52:42 2020] bcm2835_audio: probe of bcm2835_audio failed with error -22

[root@rpi2 ~]# lsmod | grep snd
snd_bcm2835            24576  0
snd_pcm                94208  1 snd_bcm2835
snd_timer              32768  1 snd_pcm
snd                    69632  3 snd_timer,snd_bcm2835,snd_pcm


Exaga 02-12-2020 02:14 AM

Quote:

Originally Posted by eduardr (Post 6088963)
omxplayer sound works.

RetroArch ...

Ohhhh eduardr... LOL! :D

RetroArch is 3rd party software and the bane of my Slackware ARM experience. I once had a guy bother me on and off for over a year about this software, telling me that SARPi was broken, etc. Only to find, after RetroArch was updated, things magically started to work again, little by little. :D

Allow me try and put it in simple terms. Here's the situation...
Your touchscreen, for example, started working because the drivers and firmware have now been included in kernel 5.4.x source and that's attributed to the RPi guys who maintain it. Likewise with omxplayer and pretty much everything else that now works which didn't before.

Why doesn't every thing just work as expected?
Because kernel 5.4.x isn't the current working kernel version that's being developed and shipped with Raspbian. It may become that, but time will surely tell. In this environment it's expected that some things will NOT work as expected, not the other way around. Work is somewhat slower than it will be on the current working kernel, but that will change if kernel 5.4.x becomes the working kernel. While under development the kernel 5.4.x version will gradually include updates, patches and fixes, to solve these niggles that you are experiencing. Be aware that it may take some time to be fully realised.

But for RetroArch problems I'm not going to spend time looking into it. I've been there before where I've put my sanity at risk by trying to fathom what's causing these issues and got nowhere fast. RetroArch will most probably work eventually. Or at least that's what has happened in the past. Just give it time. Allow everyone and every thing the time to catch up with kernel 5.4.x and things will start to fall into place. ;)

eduardr 02-12-2020 03:12 PM

@Exaga thanks, and I agree that 55 times out of 100 any post that starts with "I have a problem" and contains "*RetroArch*" can be safely ignored as being an esoteric issue not relevant to normal users.

In this case the problem is not RetroArch. What is broken is ALSA sound. The snd-bcm2835.ko is the RPi module used by ALSA to output sound to the RPi hardware. The simple ALSA test utility # speaker-test will output white noise test audio under Sarpi 5.4.16 but outputs no audio at all under Sarpi 5.4.18. Additionally, after running the speaker-test utility, you can also see that cat /proc/asound/modules shows the ALSA driver is loaded 0 snd_bcm2835 under Sarpi 5.4.16, but shows <blank> under 5.4.18.

I already looked at kernel source changes between 5.4.16 and 5.4.18 related to snd_bcm2835/bcm2835-audio and saw no changes. Didn't find any relevant changes in firmware or overlays either.

Probably the best approach as you recommend is to wait for the kernel or other rpi folks to fix the issue. No doubt if ALSA is broken it will be noticed and fixed in short order.

Exaga 02-13-2020 12:23 AM

Quote:

Originally Posted by eduardr (Post 6089257)
Additionally, after running the speaker-test utility, you can also see that cat /proc/asound/modules shows the ALSA driver is loaded 0 snd_bcm2835 under Sarpi 5.4.16, but shows <blank> under 5.4.18.

What happens if you (re)load that driver manually? 'modprobe snd_bcm2835'

The ALSA module working in 5.4.16 and not in 5.4.18 doesn't make sense. Unless I have monumentally messed something up! :D

eduardr 02-13-2020 09:28 AM

@Exaga thanks, I'm seeing the following on 5.4.16 vs 5.4.18, same as documented in my initial post. Same on both of my RPi's (model 3 B+). The only thing I change in going from 5.4.16 to 5.4.18 is upgrading the 4 packages:

kernel-modules-sarpi3-5.4.18-armv7-1_slackcurrent_08Feb20_sp1.txz

kernel_sarpi3-5.4.18-armv7-1_slackcurrent_08Feb20_sp1.txz

sarpi3-boot-firmware-armv7-1_slackcurrent_08Feb20_sp1.txz

sarpi3-hacks-3.0-armv7-1_slackcurrent_08Feb20_sp1.txz

and rebooting.

# rmmod snd_bcm2835; modprobe snd_bcm2835; dmesg

5.4.16:

Code:

[Thu Feb 13 07:21:09 2020] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[Thu Feb 13 07:21:09 2020] bcm2835_audio soc:audio: card created with 8 channels

5.4.18:

Code:

[Thu Feb 13 07:22:11 2020] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[Thu Feb 13 07:22:11 2020] bcm2835_audio bcm2835_audio: Failed to get DT property 'brcm,pwm-channels'
[Thu Feb 13 07:22:11 2020] bcm2835_audio: probe of bcm2835_audio failed with error -22


Exaga 02-13-2020 12:02 PM

Quote:

Originally Posted by eduardr (Post 6089548)
@Exaga thanks, I'm seeing the following on 5.4.16 vs 5.4.18, same as documented in my initial post.

OK. Thanks eduardr. I will look into this and get back to you.

eduardr 02-13-2020 12:05 PM

@Exaga thanks, nothing urgent, can use 5.4.16 if I need sound.

Exaga 02-13-2020 11:34 PM

Quote:

Originally Posted by eduardr (Post 6089639)
@Exaga thanks, nothing urgent, can use 5.4.16 if I need sound.

eduardr - this makes no sense! On kernel 5.4.18 I've tested, as you did, and found exactly the same problem on the Rpi2 and RPi3 - but on the RPi4 it's working as expected. This is without any jiggery-pokery, butchering, tinkering, patching, modifications or otherwise. The DTBs are built from the same source code, in the same manner, across the board. :confused:

RPi4 dmesg:
Code:

[    3.432091] mc: Linux media interface: v0.10
[    3.483192] videodev: Linux video capture interface: v2.00
[    3.488504] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[    3.498842] bcm2835_audio bcm2835_audio: card created with 8 channels
[    3.528807] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.

RPi3 dmesg:
Code:

[    4.487990] mc: Linux media interface: v0.10
[    4.548868] videodev: Linux video capture interface: v2.00
[    4.635219] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[    4.635223] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned

When I attempt to load the module manually on the RPi2/3:
Code:

[ 1409.917250] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[ 1409.919174] bcm2835_audio bcm2835_audio: Failed to get DT property 'brcm,pwm-channels'
[ 1409.919208] bcm2835_audio: probe of bcm2835_audio failed with error -22

In December 2018 a dtoverlays: fe-pi-audio: fix sgtl5000 compatible string commit was accepted upstream which purported to solve this issue. In the 'arch/arm/boot/dts/overlays/fe-pi-audio-overlay.dts' the relevant code currently looks like this:
Code:

                        sgtl5000@0a {
                                #sound-dai-cells = <0>;
                                compatible = "fsl,sgtl5000";
                                reg = <0x0a>;
                                clocks = <&sgtl5000_mclk>;
                                micbias-resistor-k-ohms = <2>;

Seems to be all present and correct. Right? It's exactly the same code for the Rpi2/3/4 and why it's only working on the RPi4 on 5.4.18, and why the DTBs load successfully and the sound is working under 5.4.16 on them all and not 5.4.18, is a complete mystery to me. I'm scratching my head here. :confused: :banghead: :confused:

I'll do a full rebuild and then test with the DTBs I build and the default DTBs from the RPi github repo. Then work from there to see if I can work out what's causing this issue. It is VERY strange indeed.

eduardr 02-14-2020 10:50 AM

@Exaga thanks for your deep dive on this. After looking at lots of things with no luck, device tree being somehow involved is also my best guess (Failed to get DT property 'brcm,pwm-channels' suggests that might be the case).

As described below I noticed that in 5.4.18 DT the audio block containing the "brcm,pwm-channels" data is inside of a "mailbox" block. My best shot in the dark guess while understanding little is that maybe this different structure in 5.4.18 prevents the snd_bcm2835 module from finding that info and causing it to not work.

Details below -

Ran the following on my 2 RPi 3's, one running 5.4.16 and the other 5.4.18 after a fresh reboot on each:

RPi1: dtc -I fs /sys/firmware/devicetree/base > dtc-5.4.18.stdout.txt 2> dtc-5.4.18.stderr.txt

Rpi2: dtc -I fs /sys/firmware/devicetree/base > dtc-5.4.16.stdout.txt 2> dtc-5.4.16.stderr.txt

And I see the following differences related to audio:

dtc stdout:

Code:

5.4.16:

audio = "/soc/audio";

5.4.18

audio = "/soc/mailbox@7e00b840/audio";

Code:

5.4.16:

audio {
                        brcm,pwm-channels = <0x08>;
                        compatible = "brcm,bcm2835-audio";
                        status = "okay";
                        phandle = <0x27>;
                        pinctrl-0 = <0x1c>;
                        pinctrl-names = "default";
                };

5.4.18 (interesting - audio section is inside a mailbox block):

mailbox@7e00b840 {
                        compatible = "brcm,bcm2836-vchiq\0brcm,bcm2835-vchiq";
                        interrupts = <0x00 0x02>;
                        phandle = <0x76>;
                        reg = <0x7e00b840 0x3c>;

                        audio {
                                brcm,pwm-channels = <0x08>;
                                compatible = "brcm,bcm2835-audio";
                                status = "disabled";
                                phandle = <0x27>;
                                pinctrl-0 = <0x1c>;
                                pinctrl-names = "default";
                        };
                };


dtc stderr:

Code:

5.4.16:

<stdout>: Warning (simple_bus_reg): /soc/audio: missing or empty reg/ranges property

5.4.18

(NOTHING)


Exaga 02-14-2020 11:44 AM

Quote:

Originally Posted by eduardr (Post 6089999)
After looking at lots of things with no luck, device tree being somehow involved is also my best guess

Same no luck. I compared the .dts files from 5.4.16 and 5.4.18 and as far as I can see they are identical. I'm still looking for clues and I haven't found anything which may point to why it's missing from 5.4.18. It may be something so deep I haven't seen it yet, or some weird link from another DTB that's been modified/changed/renamed. The settings between the two are also identical.

I will keep you posted.

eduardr 02-27-2020 06:59 PM

Fixed for my RPi 3B+ machines under Sarpi 5.4.22-v7-arm !

Fixed by: waiting for this next kernel release :)

Thanks to whoever fixed this, cheers.

Exaga 02-28-2020 04:12 AM

Quote:

Originally Posted by eduardr (Post 6094976)
Thanks to whoever fixed this, cheers.

All credit goes to the Raspberry Pi Linux kernel source devs, who I understand are working hard to fix things in the 5.4.x branch. :thumbsup:


All times are GMT -5. The time now is 01:12 PM.