[GH-ISSUE #258] Compile for arm6l #174

Closed
opened 2026-02-27 19:29:13 +03:00 by kerem · 10 comments
Owner

Originally created by @moodeaudio on GitHub (Oct 31, 2018).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/258

Hi,

I'm seeing "Illegal instruction" when running librespot on a 0W.

My compile procedure is below and its run it on a 3B+

sudo apt-get -y install portaudio19-dev
cd ~
git clone https://github.com/librespot-org/librespot
curl https://sh.rustup.rs -sSf | sh
NOTE: choose 1
sudo reboot
cd librespot/
cargo build --release --features alsa-backend
sudo cp target/release/librespot /usr/local/bin

Is there a cargo param for arm6l, or possibly does it need to be compiled directly on arm6l ??

-Tim

Originally created by @moodeaudio on GitHub (Oct 31, 2018). Original GitHub issue: https://github.com/librespot-org/librespot/issues/258 Hi, I'm seeing "Illegal instruction" when running librespot on a 0W. My compile procedure is below and its run it on a 3B+ sudo apt-get -y install portaudio19-dev cd ~ git clone https://github.com/librespot-org/librespot curl https://sh.rustup.rs -sSf | sh NOTE: choose 1 sudo reboot cd librespot/ cargo build --release --features alsa-backend sudo cp target/release/librespot /usr/local/bin Is there a cargo param for arm6l, or possibly does it need to be compiled directly on arm6l ?? -Tim
kerem closed this issue 2026-02-27 19:29:13 +03:00
Author
Owner

@ashthespy commented on GitHub (Oct 31, 2018):

I reckon you mean the Raspberry pi ZeroW?
With the steps you outlined above, you built it for the host processor of your device (3B+).
For the pi0, since it supports hard float, you can use the docker image to cross compile for it with:

docker build -t librespot-cross -f contrib/Dockerfile .
docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
<!-- gh-comment-id:434619236 --> @ashthespy commented on GitHub (Oct 31, 2018): I reckon you mean the Raspberry pi ZeroW? With the steps you outlined above, you built it for the host processor of your device (3B+). For the pi0, since it supports hard float, you can use the [docker image to cross compile](https://github.com/librespot-org/librespot/wiki/Cross-compiling) for it with: ```shell docker build -t librespot-cross -f contrib/Dockerfile . docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh ```
Author
Owner

@moodeaudio commented on GitHub (Oct 31, 2018):

Thanks and yes, the armv6l Pi's (1B, Zero and Zero W).

I assume that end result is separate binaries, one for armv7l and another for armv6l, correct?

<!-- gh-comment-id:434818921 --> @moodeaudio commented on GitHub (Oct 31, 2018): Thanks and yes, the armv6l Pi's (1B, Zero and Zero W). I assume that end result is separate binaries, one for armv7l and another for armv6l, correct?
Author
Owner

@kingosticks commented on GitHub (Oct 31, 2018):

The armv6 binary will work on all flavours of raspberry pi. In the same way that the foundation's raspbian does.

<!-- gh-comment-id:434838750 --> @kingosticks commented on GitHub (Oct 31, 2018): The armv6 binary will work on all flavours of raspberry pi. In the same way that the foundation's raspbian does.
Author
Owner

@moodeaudio commented on GitHub (Oct 31, 2018):

I did not know that :-0

Just performed a quick test using a librespot binary that was compiled on a Pi-ZeroW (armv6l) and indeed it runs perfectly on a Pi-3B+ :-) I suppose I should investigate the cross-compile since the little Zero W took all day to make librespot!

How are the build params specified in the docker cmd below? Just tack them on the end?
--release --features alsa-backend

docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh

<!-- gh-comment-id:434842767 --> @moodeaudio commented on GitHub (Oct 31, 2018): I did not know that :-0 Just performed a quick test using a librespot binary that was compiled on a Pi-ZeroW (armv6l) and indeed it runs perfectly on a Pi-3B+ :-) I suppose I should investigate the cross-compile since the little Zero W took all day to make librespot! How are the build params specified in the docker cmd below? Just tack them on the end? --release --features alsa-backend docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
Author
Owner

@ashthespy commented on GitHub (Oct 31, 2018):

@moodeaudio The docker image uses the foundations tool chain to build an armv6 binary with floating point support.

For your second question - I see that I have hard-coded the back-end, but it should be easy to edit it to pass in additional parameters to cargo.

<!-- gh-comment-id:434845275 --> @ashthespy commented on GitHub (Oct 31, 2018): @moodeaudio The docker image uses the [foundations tool chain](https://github.com/raspberrypi/tools/) to build an armv6 binary with floating point support. For your second question - I see that I have [hard-coded the back-end](https://github.com/librespot-org/librespot/blob/d12640fb478cc6536ae798057bbc6d1c84e0c598/contrib/docker-build-pi-armv6hf.sh#L42), but it should be easy to edit it to pass in additional parameters to cargo.
Author
Owner

@moodeaudio commented on GitHub (Oct 31, 2018):

Cool.

Is there a particular version of docker thats required?

I'm seeing version 1.5 in the the Stretch repo.

pi@rp3:/usr/local/bin $ sudo apt-get -s install docker
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
docker
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst docker (1.5-1 Raspbian:stable [armhf])
Conf docker (1.5-1 Raspbian:stable [armhf])

<!-- gh-comment-id:434862077 --> @moodeaudio commented on GitHub (Oct 31, 2018): Cool. Is there a particular version of docker thats required? I'm seeing version 1.5 in the the Stretch repo. pi@rp3:/usr/local/bin $ sudo apt-get -s install docker Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: docker 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Inst docker (1.5-1 Raspbian:stable [armhf]) Conf docker (1.5-1 Raspbian:stable [armhf])
Author
Owner

@ashthespy commented on GitHub (Oct 31, 2018):

Hmm - I see your running this all from the pi3 - then I think curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh gets you docker on the pi3 (with Raspbian).
else you need to follow the steps to add the key of the docker repo and install docker-ce

But if you ask me, I would directly cross compile from the pi3 rather than go through the docker route on that device.

<!-- gh-comment-id:434863715 --> @ashthespy commented on GitHub (Oct 31, 2018): Hmm - I see your running this all from the pi3 - then [I think](https://docs.docker.com/install/linux/docker-ce/debian/#extra-steps-for-wheezy-77) `curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh` gets you docker on the pi3 (with Raspbian). else you need to follow the steps to add the key of the docker repo and install `docker-ce` But if you ask me, I would directly cross compile from the pi3 rather than go through the docker route on that device.
Author
Owner

@moodeaudio commented on GitHub (Oct 31, 2018):

Thats what I would like to do, x-compile using the 3B+ and generate the armv6l binary which will work equally well on arm6 or 7.

But I don't have any experience with docker, cargo, rust etc., and so I'm having a bit of a time understanding the recipe.

So far, if I understand correctly

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
docker build -t librespot-cross -f contrib/Dockerfile .
docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh

And since the script "docker-build-pi-armv6hf.sh" has alsa-backend hard coded I should be god-to-go ?

<!-- gh-comment-id:434867195 --> @moodeaudio commented on GitHub (Oct 31, 2018): Thats what I would like to do, x-compile using the 3B+ and generate the armv6l binary which will work equally well on arm6 or 7. But I don't have any experience with docker, cargo, rust etc., and so I'm having a bit of a time understanding the recipe. So far, if I understand correctly curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh docker build -t librespot-cross -f contrib/Dockerfile . docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh And since the script "docker-build-pi-armv6hf.sh" has alsa-backend hard coded I should be god-to-go ?
Author
Owner

@ashthespy commented on GitHub (Oct 31, 2018):

With the docker image, you could build librespot from your x86_64 machine in a few minutes.
I have never tired it on the pi3 - but it should be along these lines:

# Install latest docker-ce on Raspbian
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
# Build the docker image (from librespot dir)
docker build -t librespot-cross -f contrib/Dockerfile .
# Cross compile for armv6hf (alsa-backend)
docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
# Resulting binary should be in /tmp/librespot-build/arm-unknown-linux-gnueabihf/release
<!-- gh-comment-id:434869215 --> @ashthespy commented on GitHub (Oct 31, 2018): With the docker image, you could build `librespot` from your `x86_64` machine in a few minutes. I have never tired it on the pi3 - but it should be along these lines: ``` # Install latest docker-ce on Raspbian curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh # Build the docker image (from librespot dir) docker build -t librespot-cross -f contrib/Dockerfile . # Cross compile for armv6hf (alsa-backend) docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh # Resulting binary should be in /tmp/librespot-build/arm-unknown-linux-gnueabihf/release ```
Author
Owner

@moodeaudio commented on GitHub (Nov 1, 2018):

Thanks, I'll give it a try in the coming days :-)

<!-- gh-comment-id:435169996 --> @moodeaudio commented on GitHub (Nov 1, 2018): Thanks, I'll give it a try in the coming days :-)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#174
No description provided.