The original Pi Zero W (and Zero WH) uses an ARMv6 chip. Both raspotify and prebuilt spotifyd dropped ARMv6 support years ago, and the old legacy binaries that still float around the internet are unreliable — cross-compiled versions can crash or fail to load, and stale versions eventually get rejected by Spotify’s servers. The only durable fix is compiling librespot from source, directly on the Pi. It’s slow (multiple hours on a single ARM11 core) but it’s a one-time cost and gives you a client that actually stays compatible.
1. Flash the SD card
Use Raspberry Pi Imager:
- Choose Raspberry Pi OS Lite (32-bit) — no desktop needed for a headless audio device.
- Click the gear icon (or
Ctrl+Shift+X) for advanced options and set:- Hostname (e.g.
spotifypi) - Enable SSH, set a username/password
- Wi-Fi SSID/password + correct country code
- Hostname (e.g.
- Flash, then boot the Pi.
2. Find it and SSH in
ping spotifypi.local
ssh <username>@spotifypi.local
(If .local resolution doesn’t work, check your router’s DHCP client list for the IP instead.)
3. Update the system
sudo apt update && sudo apt full-upgrade -y
sudo reboot
4. Connect and configure the USB sound card
Plug in your USB audio dongle, then confirm it’s detected:
lsusb
cat /proc/asound/cards
Note the card index (usually 0 on a fresh boot, but the Pi’s own HDMI/headphone output can sometimes claim index 0 instead — check the output rather than assuming).
Set it as the ALSA default. Using dmix here (rather than a raw hw device) means multiple programs — like this Spotify client and any other script that plays sounds — can use the sound card at the same time without fighting over exclusive access:
sudo nano /etc/asound.conf
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
}
pcm.!default {
type plug
slave.pcm "dmixer"
}
ctl.!default {
type hw
card 0
}
(Swap hw:0,0 / card 0 for whatever index cat /proc/asound/cards actually showed.)
Test it:
speaker-test -D default -c2 -t wav
5. Rule out power issues before you start a long compile
Pi Zero power budgets are tight, and a flaky USB connection or undervoltage can cause the sound card to silently drop mid-stream. Check now, so you’re not debugging it later:
vcgencmd get_throttled
0x0 = clean. Anything else means the Pi has hit undervoltage — use a proper 5V/2.5A+ power supply and a short, decent-quality USB cable if so.
6. Add swap before compiling
The Pi Zero has 512MB RAM, and compiling Rust (especially the linking stage) can exceed that. Check what you’ve got and add more if needed:
free -h
If swap is small or absent:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
7. Install the build toolchain
sudo apt install -y cargo rustc pkg-config libssl-dev libasound2-dev build-essential tmux
8. Point cargo’s temp/build directory away from /tmp
On many Raspberry Pi OS builds /tmp is a small RAM-backed tmpfs (often ~200MB), which is nowhere near enough for a Rust build. Redirect it to the SD card:
mkdir -p ~/cargo-build-tmp
9. Compile librespot inside tmux
Check first whether your terminal is already inside a tmux session (some SSH clients/terminal apps do this automatically):
echo $TMUX
- If that prints nothing, start a new session:
tmux new -s librespot-build - If it prints something, you’re already in one — just use it directly, no need to nest another.
Then run the actual build:
TMPDIR=$HOME/cargo-build-tmp cargo install librespot --locked --features alsa-backend
This will take several hours (in testing, ~13 hours on a Pi Zero W). It’ll sit quietly for long stretches — that’s normal, not a hang. If you want to double check it’s alive rather than stuck:
ps aux | grep rustc
vmstat 1 5
If rustc shows real CPU usage, it’s working. Once you’re confident it’s progressing, detach (Ctrl+B then D) and it’ll keep running in the background, surviving SSH disconnects. Reattach anytime with tmux attach -t librespot-build.
When it finishes, confirm:
~/.cargo/bin/librespot --version
10. Set up the systemd service
Create a cache directory (stores the paired session so you don’t have to reconnect from Spotify every restart):
mkdir -p ~/.cache/librespot
Create the service file:
sudo nano /etc/systemd/system/librespot.service
[Unit]
Description=Librespot Spotify Connect Client
Wants=sound.target
After=sound.target network-online.target
Wants=network-online.target
[Service]
Type=simple
User=<your-username>
ExecStart=/home/<your-username>/.cargo/bin/librespot --name "Your Device Name" --backend alsa --device default --cache /home/<your-username>/.cache/librespot --system-cache /home/<your-username>/.cache/librespot --initial-volume 70
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Replace <your-username> and the --name value. Save and exit.
Enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now librespot
sudo systemctl status librespot
It’s enabled (not just started), so it’ll come back automatically on every reboot.
11. Test it
Open Spotify on your phone or laptop (same Wi-Fi network — Zeroconf discovery relies on mDNS, which requires both devices on the same subnet with AP isolation off on your router). Tap the devices/cast icon, select your Pi by name, and hit play.
Troubleshooting notes
- “Device or resource busy” from aplay/other players: something else has the ALSA device open exclusively. This is exactly what the
dmixconfig in step 4 avoids — if you skipped it and are hitting this, switch to it. - Sound card vanishes (
cat /proc/asound/cardsshows only onboard audio): checkdmesg | tail -30for a USB disconnect event, andvcgencmd get_throttledfor undervoltage. Usually fixed by reseating the USB connector or replacing a cheap USB cable/hub. Restart any services using the device afterward (sudo systemctl restart librespot) since they may be holding a stale device handle from before the disconnect. apt installfails with unmet dependencies referencing old package names: don’t install stale prebuilt.debfiles for this architecture — that’s what led to the dependency hell this guide avoids by compiling from source on a clean system.- librespot segfaults or crashes on connect: almost always means you’re running an old/incompatible binary. Recompile with
cargo install librespot --locked --features alsa-backendfor a build built against the current protocol.