Waveshare Audio DAC WM8960

This serves as a follow up to an outdated thread regarding Volumio compatibility with WM8960.

Since the WM8960 currently seems to be the only amplifier board that runs with Pi’s on-board power and has a phone jack additionally to the speaker connectors, I assume it’s worth another look. For my use case (battery-powered kids juke box with speakers and headphone support) it seems the perfect choice.

I’ve gone through all the replies in said thread. The last hope was a comment by Inbxa in February 2022 mentioning editing the dacs.json manually and then installing the DAC’s driver. As of today, I cannot confirm this is working.

Setup: Volumio 3.757, 17-09-2024 on a Raspberry Pi 5 with 7-inch touch screen.

Reproduction

  1. Following Step 1-5 from Inbxa Volumio install
  2. The original WM8960 repo install script is not working on Buster anymore. It expects the config.txt in /boot/firmware/, which is bookworm-compatible. There is a community wrapper that fixes this to work with buster.
  3. One can select the audio output in Volumio, but pressing play has no effect (no sound, no seconds counting down) and showing the error "Failed to open “alsa” (alsa); Error opening ALSA device “volumio”; snd_pcm_hw_params() failed: Invalid argument

What I have debugged:

~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960soundcard [wm8960-soundcard], device 0: 1f000a0000.i2s-wm8960-hifi wm8960-hifi-0 [1f000a0000.i2s-wm8960-hifi wm8960-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

speaker-test -c2 -Dhw:1,0 works!

~$ speaker-test -c2 -Dhw:1,0

speaker-test 1.1.8

Playback device is hw:1,0
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 131072
Period size range from 32 to 1024
Using max buffer size 131072
Periods = 4
was set period_size = 1024
was set buffer_size = 131072
 0 - Front Left
 1 - Front Right
Time per period = 3.247001
 0 - Front Left
 [...]

Maybe issues with 44,1 kHz?

~$ aplay -Dhw:1,0 /volumio/app/startup.wav 
Playing WAVE '/volumio/app/startup.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1403: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 44100
PERIOD_TIME: (23219 23220)
PERIOD_SIZE: 1024
PERIOD_BYTES: 4096
PERIODS: 22
BUFFER_TIME: (510839 510840)
BUFFER_SIZE: 22528
BUFFER_BYTES: 90112
TICK_TIME: 0

But a self-recorded 48 kHz Sample works flawlessly

~$ aplay -Dhw:1,0 test48000.wav            
Playing WAVE 'test48000.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

This is where my debugging capabilities come to an end. Maybe one last note: I used the same hardware with a second SD card running an up-to-date Raspberry Pi OS. After installing the driver from the mentioned repo, system sound, Spotify (Browser) and media players work flawlessly.

If anyone is able to look into this or give me hints I could try out, I would be very thankful.

Apart from having an earphone jack, there are two other RPi HAT powered amplifier boards out there, from Infineon and Pimoroni, both with a higher power output than the Waveshare device, and of arguably higher audio quality. I have used both of these with Volumio (and also Moode, PiCoreplayer etc) to good effect.

Infineon

Pimoroni

The full range of Pimoroni ‘Pirate Audio’ products are here:

Pirate Audio

it looks like the overlay and the driver for the WM8960 soundcard has been included in the kernel, so in theory no need to install external drivers on the system

maybe we can do something for this card when moving to the 6.6.x kernel for RPi (currently the image is in alpha testing)

That sounds great! Maybe I can use that one until Christmas :slightly_smiling_face: I will def support this project financially if you can make this possible.

I have read in one of the issues that the kernel built-in overlay is not the latest version, but that was a rather vague information. I also cannot find that issue anymore. Just so that you have this in mind if the implementation gets stuck somewhere.

Edit: Would it be helpful and supportive if I buy the Volumio team a WM9860 and have it sent to one of the developers (you?)?

As mentioned, we can give it a try with the kernel built-in overlay, it’s been fixed very recently and hopefully it will work.

Thanks for your offer of sending one, but it won’t be necessary, I will ping you in private to obtain some information. Only one remark: there is no ETA for this activity, I’ll try to do my best when I have some spare time.

@Cologne_Muc

could you please give a try to the Beta version 3.765?

please start with a clean install, select the new Waveshare WM8960 entry from the I2S DAC list

I just set everything up. No issues selecting the HAT, but unfortunately no sound. No visible errors. When I start something (I used an internet radio station), it counts down for three seconds, then the number of seconds is only updated if you switch to another screen in between.
speaker-test also shows no error, but you can’t hear anything. I have checked the volume in alsamixer and Volumio.
Do I perhaps have to select other settings in the playback options? DSD? Playback Type? I’ve left everyhting on default.

Not sure if it helps, but I uploaded the logs: http://logs.volumio.org/volumio/uSNkhoK.html

~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: wm8960soundcard [wm8960-soundcard], device 0: 1f000a0000.i2s-wm8960-hifi wm8960-hifi-0 [1f000a0000.i2s-wm8960-hifi wm8960-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
~$ speaker-test -c2 -Dhw:2,0

speaker-test 1.1.8

Playback device is hw:2,0
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 16 to 131072
Period size range from 8 to 65536
Using max buffer size 131072
Periods = 4
was set period_size = 32768
was set buffer_size = 131072
 0 - Front Left
 1 - Front Right
Time per period = 2.734109

Please let me know if I can provide any more information. The setup is up and running.

could you please post a screenshot of all the alsamixer controls?

Sure. They are all covered with these two screenshots:
Changing the volume in Volumio directly affects the vertical “Playback” bar.


What I changed from vanilla Volumio was to raise the first four bars to maximum (“Headphone” and “Speaker” x3). The rest is untouched by me.

Hi All,

I was trying to get the WM8960 to work with Volumio as well and wanted to share one thing i discovered: When i check the I2C addresses using i2cdetect i cannot even see the WM8960. So it looks like I2C is the problem at this point and not (or not only) the driver.
I was using the beta version as well, where the WM8960 is available as a DAC.

Cheers

Edit: Never mind, this appears to have only worked momentarily, now I just get the following error when trying to play a song
image

Lots digging in forums and tinkering has brought me to solution for this, though maybe only temporary. I used the provided Beta image but was having the same issue of no audio output after selecting the WaveShare as an I2S DAC. So here’s what I did:

Accessed the volumio OS via SSH and installed the drivers provided by WaveShare

git clone -b rpi-4.9.y GitHub - waveshareteam/WM8960-Audio-HAT: The drivers of [WM8960 Audio HAT] for Raspberry Pi
cd WM8960-Audio-HAT
sudo ./install.sh
sudo reboot

In the Volumio WebUI I changed the playback options to the following:

  1. Toggle off I2S, Save
  2. Changed ‘Output device’ to wm8960-soundcard
  3. Changed ‘Mixer Control Name’ to ‘Speaker’

Now I get great audio output from the speakers that come packaged with the HAT.

I got it to work. I used the beta version mentioned above. Then I downloaded the kernel sources using “volumio kernelsource” and then I installed using the master branch provided by Waveshare. Reboot, done. WORKS!

Edit: Can confirm, after running the 'volumio kernelsource’command, and then installing the drivers from the master repo from Waveshare, I can now use the wm8960 as an I2S DAC Device.

That’s awesome, does it function as an I2S DAC now or did you just need to specify it as a normal output device?

Ok, one more update. After a second reboot the DAC stopped functioning again. I SSH’d into the Pi and ran aplay -l. The WM8960 had changed from Card 0 to Card 1. I was able to fix it by editing the /volumio/app/plugins/system_controller/i2s_dacs/dacs.json file.

I found the entry for the waveshare and changed the section “alsanum”:“2” to “alsanum”:“1”. After a reboot it works again, and subsequent reboots work as well.

I’m using the HAT on Pi Zero 2 W FWIW.

Hi guys,
so in conclusion, one needs to

  1. Install the Volumio Beta shown above
  2. Execute volumio kernelsource
  3. Install the most recent driver from waveshareteam/WM8960-Audio-HAT

It seems that you can then use the WM8960 either as output device directly or with the new I2C configuration.

@Darmur Can you confirm this makes sense? Is volumio kernelsource really necessary? If yes, could you improve the beta so that it is not needed anymore?

Additionally I wonder about two things

  • The master branch of waveshareteam/WM8960-Audio-HAT does not work with a current Volumio image, because it configures overlays in a file that only exist in newer versions of Raspberry Pi OS: WM8960-Audio-HAT/install.sh at master · waveshareteam/WM8960-Audio-HAT · GitHub. But probably having some driver files in the system is enough, Volumio cares about the referenced overlay.
  • Has anyone tested the phone jack? @Guschti, @optimuspryne? I guess it depends on a systemd service that I could not get to run on any recent system/image. Their issue tracker is full of bug reports for this.

if the custom driver from waveshare must be compiled, yes the kernelsource command is necessary

at the moment I cannot guarantee if I can find some spare time to include this custom driver in the volumio image, so this workaround must be done. I will keep you posted if the custom driver will be included later on

1 Like

Please, help install wm8960.With raspberry pi 3
thx.

Sorry for the late reply, life got in the way. Here is everything I did that worked for me and is continuing to work:

  1. Install/use the Volumio Beta image
  2. Execute ‘volumio kernelsource’ via CLI
  3. Install the drivers from Waveshare via CLI
  4. Reboot
  5. In Playback Settings change the output device to I2S DAC and choose the Waveshare device
  6. Reboot
  7. You may just need to reboot a few times and ignore these next steps but I’m including them just in case
  8. Execute aplay -l via CLI and determine which number the Waveshare has been assigned. If it’s still device 0, you should be good. If not you’ll need to edit the dacs.json file at /volumio/app/plugins/system_controller/i2s_dacs/dacs.json.
  9. In this file, find the entry for the Waveshare and change the section “alsanum”:“2” to “alsanum”:“%Number you found when running aplay -l%”. Save and reboot. (You may need to reboot a couple of times until the Waveshare gets assigned a consistent number, I had to change the json file twice because the number changed from 0 to 1 on one reboot and then to 2 on a second reboot. It has stayed 2 on numerous reboots since)

@Cologne_Muc Sorry, I haven’t actually tested the headphone jack, I’m using the spkr jack. Maybe if you change the mixer device in the Playback settings to the headphone jack?

the beta with kernel 6.6.56 has been promoted as stable

Thanks all,Working, super app. Thanks lot.