Mopidy on Edison

DSC03616

Usually I use a wide variety of devices capable of running the Mopidy music server, such as Raspberry Pi, Minnowboard Max and NUC. I acquired an Edison Mini Breakout Board kit, since the board has a quite small form factor it seemed a perfect fit for a very tiny music server. 🙂

What you need:
1) An Edison board.
2) A USB DAC.
3) An AC/DC adapter (or battery). Normally the Edison board can be powered over USB, but USB host mode requires use of external power. It needs to provide 7-15V 1.5A. For AC/DC adapter use the J21 connector, for battery use the J2 connector, on the Edison board. Make sure the + and GND are connected correctly (otherwise the board may break). For further details on the power setup see page 7 in Intel® Edison Breakout Board Hardware Guide.
4) If your USB DAC only has non-micro USB connector; a USB-female to USB micro adapter (a USB OTG cable also works).

Normally Edison runs Yocto, but currently I will run Mopidy in Ubilinux. Ubilinux is based on Debian which means support for the Debian package manager.

To flash the Edison with Ubilinux download the latest image from ubilinux.org . I used ubilinux for Intel® Edison. There is a very good guide on how to flash and configure ubilinux here: https://learn.sparkfun.com/tutorials/loading-debian-ubilinux-on-the-edison . Make sure to follow the instructions for flashing ubilinux in the link above, otherwise your device may be bricked.

I used Linux as host. When ubilinux has been flashed and waiting for login, follow these steps to install and setup Mopidy on Edison:

Connect over serial using one of the USB connections, and login as root (the default password is: edison):

anders@nuc:~$ sudo screen /dev/ttyUSB0 115200

Add user:

root@ubilinux:~$ adduser --ingroup users [username]

Change the default root password:

root@ubilinux:~$ passwd

Remove default edison user:

root@ubilinux:~$ deluser --remove-home edison

Configure WiFi:

root@ubilinux:~$ chmod 0600 /etc/network/interfaces
root@ubilinux:~$ wpa_passphrase [SSID] [WLAN password]

In /etc/network/interfaces, comment out usb, uncomment wlan0, and for wlan0 set SSID and PSK (the passphrase generated by the command above)

root@ubilinux:~$ nano /etc/network/interfaces
root@ubilinux:~$ ifup wlan0
root@ubilinux:~$ ifconfig

Set hostname:

root@ubilinux:~$ nano /etc/hostname

Also add hostname for localhost in /etc/hosts, e.g 127.0.0.1 localhost anders-edison

root@ubilinux:~$ nano /etc/hosts
root@ubilinux:~$ reboot

Enable avahi:
In /etc/avahi/avahi-daemon.conf add wlan0 as: allow-interfaces=wlan0,eth0

root@anders-edison:~$ nano /etc/avahi/avahi-daemon.conf

Free some fs space in / (required by apt):
To much stuff in /

root@anders-edison:/usr# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.4G 812M 504M 62% /
/dev/root 1.4G 812M 504M 62% /
devtmpfs 480M 0 480M 0% /dev
tmpfs 97M 304K 96M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 193M 0 193M 0% /run/shm
tmpfs 481M 0 481M 0% /tmp
/dev/mmcblk0p7 32M 5.3M 27M 17% /boot
/dev/mmcblk0p10 1.3G 2.1M 1.3G 1% /home

As suggested here https://github.com/catmaker/chippy/wiki/Upgrading-Ubilinux-Debian-Wheezy-to-Jessie, move /usr/share from / to /home partition:

root@anders-edison:~$ cd /usr
root@anders-edison:/usr$ cp -rp share /home
root@anders-edison:/usr$ mv share share.orig
root@anders-edison:/usr$ ln -sf /home/share

[reboot and check]

root@anders-edison:~$ cd /usr
root@anders-edison:/usr$ rm -rf share.orig [Ulp!]

Now more space available in / :

root@anders-edison:/usr# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.4G 589M 727M 45% /
/dev/root 1.4G 589M 727M 45% /
devtmpfs 480M 0 480M 0% /dev
tmpfs 97M 300K 96M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 193M 0 193M 0% /run/shm
tmpfs 481M 0 481M 0% /tmp
/dev/mmcblk0p7 32M 5.3M 27M 17% /boot
/dev/mmcblk0p10 1.3G 226M 1.1G 18% /home

Update apt:

root@anders-edison:~$ apt-get update

Add sudo, logout root and login as regular user:

root@anders-edison:~$ apt-get install sudo
root@anders-edison:~$ adduser [username] sudo

Add alsa-utils:

anders@anders-edison:~$ sudo apt-get install alsa-utils

Add user to audio group:

anders@anders-edison:~$ sudo adduser audio [username]

Connect the USB DAC to the USB port and verify that it can be recognised:

anders@anders-edison:~$ cat /proc/asound/cards
0 [Loopback ]: Loopback - Loopback
Loopback 1
1 [DAC ]: USB-Audio - USB Audio DAC
Burr-Brown from TI USB Audio DAC at usb-dwc3-host.2-1, full speed

Add Mopidy:

anders@anders-edison:~$ wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -

For debian wheezy:

anders@anders-edison:~$ sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/wheezy.list
anders@anders-edison:~$ sudo apt-get update
anders@anders-edison:~$ sudo apt-get install mopidy=1.1.2-1

For debian jessie:

anders@anders-edison:~$ sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
anders@anders-edison:~$ sudo apt-get update
anders@anders-edison:~$ sudo apt-get install mopidy

Add Mopidy-Spotify:

anders@anders-edison:~$ apt-cache search mopidy

For debian wheezy:

anders@anders-edison:~$ sudo apt-get install mopidy-spotify=2.3.1-0mopidy1

For debian jessie:

anders@anders-edison:~$ sudo apt-get install mopidy-spotify

Add Mopidy-Alsamixer (required since USB DAC will be used):

anders@anders-edison:~$ sudo apt-get install mopidy-alsamixer

Configure Mopidy and extensions:
See https://docs.mopidy.com/en/latest/config/
In ~/.config/mopidy/mopidy.conf edit the sections alsamixer, audio, software mixer, http and spotify according to following:

mopidyconfig_small

Add screen (to keep mopidy running even if terminal ssh session is closed)

anders@anders-edison:~$ sudo apt-get install screen
anders@anders-edison:~$ screen

Start mopidy:

anders@anders-edison:~$ mopidy

Then use any Mopidy HTTP client to control the music server, for instance Remotedy: https://play.google.com/store/apps/details?id=se.anil.remotedy

Leave a Reply

Your email address will not be published. Required fields are marked *