Skip to content

Instantly share code, notes, and snippets.

@BillyNate
Last active June 15, 2025 22:07
Show Gist options
  • Select an option

  • Save BillyNate/ae1779fb660e9e7bf4df7f21f701f59e to your computer and use it in GitHub Desktop.

Select an option

Save BillyNate/ae1779fb660e9e7bf4df7f21f701f59e to your computer and use it in GitHub Desktop.
Multiroom music setup on Raspberry Pi with TinyCore Linux (just RAM)

Multiroom music setup on Raspberry Pi with TinyCore Linux (RAM only OS)

These are the steps taken to have MPD on piCore 14
Newer version might work as well (or maybe even better), but have not been tested.

Set up piCore

  1. Download the piCore image
  2. Unpack the .zip file and write the .img file to the SD-Card (using USB Image Tool for example)
  3. Move the SD-Card to the Pi, plug the Pi into the network and plug in the power source
  4. SSH into the Pi (using Putty for example)
    Login using tc / piCore
  5. Execute backup shell command after the first boot to save generated unique SSH keys which will be used during next boots.
  6. Expand the partition:
    1. Start the partition tool: sudo fdisk -u /dev/mmcblk0
    2. List partitions with p command and write down the StartLBA and EndLBA of the second partition
    3. Delete second partition with d than recreate it with n command
      Select p for Primary Partition and 2 for Partition Number
      Use the same starting sector as deleted had and use the default value for Last Cylinder
      Exit fdisk with w command
    4. Reboot the Pi: sudo reboot
    5. After reboot expand the partition: sudo resize2fs /dev/mmcblk0p2 (may take a while)
  7. Optionally install the nano text editor (or keep using vi): tce-load -wi nano
  8. Install ALSA: tce-load -wi alsa alsa-utils
  9. Install tools to create extensions tce-load -wi squashfs-tools

Configure ALSA

  1. Configure ALSA: sudo alsamixer
  2. Save config: sudo alsactl store
  3. Add the following lines to /opt/.filetool.lst:
    etc/asound.conf
  4. Add alsactl restore to /opt/bootlocal.sh
  5. Save changes to ROM: backup

Install MPD

  1. Install compiler: tce-load -wi compiletc meson ninja
  2. Install dependencies: tce-load -wi boost-dev cmake curl-dev dbus-dev expat2-dev faad2-dev git glib2-dev icu-dev lame-dev libfmt-dev libgcrypt-dev libid3tag-dev libmad-dev libsndfile-dev mpg123-dev sqlite3-dev
  3. Fix libid3tag:
    1. Create a temporary directory: mkdir -p /tmp/libid3tagExt/usr/local/lib/pkgconfig
    2. Unpack package: unsquashfs -d /tmp/libid3tagExt /mnt/mmcblk0p2/tce/optional/libid3tag-dev.tcz
    3. Create /tmp/libid3tagExt/usr/local/lib/pkgconfig/id3tag.pc containing:
      prefix=/usr/local
      exec_prefix=${prefix}
      libdir=${exec_prefix}/lib
      includedir=${prefix}/include
      
      Name: id3tag
      Description: ID3 tag reading library
      Version: 0.17
      Requires:
      Libs: -L${libdir} -lid3tag
      Cflags: -I${includedir}
      
    4. Remove exisiting package: rm /mnt/mmcblk0p2/tce/optional/libid3tag-dev.tcz
    5. Repack new package: mksquashfs /tmp/libid3tagExt /mnt/mmcblk0p2/tce/optional/libid3tag-dev.tcz
  4. Reboot: sudo reboot
  5. Install libmpdclient:
    1. Download the latest tarball for libmpdclient from https://github.com/MusicPlayerDaemon/libmpdclient/tags, for example: wget https://github.com/MusicPlayerDaemon/libmpdclient/archive/refs/tags/v2.22.tar.gz -O libmpdclient-2.22.tar.gz
    2. Unpack the tarball: tar -xvzf libmpdclient-*.tar.gz
    3. Go into the unpacked directory: cd libmpdclient*
    4. Configure the source tree: meson setup output
    5. Compile: ninja -C output
    6. Install libmpdclient into temporary directory: DESTDIR=/tmp/libmpdclientExt ninja -C output install
    7. Create extension: mksquashfs /tmp/libmpdclientExt /mnt/mmcblk0p2/tce/optional/libmpdclient.tcz
    8. Add libmpdclient.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  6. Install MPD:
    1. Download a tarball from https://www.musicpd.org/download/mpd, for example: wget https://www.musicpd.org/download/mpd/0.23/mpd-0.23.15.tar.xz -O mpd-0.23.15.tar.xz
    2. Unpack the tarball: tar -Jxvf mpd-*.tar.xz
    3. Go into the unpacked directory: cd mpd*
    4. Configure the source tree: meson setup output/release --buildtype=release --prefix=/usr/local -Dlibmpdclient=enabled -Dadplug=disabled -Dao=disabled -Dbzip2=disabled -Ddsd=false -Dffmpeg=disabled -Dfluidsynth=disabled -Dgme=disabled -Did3tag=enabled -Dipv6=disabled -Djack=disabled -Dmikmod=disabled -Dmms=disabled -Dmodplug=disabled -Dmpcdec=disabled -Dnfs=disabled -Dopenal=disabled -Dopus=disabled -Doss=disabled -Dpipe=false -Dpulse=disabled -Drecorder=false -Dshine=disabled -Dshout=disabled -Dsidplay=disabled -Dsmbclient=disabled -Dsoundcloud=disabled -Dsoxr=disabled -Dtwolame=disabled -Dupnp=disabled -Dwavpack=disabled -Dwave_encoder=false -Dwildmidi=disabled -Dzzip=disabled -Dzeroconf=disabled
    5. Compile: ninja -C output/release
    6. Create a temporary directory: mkdir -p /tmp/mpdExt/usr/local/etc
    7. Install mpd into temporary directory: DESTDIR=/tmp/mpdExt ninja -C output/release install
    8. Copy config: cp doc/mpdconf.example /tmp/mpdExt/usr/local/etc/mpd.conf
    9. Create extension: mksquashfs /tmp/mpdExt /mnt/mmcblk0p2/tce/optional/mpd.tcz
    10. Add mpd.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  7. Reboot: sudo reboot
  8. Create config directory: mkdir ~/.mpd
  9. Copy over config: cp /usr/local/etc/mpd.conf ~/.mpd/mpd.conf, or to another filename if you're going to run multiple MPD instances
  10. Make some changes to the config:
    1. Enable the log_file & pid_file (remove the # at the start of the line)
    2. Change the name of the log_file and the pid_file if you're going to run multiple MPD instances
    3. Enable user and group and set it to tc and staff respectively
    4. Change port if necessary
    5. Add as many audio_output as locations you want to stream to:
      audio_output {
          type         "snapcast"  # outpouts in a way SnapClients can connect to the audio stream
          name         "location"  # name of the location this stream will be used
          port         "1704"      # unique port number
          format       "44100:16:2"
          mixer_type   "software"
      }
      
    6. Run mpd once to test and to create a database file: mpd ~/.mpd/mpd.conf (and mpd --kill after a little while)
    7. Enable the db_file in the config (remove the # at the start of the line)
  11. Have MPD auto start on boot: sudo nano /opt/bootlocal.sh, add mpd /home/tc/.mpd/mpd.conf to the end
  12. Save the changes: backup
  13. Reboot: sudo reboot

Accessing NAS share

  1. Install cifs: tce-load -wi cifs-utils samba4 filesystems-KERNEL

  2. Create a file containing the login credentials of the share /home/tc/.smb:

    user=username
    password=xxxxxx
    
  3. Add a line to /etc/fstab: //192.168.x.xxx/sharedfolder /mnt/shared cifs credentials=/home/tc/.smb,vers=1.0 0 0

  4. Make fstab saved by adding etc/fstab to /opt/.filetool.lst

  5. Create a script for mounting /opt/mount.sh:

    #!/bin/sh
    mkdir /mnt/shared
    until cat /etc/fstab | grep shared
    do
      sleep 1
    done
    sleep 5
    mount /mnt/shared
    
  6. Give the script execution rights: sudo chmod +x /opt/mount.sh

  7. Add the script to /opt/bootlocal.sh: /opt/mount.sh &

  8. Save the changes: backup

  9. Reboot: sudo reboot

Connecting it all together

  1. Set the correct library location in ~/.mpd/mpd.conf: music_directory "/mnt/shared"

Exclude files from filetool back-up

  1. Add some lines to /opt/.xfiletool.lst:
    home/tc/.mpd/log*
    home/tc/.mpd/pid*
@BillyNate
Copy link
Author

@BillyNate
Copy link
Author

According to https://wiki.archlinux.org/title/Music_Player_Daemon/Tips_and_tricks#Configuration_2 there's an easier way of accessing the SMB share....

@BillyNate
Copy link
Author

MPD might not compile, because libid3tag doesn't have the file needed for pkgconfig.
By downloading a proper .tc file into /usr/local/lib/pkgconfig (for example http://slackware.cs.utah.edu/pub/slackware/slackware-current/source/l/libid3tag/id3tag.pc) and updating the paths in the file, this should be solved.

@BillyNate
Copy link
Author

This might be of interest to stitch the multiple outputs together better: snapcast/snapcast#65 (comment)

@mrkbbk
Copy link

mrkbbk commented Sep 10, 2022

Great work, thanks!
It seams the tce-load -wi liblz4 is missing, though

@BillyNate
Copy link
Author

Great work, thanks! It seams the tce-load -wi liblz4 is missing, though

Thanks! It's probably not perfect indeed. I wrote this just in case I needed to go through it again some time πŸ˜‰
Good to hear someone else got some use out if it! πŸ‘
At what point were you missing the liblz4? Cause I don't remember running into that, and I'd like to know in case I missed something or run into a missing dependency in the future πŸ˜„

@JaMa-95
Copy link

JaMa-95 commented Nov 9, 2024

Hi, nice work. Unfortunately i get this error at step 6.v:
FAILED: src/tag/libtag.a.p/Id3Load.cxx.o
c++ -Isrc/tag/libtag.a.p -Isrc/tag -I../../src/tag -Isrc -I../../src -I. -I../.. -I/usr/local/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c++17 -O3 -ffast-math -ftree-vectorize -Wcast-qual -Wdouble-promotion -Wmissing-declarations -Wshadow -Wunused -Wvla -Wwrite-strings -Wno-stringop-overflow -fno-threadsafe-statics -fmerge-all-constants -Wcomma-subscript -Wextra-semi -Wmismatched-tags -Woverloaded-virtual -Wsign-promo -Wvolatile -Wvirtual-inheritance -Wno-non-virtual-dtor -Wsuggest-override -fvisibility=hidden -ffunction-sections -fdata-sections -D_GNU_SOURCE -fPIC -MD -MQ src/tag/libtag.a.p/Id3Load.cxx.o -MF src/tag/libtag.a.p/Id3Load.cxx.o.d -o src/tag/libtag.a.p/Id3Load.cxx.o -c ../../src/tag/Id3Load.cxx
In file included from ../../src/tag/Id3Load.hxx:23,
from ../../src/tag/Id3Load.cxx:20:
../../src/tag/Id3Unique.hxx:23:10: fatal error: id3tag.h: No such file or directory
23 | #include <id3tag.h>

Any idea?
Tried with piCore 14.1 and 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment