yrd
1
Has anyone had success in getting sound to work RPi4 devices? What I’ve tried so far:
- Adding
dtparam=audio=on
to boot.loader.raspberryPi.firmwareConfig
and rebuilding the SD image
- Manually adding the aforementioned boot option to the
config.txt
file in the boot partition
- Enabling ALSA and Pulseaudio
Nothing has helped by get a running system where aplay -L
yields more than the null
card. Is there anything I’m missing here?
I’m not positive, but I think you might have to use linuxPackages_rpi4
.
EDIT: It doesn’t look like the PWM audio driver was ever mainlined, so this is probably the case.
I had success having sound on the RPi4 jack output using this config.
All of it may not be necessary since I tried a lot of things.
{ pkgs, lib, flakeInputs, ... }:
{
imports = [
# ...
flakeInputs.nixos-hardware.nixosModules.raspberry-pi-4
];
boot = {
extraModprobeConfig = ''
options snd_bcm2835 enable_headphones=1
'';
};
hardware.raspberry-pi."4" = {
fkms-3d.enable = true;
audio.enable = true;
dwc2.enable = true;
};
hardware.pulseaudio = {
enable = true;
package = pkgs.pulseaudioFull;
};
}
I also manually added
dtparam=audio=on
in the config.txt file. But I am not sure that it is needed.
I’m pretty sure the important part of that is nixos-hardware using the kernel that I mentioned, but I could be wrong.
yrd
5
Thanks for your answers! I copied @nurelin’s config and something in there seemed to do the trick
hi @nurelin or @yrd , could you provide your full nix configuration file? I would love to get my sound to work properly on my machine thanks
yrd
7
Hey, this is the current state of my config (although I’m not actually using it at the moment, so I don’t know if it still works):
{config, pkgs, ...}: {
boot = {
loader.raspberryPi.firmwareConfig = ''
dtparam=audio=on
'';
extraModprobeConfig = ''
options snd_bcm2835 enable_headphones=1
'';
};
hardware.raspberry-pi."4" = {
fkms-3d.enable = true;
audio.enable = true;
dwc2.enable = true;
};
sound.enable = true;
systemd.services.snapclient = {
description = "Snapcast client";
wantedBy = ["multi-user.target"];
wants = ["network-online.target"];
after = ["network-online.target"];
serviceConfig = {
Type = "forking";
ExecStart = "${pkgs.snapcast}/bin/snapclient --daemon --hostID ${config.networking.hostName} -h audio.daheim.link --player alsa -s Headphones";
PIDFile = "/run/snapclient/pid";
Restart = "on-failure";
RestartSec = "5s";
DynamicUser = true;
SupplementaryGroups = "audio";
RuntimeDirectory = "snapclient";
};
};
}