Welcome! Log In Create A New Profile

Advanced

[help request] Librespot/Spotify Connect on Pogoplug Pro

Posted by cdlenfert 
[help request] Librespot/Spotify Connect on Pogoplug Pro
July 17, 2019 12:12PM
I'm interested in adding Spotify Connect functionality to my Pogoplug. For those who are not familiar, Spotify Connect allows your device (the pogo in this case) to show up as a remote speaker from within the Spotify App (on your computer or phone). You can play anything in the Spotify ecosystem to your Spotify Connect device and the audio gets pulled directly from Spotify servers. So you could shut your device off, go out of range, etc and the music keeps on playing.

I'm most interested in running this fork of Librespot which includes Metadata Pipe support. Buy outputting the audio and metadata from Librespot to a pipe, a program I'm running called Forked-Daapd can pick that up automatically and stream the tunes to any of my Airplay/Shairport-sync wireless speakers. The metadata would then populate the web interface for Forked-daapd or the Apple Remote app, allowing for easy volume control and nice cover art/titles/etc.

The problem is, Librespot requires Rust to be installed in order to build. When I try installing Rust I get the following:
curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Illegal instruction

Any advice on next steps I can take to troubleshoot the installation would be much appreciated. I'd love to convert this help request into a how-to in the future :)



Edited 1 time(s). Last edit at 07/18/2019 09:56AM by cdlenfert.
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 18, 2019 12:14AM
cdlenfert,

I did not see armv6 armel option in the rustup script. So I checked their website, armv6l is supported:

https://forge.rust-lang.org/platform-support.html

Quote

Tier 2
Tier 2 platforms can be thought of as “guaranteed to build”. Automated tests are not run so it’s not guaranteed to produce a working build, but platforms often work to quite a good degree and patches are always welcome! Specifically, these platforms are required to have each of the following:

Official binary releases are provided for the platform.
Automated building is set up, but may not be running tests.
Landing changes to the rust-lang/rust repository’s master branch is gated on platforms building. For some platforms only the standard library is compiled, but for others rustc and cargo are too.
target std rustc cargo notes
....
....
arm-unknown-linux-gnueabi ✓ ✓ ✓ ARMv6 Linux
arm-unknown-linux-gnueabihf ✓ ✓ ✓ ARMv6 Linux, hardfloat
arm-unknown-linux-musleabi ✓ ARMv6 Linux with MUSL
arm-unknown-linux-musleabihf ✓ ARMv6 Linux, MUSL, hardfloat
...
...


Ideas:

1. Cross-compiling Librespot fork on a x86 laptop running Mint/Ubuntu.

or

2. If you have another ARM box that use armv7 (e.g rPi), then you can do native compile (using arm-unknown-linux-gnueabi).

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 18, 2019 10:00AM
Thanks for the reply. I have a rPi that I could install RUST on, so "idea 2" sounds like a good way to proceed. Is the idea that if I build Librespot on the Pi, I'll get a deb file that I can install/run on the Pogo? I updated my original post with a link to the fork I'm interested in using (also added below).

https://github.com/billsq/librespot

Is there a way to tell if this will run on the Pogo other than build/install/test? I don't see much mention of specific supported architectures in the repo.
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 25, 2019 11:27AM
So I managed to get Rust installed on a PiZero W at the office.

curl https://sh.rustup.rs -sSf | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust programming 
language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to Cargo's bin 
directory, located at:

  /root/.cargo/bin

This path will then be added to your PATH environment variable by modifying the
profile file located at:

  /root/.profile

You can uninstall at any time with rustup self uninstall and these changes will
be reverted.

Current installation options:

   default host triple: arm-unknown-linux-gnueabihf
     default toolchain: stable
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: syncing channel updates for 'stable-arm-unknown-linux-gnueabihf'
info: latest update on 2019-07-04, rust version 1.36.0 (a53f9df32 2019-07-03)
info: downloading component 'rustc'
 73.6 MiB /  73.6 MiB (100 %)   2.4 MiB/s in 36s ETA:  0s
info: downloading component 'rust-std'
 65.1 MiB /  65.1 MiB (100 %)   2.7 MiB/s in 31s ETA:  0s
info: downloading component 'cargo'
  4.1 MiB /   4.1 MiB (100 %)   1.6 MiB/s in  3s ETA:  0s
info: installing component 'rustc'
 73.6 MiB /  73.6 MiB (100 %) 875.2 KiB/s in  1m  6s ETA:  0s
info: installing component 'rust-std'
 65.1 MiB /  65.1 MiB (100 %)   1.6 MiB/s in 48s ETA:  0s
info: installing component 'cargo'
  4.1 MiB /   4.1 MiB (100 %)   1.2 MiB/s in  5s ETA:  0s
info: default toolchain set to 'stable'

  stable installed - rustc 1.36.0 (a53f9df32 2019-07-03)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH 
environment variable. Next time you log in this will be done automatically.

To configure your current shell run source $HOME/.cargo/env


I made sure that dependencies were installed (they already were).
root@moode:/home/pi# source $HOME/.cargo/env
root@moode:/home/pi# apt-get install build-essential libasound2-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.3).
libasound2-dev is already the newest version (1.1.3-5+rpi3).
0 upgraded, 0 newly installed, 0 to remove and 42 not upgraded.

I attempted to build directly instead of using the docker container to cross compile. I got the command below from the cross-compile instructions in the wiki:
root@moode:/home/pi/librespot# cargo build --release --target arm-unknown-linux-gnueabi

I hit an error in compiling:
error[E0463]: can't find crate for `std`
  |
  = note: the `arm-unknown-linux-gnueabi` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rand_core`.

To learn more, run the command again with --verbose.
root@moode:/home/pi/librespot# rustc --explain E0463

Here is a summary of the error
A plugin/crate was declared but cannot be found. Erroneous code example:

```
#![feature(plugin)]
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
```

You need to link your code to the relevant crate in order to be able to use it
(through Cargo or the `-L` option of rustc example). Plugins are crates as
well, and you link to them the same way.

Maybe I'm using the wrong command (the standard command is just cargo build --release)? Maybe I need to use the docker image and cross compile?
If I get the "arm-unknown-linux-gnueabi" binary compiled on my Pi Zero, how do I run it on my Pogo Pro?
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 26, 2019 12:17AM
cdlenfert,

I'm not familiar with what you trying to do, so it's best that others should chime in.

However,

Regarding arm-unknown-linux-gnueabi, look inside the rustup script to see toolchain options

OPTIONS:
        --default-host <default-host>              Choose a default host triple
        --default-toolchain <default-toolchain>    Choose a default toolchain to install
        --default-toolchain none                   Do not install any toolchains

You have selected (by default)
default host triple: arm-unknown-linux-gnueabihf

So try this to see if it is compiled:
cargo build --release --target arm-unknown-linux-gnueabihf

And then back to the rustup script to figure out how to get arm-unknown-linux-gnueabi.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 26, 2019 11:41AM
thanks bodhi. I'm not very familiar either :P

However due to the extreme slowness of the Pi Zero building librespot I looked around for alternatives. Cross compiling as you mentions initially, but instead of using a Linux device I used a Docker image on my Mac via the instructions here - https://github.com/librespot-org/librespot/wiki/Cross-compiling

Building with Alsa on the Mac failed for some reason but I only need pipe output from librespot so I went with this command:
docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features

That took about 5 minutes and then I scp'd the built librespot directory over to my Pogo.
scp -r /private/tmp/librespot-build root@debian.local:~/

Next I set up my pipes (one for the audio and one for metadata)
mkfifo /home/share/librepipe
mkfifo /home/share/librepipe.metadata

Then from the /librespot-build/arm-unknown-linux-gnueabi/release directory (where the librespot binary lives) I ran:
./librespot -n "Hiveify" -u "myusername" -p "mypassword" --backend pipe --device "/home/share/librepipe" --initial-volume "100"

You may notice there's no reference to the metadata pipe in that command. Even though I cloned down billsq's repo before I ran the docker build command above. I'm guessing I just built it wrong or needed to include some flag.

The end result of the current setup is that I can pull up the Spotify app on my phone or mac and see my Pogo in a list of devices that I can playback on (via Spotify connect). Then Forked-daapd grabs the piped audio and can play it locally on the sound card attached to the Pogo, or stream it to several airplay speakers in sync. Pretty amazing!! Metadata would be icing on the cake.

Edit: After a handful of songs in the connection drops or Librespot hangs. Doesn't seem like resources are being exhausted when I look at htop.



Edited 3 time(s). Last edit at 07/26/2019 12:10PM by cdlenfert.
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 29, 2019 11:18AM
Quick update:
I found the disconnection issue was indeed not related to resources (at least as far as I can tell). Seems to be a pretty big issue with the project as a whole - https://github.com/librespot-org/librespot/issues/134

I've also found when trying to run the same "arm-unknown-linux-gnueabi" build on my PogoPlug E-02 model I just get an immediate "Illegal instruction". I'm surprised that librespot can run on the Pro but not the E-02. Any insight into why this might be? The only thing I can think of is that floating-point is mentioned and maybe that's the difference on the 2 pogos chips? https://forum.doozan.com/read.php?8,25244,25246,quote=1 and https://github.com/librespot-org/librespot/wiki/Cross-compiling (mentions a flag if floating point is not supported). Am I on the right track?
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 29, 2019 12:24PM
> I've also found when trying to run the same
> "arm-unknown-linux-gnueabi" build on my PogoPlug
> E-02 model I just get an immediate "Illegal
> instruction". I'm surprised that librespot can run
> on the Pro but not the E-02. Any insight into why
> this might be?

Yes, that error would make sense (Pogo Pro is armv6l). The Pogo E02 is Kirkwood, armv5te. So eihter one of these compilers must be used.

armv5te-unknown-linux-gnueabi	ARMv5TE Linux
armv5te-unknown-linux-musleabi	ARMv5TE Linux with MUSL

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 29, 2019 12:26PM
Where did you find those? Are you some kind of Google-wizard??

Edit: When I use the cross compiler and try the command:
docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target armv5te-unknown-linux-gnueabi --no-default-features --features with-tremor
I get an error:
error[E0463]: can't find crate for `core`
  |
  = note: the `armv5te-unknown-linux-musleabi` target may not be installed
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `lazy_static`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `rand_core`.

I didn't find any reference to armv5 in the librespot github docs, however some issues from a couple of years ago show people building for armv5. Maybe they've deprecated it?



Edited 1 time(s). Last edit at 07/29/2019 12:46PM by cdlenfert.
Re: [help request] Librespot/Spotify Connect on Pogoplug Pro
July 29, 2019 11:28PM
cdlenfert,

> Where did you find those?

It is in from your link :)

Looks like they have removed armv5te from the script:
https://sh.rustup.rs

But Rust website show the patform support (don't know how up-to-date this list is):
https://forge.rust-lang.org/platform-support.html

> I didn't find any reference to armv5 in the
> librespot github docs, however some issues from a
> couple of years ago show people building for
> armv5. Maybe they've deprecated it?

Probably, there was some issue with armv5te in the past.

-bodhi
===========================
Forum Wiki
bodhi's corner
Author:

Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: