Follow

Configuring Linux 4.x or higher

With Linux 3.18 (or higher) a new way to load device drivers have been introduced to the Raspberry Pi environment. It is called device tree overlay. This brings big changes to the way how to configure the necessary drivers for the HiFiBerry boards.

Remove the driver for the onboard sound

Remove the line

dtparam=audio=on

from /boot/config.txt if it exists.

Configure device tree overlay file

You don’t have to edit /etc/modules anymore, but need to load the correct device tree file. To do this, you must edit /boot/config.txt and add the following line

DAC for Raspberry Pi 1/DAC+ Light/DAC Zero/MiniAmp

dtoverlay=hifiberry-dac

DAC+ standard/pro

dtoverlay=hifiberry-dacplus

Digi/Digi+ all models

dtoverlay=hifiberry-digi

Amp+

dtoverlay=hifiberry-amp

In the future it will be possible to automatically detect the DAC+/Digi+ boards based on the information stored in the EEPROM on the card. However we need to implement this first.

Configure ALSA (optional)

Create /etc/asound.conf with the following content:

pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}

Make sure you have no .asound.conf file with different settings in your home directory (you might simply delete it if there is one). Reboot again now. 

Test it

Check, if the sound card is enabled with “aplay”:

pi@raspberrypi ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

This should work as root but also with the default "pi" user of Raspbian. If you created another user, make sure it is part of the "audio" group, otherwise it won't be able to access the sound card and aplay won't list it.

You can use aplay, to playback a WAV file. Note that aplayer won’t convert files that are in a format that is not natively supported from our drivers. (e.g. mono files or different sample rates). For other file formats (MP3, FLAC, …) We recommend to use mplayer.

sudo apt-get install mplayer

Some users have reported problems with MP3 playback of mplayer. It seems, that the MP3 codec is not installed by default on all systems. We found the FLAC format to be best supported by mplayer.

Depending of the board you’re using it will show another HiFiBerry sound card (DAC,DAC+, Digi or Amp)

Device not recognised?

This could be caused by typos in config.txt or blacklisted drivers. Add

dtdebug=1

to your config.txt. Have a look at the output of

dmesg

and the output of

sudo vcdbg log msg

.

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Chester H Berry

    Perhaps this is out of the scope of this article, but I'd appreciate some indication as to how the HiFiDigi+ card is configured (or perhaps more properly, how Linux is configured) for 7.1 surround sound. Is there a line that must be added to the /etc/asound.conf file (such as "channels = 8") that will cause ALSA to recognize that there are eight channels available in this sound card?

    Any help, including reading suggestions, MOST welcome!
    Thanks!

  • Avatar
    HiFiBerry team

    You can't configure the Digi+ for 7.1 sound. This is a 2-channel sound card. 5.1 or 7.1 needs Dolby Digital or DTS encoding, this isn't part of the Linux kernel (and most likely will never be due to licensing).

    Best regards
    Daniel

  • Avatar
    pander

    Please, contribute to https://github.com/RPi-Distro/raspi-config/issues/14 for ease of installation.

    Linux with 5.1 or 7.1 should be possible, but you have to dive deep into ALSA and probably PulseAudio.