No audio from RPI 4B Headphone jack

Creating a bug report/issue

Required Information

  • DietPi version | 8.16

  • Distro version | Raspian Bullseye

  • Kernel version |Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

  • SBC model | RPI 4B

  • Power supply used | RPI power cube

  • SD card used | Kingston 120Gb SSD

Additional Information (if applicable)

  • Software title | Dietpi
  • Was the software title installed freshly or updated/migrated?
  • Can this issue be replicated on a fresh installation of DietPi?
    ← If you sent a “dietpi-bugreport”, please paste the ID here →
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  1. Initial first run setup procedures
  2. Dietpi-Config - Audio Options
    enabled audio (loaded alsa)
    selected rpi-bcm2835-3.5mm as sound card
    after setup completed, ran the following command:
    speaker-test -c2 -twav -l4

Expected behaviour

should hear “front left front right” repeated 4 times.

Actual behaviour

no sound at all

Extra details

Plugged in a usb speaker and selected it sound card and speaker test, it worked normally.
On another ssd did a fresh install of raspian nbulleyes lite and after the first run script completed, went into raspi-config and selected the headphome jack for audio out. Speaker-Test worked normally.

something for @MichaIng our audio specialist

Did you reboot once? The onboard sound devices are toggled via /boot/config.txt firmware settings, so won’t be effective until a reboot.

Yes I did as the end of the first run scripts will normally require a reboot to take care of the change in the ssh server (I always change that when I do an install). But just to double check I will bring the dietpi system back up in a few to verify. And no I am not using ssh at this time, just a normal setup with monitor, keyboard and all.

Did the check. Both as a normal user and as root. Still no audio.

I did not look at config.txt, so will take a look and see what audio related settings are there in case there are any questions.

I had this trouble a few times. My guess is your audio is using the HDMI. Try changing the soundcard to the option near the very end of the list. Also run cava or the mixer to make sure your not on mute or have the level on 0. It will default to the first thing unless you specify something else.

dietpi@DietPi:/dev$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 7/8
  Subdevice #0: subdevice #0

That may not work as audio needs to be explicitly enabled in /boot/dietpi.txt, which is done only when explicitly selecting the onboard audio options at the top of the list.

aplay -l however is a good command to check whether the analogue audio device “bcm2835 Headphones” really is enabled.

dtparam=audio=on is needed in /boot/config.txt and dtoverlay=dietpi-disable_headphones must not be present.

Verified that selecting hw 1,0 does give a dtparm=audio=off and that aplay will show no soundcards available.
Selecting the rpi-bcm2835-3.5mm option does give “dtparm=audio=on” and “dtoverlay=dietpi-disable_hdmi_audio” entries in config.txt.
aplay -l shows card 1 as “card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]”.
But still no audio.
Yes, didn a reboot after each change in dietpi-config.
Alsamixer just shows a “PCM” entry which is not muted for both “default” and “card 1” displays . Not sure what the “default” audo device is.

Oh, it sows up as card 1? This is unexpected and the reason for your issue. What is card 0 in your case?

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
card 0: b1 [bcm2835 HDMI 1], device 1: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3

card 0 seems to be HDMI

Not sure what is going on in the background as I would think that specificaly picking the headphone in dietpi-config would set the default device to that rather than to hdmi audio. Where is the default audio device set? Maybe it could be edited to shown the headphone jack as default?

Just did a run through /etc and found asound.conf. Saw that it had the defaults as card 0. Edited the file to show card 1 as the defaults. I now have good audio. So it looks like it is a dietpi-config problem.

If I get a chance I will try the hw 0,1 option id dietpi config and see what it does to asound.conf and if it sets the default card to 0 again (seems like it should set it to card 1 as that is what you are selecting).

Ok, did play witn dietpi-config and the hw 1.0 choice does set the default card to 1 as expected. If it did not turn the onboard audio off everything would be fine. Reset the audio to the rpi headphone jack and it reset the default card in asound.conf to 0. It would appear that dietpi-config is not verifying which audio cards are actually available before setting the default card vaule in asound.conf.

1 Like

Actually selecting analoge audio should disable the HDMI audio device(s). We create a dtoverlay for this. But probably the device tree has changed with Linux 6.1. I’ll have a look.

Just to make things more interesting I now have a problem of when using the cinnamon desktop sounds app, when you try to run a speaker test there is no sound. Checked both the builtin audio (headphone jack) and a usb speaker and no sound from either. Both work just fine from the command line using speaker-test.
Just as a double check that it was not a cinnamon desktop problem, I did a fresh install (on a different ssd) of dietpi and after
the initial setup steps used dietpi software to install a mate desktop. (after verifying that .asoundrc was correct ) saw the exact same thing, onboard audio selected but no output in the spaker test using the mate audio app. Command line worked fine.

I don’t know how these desktop speaker tests work. Probably enabling the auto-conversion plugin in dietpi-config audio settings helps.

Made no difference. Guess I will move this into a new topic as the origional problem in this topic was solved with the .asoundrc edit.

Okay, the audio device tree node has gone indeed. Strangely there is a new sound node which is always disabled. However, the audio node option triggered (as well) a cmdline entry to toggle analogue and HDMI via kernel module option. It should work to use this directly:

echo 'options snd_bcm2835 enable_hdmi=0' > /etc/modprobe.d/dietpi-disable_rpi_hdmi_audio.conf

multiple errors with various complaints about this and that not available, etc. Will try to get the exact wording tomorrow.

If you mean errors when doing rmmod and modprobe, just reboot (which is what the modprobe.d config is for). This was an attempt to apply the option directly but this does not work in all cases.

Ended up not needing to do this. As I had been making lots of suggested tweaks while working on this problem I decided to do a from scratch reinstall (this a testing setup only). After finishing the first run setup script, installed cinnamon Desktop and pulseaudio. The one problem I found using dietpi-config audio soundcard selection process is that if you scroll down to hw 1,0 (rpi headphone) option is that when you finish up and reboot you find that dietpi-confign has turned the built in audio to off in config.txt. Thus there is no way to actually use this soundcard option. Not a major problem as the 2nd choice in then selection menu seems to work ok.
So at this point the only problem left is that the Cinnamon sound app does not put out any audio for a valid ausio option, But that is in another post as it does not strictly apply to this listed problem.