install OS - fcorthay/RPi-multiroom-audio GitHub Wiki

The very first step is to install Raspberry Pi OS. In the present case, it is a Debian GNU/Linux 12 (bookworm).

Table of Contents

On a Linux PC

Raspberry Pi Operating System

On a PC, the Raspberry Pi Operating System (RPi OS) can be written on an SD card with the help of the Raspberry Pi Imager.

Choose Raspberry Pi OS (other) > Raspberry Pi OS Lite (64-bit) as the operating system. [1]

Next, edit settings and:

  • in the general tab :
    • set a hostname (e.g. audioAmp) which will change from one machine to the other
    • set a user name (I suggest amp) and password
    • don't configure the wireless LAN if you plan to go wired
  • in the services tab :
    • enable SSH
Save the settings and write the SD.

Partitioning

The system comes with a boot and a system partition. For backup purposes, it can be of interest to add a data partition which will contain the music files.

Also, in order to ease copying one SD card to another, one can add a swap partition at the end of the disc. With this, if the second SD card's storage is a little bit smaller as the first one, e.g. due to bad sectors, The swap partition might not be complete, but it is easy to create it again from scratch.

On the RPi

When done, insert the SD into the Raspberry Pi (RPi) board and power it on. Once the RPi powered-up, one can continue either on the RPi itself, with a keyboard and a screen, or headless via SSH. In the latter case, open a terminal window on your PC and connect (adapting the names):

 ssh [email protected]

Operating system

Update

Update the operating system:

sudo apt update
sudo apt list --upgradable 2>/dev/null | cut -d ' ' -f 1
sudo apt upgrade -y
sudo apt autoremove -y

Configuration

Configure the operating system:

sudo raspi-config
Change (as you prefer):
  • 1 System Options
    • S5 Boot / Auto Login
      • B2 Console Autologin
    • S6 Splash Screen
      • No
  • 2 Display Options
    • D2 Screen Blanking
      • No
    • D3 VNC resolution
      • 1280x720
Provide further information about the machine:
sudo hostnamectl chassis embedded
sudo hostnamectl deployment development
hostnamectl status

Swap

If there is a swap partition, one can disable the swap file:

lsblk -o name,fstype,size,label,mountpoint
swapon -s
free -k

sudo swapoff /var/swap
sudo systemctl status dphys-swapfile | cat
sudo systemctl disable dphys-swapfile
sudo rm /var/swap

Locales

Check if you have Perl warnings to avoid:

perl -e exit

If you have the warnings, edit the locales:

sudo sh -c 'echo "LC_ALL=C" >> /etc/default/locale'
. /etc/default/locale
locale
The changes will come to effect after a new login.

Group

Add the amp user to the users and audio groups:

sudo usermod -G users,audio amp
cat /etc/group | grep users
sudo chown amp:users /home/amp

Unnecessary components

Uninstall the CUPS printer server:

sudo service cups stop
sudo apt purge -y cups
sudo apt purge -y cups-common
sudo apt autoremove -y

Audio system

Loopback device

In order to pipe audio streams from one application to the other, we might want to use ALSA loopback.

Install this anyway:

sudo bash -c 'cat << EOF > /etc/modules-load.d/aloop.conf
# alsa loopback
snd
snd-timer
snd-pcm
snd-aloop
EOF'
sudo modprobe snd-aloop

This will, reveal a new sound card called Loopback.

Amplifier soundcard

In order to declare the amplifier hat as an ALSA soundcard, one usually has to edit /boot/firmware/config.txt. Yet some get automatically discovered by the RPi OS.

Check if the amplifier hat has been discovered:

aplay -l | grep ^card

If you don't find the amplifier in the list, install it as described by its manufacturer.

Check the amplifier's capacities:

AMPLIFIER_DEVICE=`aplay -l | grep ^card | grep -v Headphones | grep -v vc4hdmi | grep -v Loopback`
AMPLIFIER_SOUNDCARD_ID=`echo $AMPLIFIER_DEVICE | cut -d ' ' -f 2 | tr -d :`
AMPLIFIER_SOUNDCARD=`echo $AMPLIFIER_DEVICE | cut -d ' ' -f 3`
echo "amplifier soundcard is card $AMPLIFIER_SOUNDCARD_ID, $AMPLIFIER_SOUNDCARD"

AMPLIFIER_CAPACITIES=`aplay -v -D hw:$AMPLIFIER_SOUNDCARD --dump-hw-params /dev/zero 2>&1 | grep -iE '^format|^rate|^channels'`
echo -e "$AMPLIFIER_CAPACITIES"

Audio environment

Install the multiroom environment from the repository:

cd ~/Documents/
git clone https://github.com/fcorthay/RPi-multiroom-audio.git

Update the configuration script based on the the parameters found above:

nano ~/Documents/RPi-multiroom-audio/configuration.bash
source ~/Documents/RPi-multiroom-audio/configuration.bash

The script ~/.bash_aliases, if existing, is called by ~/.bashrc and thus run at login on the RPi. Add to it (adapt the path):

source ~/Documents/RPi-multiroom-audio/configuration.bash

Backup

Halt the RPi, remove the SD card and plug it into a card reader.

Find the disk name and adapt:

lsblk -o name,fstype,size,label,mountpoint | grep -v ^loop
RPI_DISK=sdc

Make a compressed copy of the SD card (adapt the path and name) :

BACKUP_DIRECTORY='/mnt/backup'
MACHINE_NAME='audioAmp'
dd status=progress if=/dev/$RPI_DISK | xz -9 > $BACKUP_DIRECTORY/$MACHINE_NAME.img.xz

Decompress the copy to an SD card :

xzcat $BACKUP_DIRECTORY/$MACHINE_NAME.img.xz | dd status=progress of=/dev/$RPI_DISK

Multiroom components

Continue the installation process.

Notes

  1. ^ To my first attempts, aplay -l reported no soundcards found. I solved it by choosing the full Raspberry Pi OS (64-bit) as the operating system.
⚠️ **GitHub.com Fallback** ⚠️