diff --git a/documentation/builders/components/Readme.md b/documentation/builders/components/Readme.md new file mode 100644 index 000000000..f4d109032 --- /dev/null +++ b/documentation/builders/components/Readme.md @@ -0,0 +1,3 @@ +# Phoniebox components directory + +* [Hifberry](./hifiberry.md) \ No newline at end of file diff --git a/documentation/builders/components/hifiberry.md b/documentation/builders/components/hifiberry.md new file mode 100644 index 000000000..9aa3966f3 --- /dev/null +++ b/documentation/builders/components/hifiberry.md @@ -0,0 +1,41 @@ +# HiFiBerry + +## Automatic setup + +Use this install script to enable your HiFiBerry board. + +``` +$ cd; cd ~/RPi-Jukebox-RFID/installation/components && chmod +x setup-hifiberry.sh && sudo ./setup_hifiberry.sh +``` + +## Manual steps to enable sound through HiFiBerry board + +1. Make sure your onboard sound of your Raspberry Pi is disabled. Check `/boot/config.txt`. The installation + + ``` + dtparam=audio=off + ``` + +2. Run the following command to enable HiFiBerry boards. + + ``` + echo "dtoverlay=hifiberry-dac" | sudo tee -a /boot/config.txt + ``` + +3. Enable volume control. Create or edit the following file: `sudo vi /etc/asound.conf` + + ``` + pcm.hifiberry { + type softvol + slave.pcm "plughw:0" + control.name "HifiBerry" + control.card 0 + } + + pcm.!default { + type plug + slave.pcm "hifiberry" + } + ``` + +4. Restart your device. diff --git a/installation/components/setup_hifiberry.sh b/installation/components/setup_hifiberry.sh new file mode 100644 index 000000000..305d2d23d --- /dev/null +++ b/installation/components/setup_hifiberry.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Check if the script is run as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Disable onboard sound of Raspberry Pi +echo "Disabling onboard sound..." +sed -i '/dtparam=audio=on/c\dtparam=audio=off' /boot/config.txt + +# Enable HiFiBerry board +echo "Enabling HiFiBerry board..." +grep -qxF 'dtoverlay=hifiberry-dac' /boot/config.txt || echo 'dtoverlay=hifiberry-dac' >> /boot/config.txt + +# Backup asound.conf +if [ -f /etc/asound.conf ]; then + echo "Backing up existing asound.conf..." + cp /etc/asound.conf "/etc/asound.conf.backup.$(date +%Y%m%d%H%M%S)" +fi + +echo "Configuring sound settings..." +cat > /etc/asound.conf << EOF +pcm.hifiberry { + type softvol + slave.pcm "plughw:0" + control.name "HifiBerry" + control.card 0 +} + +pcm.!default { + type plug + slave.pcm "hifiberry" +} +EOF + +echo "Configuration complete. Please restart your device."