Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulseaudio on Rpi4, bookworm, 64bit #43

Open
bjoernbusch opened this issue Apr 28, 2024 · 6 comments
Open

pulseaudio on Rpi4, bookworm, 64bit #43

bjoernbusch opened this issue Apr 28, 2024 · 6 comments

Comments

@bjoernbusch
Copy link

Hello void,

I know that this is completely unmaintained, but maybe someone is still listening in on this and has some ideas. I really like the phat-beat hat and it's still working fine, but I wanted to upgrade the RaspberryPi underneath for different reasons. I started the old install scripts on a brand new bookworm 64bit.

  • OS_NAME could not be determined, so it patched that variable
  • The python package can't be installed via python anymore, but via apt, so I patched that
  • wiringpi is now available from here: https://github.com/WiringPi/WiringPi/releases/download/3.1/wiringpi_3.1_arm64.deb, so I patched that
    • 3.2. didn't work, don't remember the exact log anymore, but it said to use 3.1 instead
  • So the installation seems to run through.

The phatbeat Python library doesn't properly connect to the board, when doing phatbeat.set_all(0,128,0,0.1) it crashes due to

Traceback (most recent call last):
  File "/usr/bin/phatbeatd", line 192, in <module>
    phatbeat.set_all(0,128,0,0.1)
  File "/usr/lib/python3/dist-packages/phatbeat/__init__.py", line 250, in set_all
    setup()
  File "/usr/lib/python3/dist-packages/phatbeat/__init__.py", line 325, in setup
    GPIO.add_event_detect(button, GPIO.FALLING, callback=_handle_button, bouncetime=200)
RuntimeError: Failed to add edge detection
Exception ignored in atexit callback: <function _exit at 0x7faf6e5a80>

I can live without the actual phatbeat LED stuff, I only care about audio output, so I removed the GPIO.add_event_detect call from the python library.

Now my last hurdle seems to be that pulseaudio can't connect to the actual board.

pulseaudio[705]: Using device: phat-beat
pulseaudio[707]: gpio: Unable to open GPIO direction interface for pin 23: No such file or directory
pulseaudio[709]: gpio: Unable to open GPIO direction interface for pin 24: No such file or directory
pulseaudio[705]: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
pulseaudio[705]: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="1" name="platform-fef00700.hdmi" card_name="alsa_card>
pulseaudio[705]: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
pulseaudio[705]: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="2" name="platform-fef05700.hdmi" card_name="alsa_card>
pulseaudio[705]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a>
pulseaudio[705]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY>

I guess both the Python issue and the pulseaudio issue are due to some GPIO changes, but here I'm a little but clueless. Any further hints would be appreciated.

Maybe @Gadgetoid, I saw you commenting on these things in the past.

@Gadgetoid
Copy link
Member

Audio

I'd guess the issue with audio playback is that all instructions/install scripts put stuff in /boot/config.txt which is now just a file that reads:

DO NOT EDIT THIS FILE

The file you are looking for has moved to /boot/firmware/config.txt

Which is rather unhelpful.

I'm reasonably sure you can just add dtoverlay=hifiberry-dac to /boot/firmware/config.txt and at least the audio side of pHAT BEAT will work fine.

LEDs

For user control of the LEDs you'll eventually be able to use pimoroni/apa102-python#9

That APA102 library (which is what the LEDs on pHAT BEAT are, fundamentally) needs some updates with all the stuff I've learned over the last few months before it's ready for prime time though.

Buttons

These are just regular GPIOs on the following pins:

BTN_FASTFWD = 5
BTN_REWIND = 13
BTN_PLAYPAUSE = 6
BTN_VOLUP = 16
BTN_VOLDN = 26
BTN_ONOFF = 12

They're active-low, with a pull-up so you can probably just try the following in /boot/firmware/config.txt to see if it works:

dtoverlay=gpio-key,gpio=5,keycode=163
dtoverlay=gpio-key,gpio=13,keycode=165
dtoverlay=gpio-key,gpio=6,keycode=119
dtoverlay=gpio-key,gpio=16,keycode=114
dtoverlay=gpio-key,gpio=26,keycode=115
dtoverlay=gpio-key,gpio=12,keycode=166

With the expectation that this will make those buttons behave like volume up/down, prev/next, play/pause and stop keyboard media keys. (I haven't tested this!)

The event codes header, that serves as a lookup table for the keycode, value is here: https://github.com/torvalds/linux/blob/e67572cd2204894179d89bd7b984072f19313b03/include/uapi/linux/input-event-codes.h#L189-L190

@bjoernbusch
Copy link
Author

Adding dtoverlay=hifiberry-dac to /boot/firmware/config.txt get me passed the GPIO errors, but the errors about the profile persist and there is no sound yet. Any further ideas?

Apr 29 14:37:10 audiopi pulseaudio[645]: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
Apr 29 14:37:13 audiopi pulseaudio[645]: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Apr 29 14:37:13 audiopi pulseaudio[645]: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="2" name="platform-fef00700.hdmi" card_name="alsa_card.platform-fef00700.hdmi" namereg_fail=false tsched=no fixed_latency_r>
Apr 29 14:37:13 audiopi pulseaudio[645]: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Apr 29 14:37:13 audiopi pulseaudio[645]: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="3" name="platform-fef05700.hdmi" card_name="alsa_card.platform-fef05700.hdmi" namereg_fail=false tsched=no fixed_latency_r>
Apr 29 14:37:14 audiopi pulseaudio[645]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Apr 29 14:37:14 audiopi pulseaudio[645]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Apr 29 14:37:32 audiopi pulseaudio[991]: E: [pulseaudio] main.c: Failed to kill daemon: No such process
Apr 29 14:37:32 audiopi systemd[1]: pulseaudio.service: Control process exited, code=exited, status=1/FAILURE
Apr 29 14:37:32 audiopi systemd[1]: pulseaudio.service: Failed with result 'exit-code'.
Apr 29 14:37:32 audiopi systemd[1]: pulseaudio.service: Scheduled restart job, restart counter is at 1.

@Gadgetoid
Copy link
Member

I can't believe I'm writing these words, but Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 suggests audio wont work without booting up into Raspberry Pi Desktop...

Are you running the full desktop or Lite flavour of Pi OS?

What are you launching to try and get audio playing?

@bjoernbusch
Copy link
Author

yeah, I guess I should have read all the way to the right :)

No, it's just the Lite version of Pi OS. I'm using it as a headless radio player. I've added some MQTT subscription in the phatbeatd code, so that I could remotely turn on the radio, that's why I don't need the buttons and the LEDs.

Let me try to through the desktop onto this machine then

@Gadgetoid
Copy link
Member

Do you have any luck running something simple like: speaker-test -c2 -twav ?

@bjoernbusch
Copy link
Author

hm, I guess a little bit of UI didn't help.

sudo apt install xserver-xorg raspberrypi-ui-mods xinit + raspi-config boot options

Apr 29 17:50:46 audiopi systemd[1]: Started pulseaudio.service - PulseAudio Daemon.
Apr 29 17:50:47 audiopi pulseaudio[546]: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
Apr 29 17:50:52 audiopi pulseaudio[546]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Apr 29 17:50:52 audiopi pulseaudio[546]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Apr 29 17:50:52 audiopi pulseaudio[546]: [pulseaudio] bluez5-util.c: Could not find org.bluez.BatteryProviderManager1.RegisterBatteryProvider(), is bluetoothd started with experimental features enabled (-E flag)?
Apr 29 17:50:55 audiopi pulseaudio[546]: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Apr 29 17:50:55 audiopi pulseaudio[546]: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="1" name="platform-fef05700.hdmi" card_name="alsa_card.platform-fef05700.hdmi" namereg_fail=false tsched=no fixed_latency_r>
Apr 29 17:50:55 audiopi pulseaudio[894]: E: [pulseaudio] main.c: Failed to kill daemon: No such process
Apr 29 17:50:55 audiopi systemd[1]: pulseaudio.service: Control process exited, code=exited, status=1/FAILURE
Apr 29 17:50:55 audiopi systemd[1]: pulseaudio.service: Failed with result 'exit-code'.
Apr 29 17:50:55 audiopi systemd[1]: pulseaudio.service: Scheduled restart job, restart counter is at 1.
Apr 29 17:50:55 audiopi systemd[1]: Stopped pulseaudio.service - PulseAudio Daemon.
speaker-test -c2 -twav

speaker-test 1.2.8

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Playback open error: -524,Unknown error 524

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants