waveshare / WM8960-Audio-HAT

The drivers of [WM8960 Audio HAT] for Raspberry Pi
GNU General Public License v3.0
100 stars 65 forks source link

Build error on kernel: 6.1.21-v7+ (armv7l) (pi2zeroW) #52

Open Fysek opened 7 months ago

Fysek commented 7 months ago

I am working on PI 2 zero W with WM8960 Audio HAT https://www.waveshare.com/wiki/WM8960_Audio_HAT raspberrypi-kernel : (1:1.20230405-1) raspberrypi-kernel-headers: (1:1.20230405-1)

I did this: sudo apt-get dist-upgrade sudo apt-get update git clone https://github.com/waveshare/WM8960-Audio-HAT cd WM8960-Audio-HAT sudo nano wm8960-soundcard.dts Change target = <&i2c1>; to <&i2c0> ; line 25 sudo ./install.sh sudo reboot -> nothing changed

Dec 10 18:40:17 pizero systemd[1]: Starting WM8960 soundcard service... Dec 10 18:40:17 pizero wm8960-soundcard[369]: + exec Dec 10 18:40:17 pizero wm8960-soundcard[400]: ++ basename /usr/bin/wm8960-soundcard Dec 10 18:40:20 pizero systemd[1]: wm8960-soundcard.service: Main process exited, code=exited, status=99/n/a Dec 10 18:40:20 pizero systemd[1]: wm8960-soundcard.service: Failed with result 'exit-code'. Dec 10 18:40:20 pizero systemd[1]: Failed to start WM8960 soundcard service.


Logs:
```shell
cat /var/lib/dkms/wm8960-soundcard/1.0/6.1.21-v7+/armv7l/log/make.log
DKMS make.log for wm8960-soundcard-1.0 for kernel 6.1.21-v7+ (armv7l)
Sun 10 Dec 18:39:13 CET 2023
make: Entering directory '/usr/src/linux-headers-6.1.21-v7+'
  CC [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/wm8960.o
  CC [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/wm8960-soundcard.o
/var/lib/dkms/wm8960-soundcard/1.0/build/wm8960.c: In function ‘wm8960_hw_params’:
/var/lib/dkms/wm8960-soundcard/1.0/build/wm8960.c:882:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
  882 |   if ((iface & 0x3) != 0) {
      |      ^
/var/lib/dkms/wm8960-soundcard/1.0/build/wm8960.c:887:2: note: here
  887 |  default:
      |  ^~~~~~~
  LD [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/snd-soc-wm8960-soundcard.o
  LD [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/snd-soc-wm8960.o
  MODPOST /var/lib/dkms/wm8960-soundcard/1.0/build/Module.symvers
  CC [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/snd-soc-wm8960-soundcard.mod.o
  CC [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/snd-soc-wm8960.mod.o
  LD [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/snd-soc-wm8960-soundcard.ko
  LD [M]  /var/lib/dkms/wm8960-soundcard/1.0/build/snd-soc-wm8960.ko
make: Leaving directory '/usr/src/linux-headers-6.1.21-v7+'
YuMingC233 commented 6 months ago

I encountered the same wm8960-soundcard.service error code 99 issue, but I just did a test and it doesn't seem to affect any related functionalities, such as running commands like aplay xxx.wav, etc. It's really strange, isn't it?

Fysek commented 6 months ago

Interesting finding @YuMingC233, did you try to run alsamixer to check if raspbian sees it as a sound card? Here's a manual https://www.waveshare.com/wiki/WM8960_Audio_HAT Btw. what is your hardware and kernel version?

YuMingC233 commented 6 months ago

Based on the results, it is able to very accurately recognize it as a sound card:

Untitled

Untitled (1)

My hardware:

Raspberry Pi Zero 2

WM8960 Audio HAT

IMG_20231222_202056

After assembly

IMG_20231222_202656

My kernel version:

Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

How I discovered this anomaly

When I normally boot it up, there is an error at the end of the startup, like this:

IMG_20231222_203026

Further error information

Untitled (2)

Looks identical, doesn't it? 😏😏

When I tried to reboot:

Untitled (3)

Ok, it failed.

When I checked journalctl -xe to investigate further:

Untitled (4)

Memory leak? But when I checked htop, I found no applications hogging system resources:

Untitled (5)

However, when I tried to reboot it again, the same error occurred.

Actually, this issue is not "fatal." When I use aplay xxx.wav in this state, it can play correctly, and even more advanced "real-time listening" commands like arecord -f cd | sudo arecord -f cd | aplay work fine.

Note, none of my commands explicitly specify the hardware.

@Fysek You might also try testing to see if you can replicate it.

Cheers 🥂

Subuday commented 3 months ago

I have been experience the same problem.

Subuday commented 3 months ago

Okay, it looks like I figured out what's problem.

Fysek commented 3 months ago

Okay, it looks like I figured out what's problem.

@Subuday Could you share what's the problem and any possible solutions, please?

Subuday commented 3 months ago

On my Raspberry Pi Zero 2 W, by default I have two devices:

card 0: vc4hdmi
card 1: wm8960soundcard

You can check this using aplay -l.

Then I checked logs of wm8960-soundcard.service: alsactl restore

No state is present for card vc4hdmi
alsa-lib main.c:1014:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
Found hardware: "vc4-hdmi" "" "" "" ""
Hardware is initialized using a generic method
No state is present for card vc4hdmi

So it looks like alsactl tries to restore by default with card 0 that is vc4hdmi instead wm8960soundcard.

To fix starting of the service, just modify it to launch with the correct card. In my case it is alsactl restore -c 1

Subuday commented 3 months ago

Maybe we need some code that would either disabling vc4hdmi or setting proper card by searching in system wm8960soundcard.