Skip to content

Instantly share code, notes, and snippets.

@estshorter
Last active August 16, 2021 07:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estshorter/7361be59368466690b0217075fab25f1 to your computer and use it in GitHub Desktop.
Save estshorter/7361be59368466690b0217075fab25f1 to your computer and use it in GitHub Desktop.
Auto-setup of Minimum Raspbian for Music

Assumption

  • Raspberry Pi 3 only (due to optimization option)
  • OS: Raspbian stretch (2017-11-29)
  • Music format: mp3, m4a, flac (no dsd)
  • Play music stored in a NAS via wired lan (no usb)
  • Scrobble to last.fm
  • I2S DAC: Hifiberry DAC+ Pro compatible board
  • For Japanese (NTP, timezone and language setting)
  • Network: dhcp, wired lan
  • Write the raspbian image on Windows

Download image

Mirror on Japan

Write image

Use etcher

Enable ssh

Create a file named ssh on the root folder

  • user: pi
  • pass: raspberry

Minimum raspbian setting for Music

Setting overview

The following are configured automatically.

  • Build the latest alsa-lib, libflac, mpg123, FFmpeg and MPD with optimization options for Raspberry Pi 3
  • Specify high priority to MPD tasks
  • Turn off the power led after initialization
  • Provide cover art via http using nginx
  • Scrobble to last.fm using mpdas
  • Disable swap, HDMI, Wi-Fi, Bluetooth, UART, onboard audio, usb-power and unnecessary service
  • Put temp and log files to RAM disk
  • Decrease GPU assigned memory
  • Suppress rsyslog and nginx output
  • Specify NTP server, timezone and language for Japanese
  • Configure NAS

Setting script

Download files:

mkdir ~/setup
cd ~/setup
wget https://gist.githubusercontent.com/estshorter/302449b697c1468bcfdb0bf31ed3b35e/raw -O ./setup.sh
chmod u+x ./setup.sh

File urls:

Execute all scripts:

Note: specify NAS_USER, NAS_PASS, NAS_ADDR, LAST_FM_USER, LAST_FM_PASS before third executing.

cd ~/setup
./setup.sh
sudo reboot

cd ~/setup
./setup.sh
sudo reboot

export NAS_USER=user
export NAS_PASS='pass'
export NAS_ADDR=addr
export LAST_FM_USER=user
export LAST_FM_PASS='pass'

cd ~/setup
./setup.sh
sudo reboot

Note: I'm afraid most references in the scripts are written in Japanese.

Optional scripts

Disable LEDs

One time

#!/bin/bash -e
echo none | sudo tee /sys/class/leds/led0/trigger > /dev/null # disable green led
echo none | sudo tee /sys/class/leds/led1/trigger > /dev/null # disable red led
echo 0 | sudo tee /sys/class/leds/led1/brightness > /dev/null

Forever

#!/bin/bash -ue
GREEN_LED_CMD="dtparam=act_led_trigger=none
dtoverlay=pi3-act-led,activelow=on"

echo "${GREEN_LED_CMD}" | sudo tee -a /boot/config.txt > /dev/null
echo "dtparam=pwr_led_trigger=none,pwr_led_activelow=on" | sudo tee -a /boot/config.txt > /dev/null

Ref: https://azriton.github.io/2017/09/20/Raspberry-Pi%E5%9F%BA%E7%9B%A4%E3%81%AELED%E3%82%92%E6%B6%88%E7%81%AF%E3%81%99%E3%82%8B/

Overclocking

For CPU/GPU

For SD card

Use the latest kernel

sudo rpi-update

Install upmpdcli

Create and edit /etc/apt/sources.list.d/upmpdcli.list and add the following lines.

deb http://www.lesbonscomptes.com/upmpdcli/downloads/raspbian-stretch/ stretch main
deb-src http://www.lesbonscomptes.com/upmpdcli/downloads/raspbian-stretch/ stretch main

Setup:

sudo apt -y install dirmngr
gpg --keyserver pool.sks-keyservers.net --recv-key 'F8E3 3472 5692 2A8A E767 605B 7808 CE96 D38B 9201'
gpg --export '7808CE96D38B9201' | sudo apt-key add -
sudo apt -y update
sudo apt -y install upmpdcli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment