HinTak / seeed-voicecard

This is an enhancement fork with the explicit aim of supporting current shipping Raspbian/Ubuntu kernels without requiring downgrading. Please donate at https://hintak.github.io/ if it works for you. Use vX.Y branch for kernel version vX.Y
GNU General Public License v3.0
180 stars 67 forks source link

Raspberry Pi 5 Support #19

Open zytegalaxy opened 7 months ago

zytegalaxy commented 7 months ago

I tried installing the driver on a fresh bookworm image in Pi 5 and after reboot, the system does not boot anymore. On Pi 4, same OS image everything work well (v6.1).

I would like to get behind Pi 5 support and help to make it happen. This audio chip is super popular and it will be bummer not to have support for Pi 5...

The issue might be related to this: https://github.com/raspberrypi/linux/issues/5743

flatsiedatsie commented 6 months ago

I have it running on a Pi 5, on a bookworm LITE image I flashed today. I did have to add:

dtoverlay=i2s-mmap
dtparam=i2s=on
dtoverlay=seeed-2mic-voicecard

to /boot/firmware/config.txt

makermelissa commented 6 months ago

It installs and works fine on the lite version of bookworm using the above, but it kills the desktop even after uninstalling.

zytegalaxy commented 6 months ago

This script ended up working well for me:

https://github.com/ubopod/ubo-sdk/blob/main/system/setup/install_wm8960.sh

makermelissa commented 5 months ago

Thank you @ubopod. It appears to be working for me as well.

HinTak commented 5 months ago

Pi5 support and bookworm supports are separate issues. I believe the latter is fixed by #23 . Not sure about the former - anybody with a pi5 want to try after the #23 merge again?

HinTak commented 5 months ago

sorry, didn't mean to close.

makermelissa commented 5 months ago

Yes, #23 fixed an issue with Bookworm, but was it still not working not Pi 5.

HinTak commented 5 months ago

@makermelissa is the desktop issue same as lxpanel problem mentioned elsewhere?

I am a bit confused - @flatsiedatsie and @ubopod seems to have something that works?

makermelissa commented 5 months ago

I'm not sure what the lxpanel problem is. However, installing causes the desktop environment to stop working, but I can still SSH into the Pi and play audio just fine. The solution @ubopod mentioned works in the desktop environment, but isn't working for me on the lite version.

HinTak commented 5 months ago

@makermelissa pulseaudio seems to interfere with the desktop environment - https://github.com/HinTak/seeed-voicecard/issues/8 .

makermelissa commented 5 months ago

Thanks, I'll see if removing it first (or after) fixes the issue.

makermelissa commented 5 months ago

Uninstalling PulseAudio had no effect. Still no desktop.

HinTak commented 5 months ago

@makermelissa surely there are signs why it doesn't start - e.g. if you can still ssh in, as root, have a look at sys log - for systemd based systems, it is journalctl -r -b (since this boot), you might have to hunt around /var/log to see what other sys log mechanisms record.

makermelissa commented 5 months ago

I'll take a deeper look into the issue and let you know if I see something that stands out.

makermelissa commented 5 months ago

Here are the relevant sections of the log that stood out. Much of it is repeated:

Jan 11 08:43:53 raspberrypi wireplumber[1060]: Trying to use legacy bluez5 API for LE Audio - only A2DP will be supported. Please upgrade bluez5.
Jan 11 08:43:53 raspberrypi systemd[1]: Started session-5611.scope - Session 5611 of User pi.
Jan 11 08:43:53 raspberrypi systemd-logind[713]: New session 5611 of user pi.
Jan 11 08:43:53 raspberrypi lightdm[1330355]: pam_unix(lightdm-autologin:session): session opened for user pi(uid=1000) by (uid=0)
Jan 11 08:43:53 raspberrypi systemd[1]: Started lightdm.service - Light Display Manager.
Jan 11 08:43:52 raspberrypi systemd[1]: Starting lightdm.service - Light Display Manager...
Jan 11 08:43:52 raspberrypi systemd[1]: Stopped lightdm.service - Light Display Manager.
Jan 11 08:43:52 raspberrypi systemd[1]: lightdm.service: Scheduled restart job, restart counter is at 2794.
Jan 11 08:43:52 raspberrypi systemd[1]: lightdm.service: Failed with result 'exit-code'.
Jan 11 08:43:52 raspberrypi systemd[1]: lightdm.service: Main process exited, code=exited, status=1/FAILURE
Jan 11 08:43:52 raspberrypi systemd-logind[713]: Session c2794 logged out. Waiting for processes to exit.
Jan 11 08:43:52 raspberrypi systemd[1]: session-c2794.scope: Deactivated successfully.
Jan 11 08:43:52 raspberrypi lightdm[1329811]: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
Jan 11 08:43:52 raspberrypi lightdm[1329811]: instance with invalid (NULL) class pointer
Jan 11 08:43:52 raspberrypi lightdm[1330170]: pam_unix(lightdm-greeter:session): session closed for user lightdm
Jan 11 08:43:42 raspberrypi pipewire[1330190]: mod.rt: Can't find org.freedesktop.portal.Desktop. Is xdg-desktop-portal running?
Jan 11 08:43:42 raspberrypi wireplumber[1330191]: Can't find org.freedesktop.portal.Desktop. Is xdg-desktop-portal running?
Jan 11 08:43:42 raspberrypi pipewire-pulse[1330192]: mod.rt: Can't find org.freedesktop.portal.Desktop. Is xdg-desktop-portal running?
makermelissa commented 5 months ago

Reinstalling lightdm lets it boot to the desktop once again, but it loses any customizations and looks like the default debian desktop rather than the Raspberry Pi bookworm desktop.

HinTak commented 5 months ago

The repeatedness is meaningful - lightdm refuses to start, so systemd try to start it over and over.

@makermelissa I think there is a apt.log (or as part of systemd messages) about installed packages. So it would be interesting to know what is most recently installed because of lightdm. It looks like it might depends on pulseaudio - that's a bit insane surely, the display manager needing to play sound?

makermelissa commented 5 months ago

Makes sense with what I was seeing. I'll keep looking, but probably a bit later today.

etiennedv-mathu commented 5 months ago

I haven't been able to get it working on my Pi5 with the Respeaker 4-Mic Array v1.2.

With a fresh copy of bookworm lite I can install without issue. But I don't see any devices listed.

pi@username:~ $ arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
default
playback
ac108
sassanh commented 5 months ago

The solution @ubopod mentioned works in the desktop environment, but isn't working for me on the lite version.

My observation on a lite installation of bookworm is that when I ran the script, rebooted the device and played some audio, I heard nothing, I had to set "Playback" and "Speaker" values to a non-zero value in alsamixer to hear things:

image
zytegalaxy commented 5 months ago

I'm not sure what the lxpanel problem is. However, installing causes the desktop environment to stop working, but I can still SSH into the Pi and play audio just fine. The solution @ubopod mentioned works in the desktop environment, but isn't working for me on the lite version.

I confirm the solution suggested in https://github.com/HinTak/seeed-voicecard/issues/19#issuecomment-1879387637 works on lite version too

AIWintermuteAI commented 3 months ago

~~PR here https://github.com/HinTak/seeed-voicecard/pull/29~~ See the below comments.

HinTak commented 3 months ago

@AIWintermuteAI I am not convinced about pull - for two reasons, it just loads the 2-mic device tree so doesn't apply to the other devices; the i2cdetect -y .... lines in seeed-voiceccard is supposed to auto-detect what device is actually connected, and load that automatically.

So the fact that force-loading the device tree works, seems to suggest that on p5, the i2cdetect -y ... code is broken. Can somebody with a p5 and some devices connected, runs the 3 i2cdetect -y lines and show the result? I mean just run these 3 lines:

i2cdetect -y  1 0x1a 0x1a
i2cdetect -y  1 0x35 0x35
i2cdetect -y  1 0x3b 0x3b

`

HinTak commented 3 months ago

It seems that i2cdetect on P5 is indeed faulty : https://github.com/raspberrypi/linux/issues/6056

HinTak commented 3 months ago

@AIWintermuteAI this upstream issue seems highly relevant: https://github.com/raspberrypi/linux/issues/5743 - have a read. It seems to suggest modifying the device tree overlays.

HinTak commented 3 months ago

This sort of explains why the 2-mic card is easier to get to work - it doesn't do playbacks.

AIWintermuteAI commented 3 months ago

@HinTak yes, after a look at the issue it seems that the PR I made is more a quick patch rather than actual long-term solution. I'll close it. I've been away from all the reSpeaker stuff for quite a while now and it's not immediately clear to me what needs to be modified in the device tree overlays. I do have a Pi 5 here for testing tho.

fonix232 commented 1 month ago

@HinTak looks like recent versions of the Pi5 kernel have fixed the I2C detection issue. I'm on 6.6.28+rpt-rpi-2712 and i2cdetect -y 1 properly shows the 4-mic HAT being installed:

admin@pi5:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

(note that at this point I had the drivers loaded hence the UU state)

The service also correctly identifies the 4-mic array and loads the appropriate config and state files. However, arecord -L still returns no devices:

admin@pi5:~ $ service seeed-voicecard status
● seeed-voicecard.service - Seeed Voicecard service
     Loaded: loaded (/lib/systemd/system/seeed-voicecard.service; enabled; preset: enabled)
     Active: active (exited) since Thu 2024-05-23 15:22:41 BST; 33min ago
   Main PID: 638 (code=exited, status=0/SUCCESS)
        CPU: 293ms

May 23 15:22:41 pi5 seeed-voicecard[638]: create seeed-4mic-voicecard asound status file
May 23 15:22:41 pi5 seeed-voicecard[638]: + ln -s /etc/voicecard/ac108_asound.state /var/lib/alsa/asound.state
May 23 15:22:41 pi5 seeed-voicecard[638]: + alsactl restore
May 23 15:22:41 pi5 seeed-voicecard[851]: No state is present for card Device
May 23 15:22:41 pi5 seeed-voicecard[851]: Found hardware: "USB-Audio" "USB Mixer" "USB0c76:1203" "" ""
May 23 15:22:41 pi5 seeed-voicecard[851]: Hardware is initialized using a generic method
May 23 15:22:41 pi5 seeed-voicecard[851]: No state is present for card Device
May 23 15:22:41 pi5 seeed-voicecard[852]: + aplay -l
May 23 15:22:41 pi5 seeed-voicecard[853]: + grep -q 'bcm2835 ALSA'
May 23 15:22:41 pi5 systemd[1]: Finished seeed-voicecard.service - Seeed Voicecard service.
admin@pi5:~ $ arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault
    Default Audio Device
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
playback
ac108
default
output
usbstream:CARD=Device
    USB PnP Audio Device
    USB Stream Output

(please ignore the USB PnP Audio Device, it's a separate audio card mounted on the bottom of the Pi5 )

The driver in question is running off the v6.6 branch.