SparkFun top pHAT Audio not working

Hello everyone,

Ive been working on getting my top pHAT fully working. I have it so that my buttons work fine, and my audio used to work but ever since I got the display to work, my audio stopped working entirely.

When I run “sudo aplay -l” no devices show up at all, but a “sudo dkms status” shows the WM8960 sound card. Here is the steps I used to get the display working- could something here have broken the audio?

Installed the following linked file and placed in the home directory

Sfe-topphat-overlay.dts

dtc -@ -I dts -O dtb -o rpi-display.dtbo sfe-topphat-overlay.dts

sudo cp rpi-display.dtbo /boot/overlays

Add the following text to the end of the /boot/config.txt file:

dtoverlay=rpi-display,speed=32000000,rotate=270

sudo reboot

Sudo nano /etc/modules added

Spi-bcm2835

Fbtft_device

Sudo nano /etc/modprobe.d/fbtft.conf

options fbtft_device name=fb_ili9341 gpios=reset:23,dc:24 speed=16000000 bgr=1 rotate=180 custom=1

Sudo reboot

Sudo apt-get install cmake

Git clone https://github.com/tasanakorn/rpi-fbcp

Cd rpi-fbcp

Cmake

Make

Sudo install fbcp /usr/local/bin/fbcp

Sudo nano /etc/rc.local

Added “fbcp&” before “exit 0”

Sudo reboot

I also just tried to repeat the install guide for setting up the audio card and got the following error on the ./install.sh part-

pi@ECD207raspberrypi:~/WM8960-Audio-HAT $ sudo ./install.sh

Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease

Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

11 packages can be upgraded. Run ‘apt list --upgradable’ to see them.

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

raspberrypi-kernel is already the newest version (1:1.20220328-1).

raspberrypi-kernel-headers is already the newest version (1:1.20220328-1).

The following package was automatically installed and is no longer required:

libfuse2

Use ‘sudo apt autoremove’ to remove it.

0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

dkms is already the newest version (2.8.4-3).

git is already the newest version (1:2.30.2-1).

i2c-tools is already the newest version (4.2-1+b1).

libasound2-plugins is already the newest version (1.2.2-2).

The following package was automatically installed and is no longer required:

libfuse2

Use ‘sudo apt autoremove’ to remove it.

0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.


Deleting module version: 1.0

completely from the DKMS tree.


Done.

Creating symlink /var/lib/dkms/wm8960-soundcard/1.0/source →

/usr/src/wm8960-soundcard-1.0

DKMS: add completed.

Kernel preparation unnecessary for this kernel. Skipping…

Building module:

cleaning build area…

make -j4 KERNELRELEASE=5.15.30-v7+ -C /lib/modules/5.15.30-v7+/build M=/var/lib/dkms/wm8960-soundcard/1.0/build…(bad exit status: 2)

Error! Bad return status for module build on kernel: 5.15.30-v7+ (armv7l)

Consult /var/lib/dkms/wm8960-soundcard/1.0/build/make.log for more information.

mkdir: cannot create directory ‘/etc/wm8960-soundcard’: File exists

Job for wm8960-soundcard.service failed because the control process exited with error code.

See “systemctl status wm8960-soundcard.service” and “journalctl -xe” for details.


Please reboot your raspberry pi to apply all settings

Enjoy!


This thread https://github.com/waveshare/WM8960-Audio-HAT/issues/27 is for the waveshare version, but it looks like the steps to correct the error might be the same…the uninstall/wipe method, swap power supplies & see if hooking just the audio board up if it functions as expected

I tried the steps found in the github you posted but am still getting the same error- could there be a port conflict on the I2C pins for the display and speaker that is causing it to not be recognized? I suppose I cant even get the install command to work which is the first problem. Do you have any other ideas?

pi@ECD207raspberrypi:~/WM8960-Audio-HAT $ sudo ./install.sh

Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease

Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

13 packages can be upgraded. Run ‘apt list --upgradable’ to see them.

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

raspberrypi-kernel is already the newest version (1:1.20220331-1).

raspberrypi-kernel-headers is already the newest version (1:1.20220331-1).

The following package was automatically installed and is no longer required:

libfuse2

Use ‘sudo apt autoremove’ to remove it.

0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

dkms is already the newest version (2.8.4-3).

git is already the newest version (1:2.30.2-1).

i2c-tools is already the newest version (4.2-1+b1).

libasound2-plugins is already the newest version (1.2.2-2).

The following package was automatically installed and is no longer required:

libfuse2

Use ‘sudo apt autoremove’ to remove it.

0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.


Deleting module version: 1.0

completely from the DKMS tree.


Done.

Creating symlink /var/lib/dkms/wm8960-soundcard/1.0/source →

/usr/src/wm8960-soundcard-1.0

DKMS: add completed.

Kernel preparation unnecessary for this kernel. Skipping…

Building module:

cleaning build area…

make -j4 KERNELRELEASE=5.15.32-v7+ -C /lib/modules/5.15.32-v7+/build M=/var/lib/dkms/wm8960-soundcard/1.0/build…(bad exit status: 2)

Error! Bad return status for module build on kernel: 5.15.32-v7+ (armv7l)

Consult /var/lib/dkms/wm8960-soundcard/1.0/build/make.log for more information.

mkdir: cannot create directory ‘/etc/wm8960-soundcard’: File exists

Job for wm8960-soundcard.service failed because the control process exited with error code.

See “systemctl status wm8960-soundcard.service” and “journalctl -xe” for details.


Please reboot your raspberry pi to apply all settings

Enjoy!


pi@ECD207raspberrypi:~/WM8960-Audio-HAT $ sudo dkms status

wm8960-soundcard, 1.0: added

pi@ECD207raspberrypi:~/WM8960-Audio-HAT $ aplay -l

aplay: device_list:274: no soundcards found…

Also- every time I boot the device it says “Failed to load i2s-mmap overlay” … Could this be contributing to the problem?

Have you found a solution to this problem, or are you still stuck? I’ve managed to replicate the problem on my end, so I’m working to find a solution! I’ll let you know what I find.

Hi! Unfortunately I have not solved the problem yet no- but I am working on it too so I will let you know if I find anything as well. Im wondering if maybe I have too many devices on a single i2c bus or maybe my bus speed is higher than the max speed of the top pHat? I am unsure but thanks for reaching out!

I’ve been working on this intermittently over the last week, still no success. From what I gather, there was an update in the Linux kernel that broke some functionality of the WM8960 driver. Waveshare has been updating their repo to address this, but the current version is not functional on my end. I’ve tried multiple versions of Raspberry Pi OS, multiple versions of the WM8960 driver, multiple Raspberry Pis, but I’m unable to get any combination to work correctly.

I don’t think there’s any problems with conflicting I2C addresses and clock speeds, unless you’ve got some other hats installed. If so, I’d recommend testing with just the top hat to see if you can at least get the audio working.

There’s an active GitHub issue that I’ve been watching: https://github.com/waveshare/WM8960-Audio-HAT/issues/44 User dr-ni has forked the repo to try fixing the issue themself, and some other users have reported that to work. I’ve not personally had success with it, but might be worth a try: https://github.com/dr-ni/WM8960-Audio-HAT Other users have also reported switching to seeed-voicecard with good results, but I’ve not tested it myself: https://github.com/HinTak/seeed-voicecard

Unfortunately, I’m not sure if there’s anything I can do to fix this right now, it may just be a matter of waiting for Waveshare to update their driver. You might be able to downgrade your Raspberry Pi OS and WM8960 driver to previous versions, though I’ve not had success with it (careful with older OS versions, the install.sh script tries to update the raspberrypi-kernel, you’ll want to comment that out).

You mentioned that you had it working a while ago; when was this? Do you know what version of Raspberry Pi OS you were using at the time? And which model of the Raspberry Pi are you using?

I do hope we can get this working, certainly a pesky issue to have!

Quick update for you: I’ve finally got audio working on my end. Looks like the latest update from Waveshare fixed the problems I was experiencing. I’m now able to record and play audio as described in the hookup guide.

However I’m unable to get both audio and the display working simultaneously. Both work separately, but enabling the display causes the soundcard service to fail to load. I suspect this is an issue with the device tree overlay, but I’m uncertain right now and will get back to you if I figure something out.

If you currently have your display working, try commenting out the the “dtoverlay-rpi-display” line from “/boot/config.txt” and reboot (you’ll need to connect a separate monitor, or connect through SSH or VNC). Then see whether the WM8960 shows up when you run “aplay -l”. If not, try installing the latest WM8960 driver again.

Let me know how it goes!

Finally got both the display and audio working simultaneously! It was an issue with the device tree overlay, there’s a simple fix for it:

Assuming you followed the hookup guide, it had you add “dtoverlay=rpi-display,speed=32000000,rotate=270” to the end of “/boot/config.txt”. Replace that line with the following:

dtoverlay=fbtft,spi0-0,speed=16000000,ili9341,rotate=270,reset_pin=23,dc_pin=24

Then reboot. You should find that the display works, and “aplay -l” shows the WM8960 soundcard. Let me know how it goes!

Excellent thanks so much! I haven’t had success fixing it before this, but this helps a ton. Thank you!