Cross compiling for Turris Omnia

Hi.
I’m trying to create an environment in which I’ll be able to cross-compile different programs (eg. Pillow, ImageMagick, Gotify, mitmproxy) for my Turris Omnia 2 with OS 3.11.16 and Kernel 4.4.199. I’m totally new to linux compiling, so cross-compiling is for me a brainf*ck. I already spent hours in searching for a proper, understandable-for-me tutorial, no success yet. I have access to both Win10 and Debian machine, so I can use one of them for creating this environment.

After some research into the subject, I was advised that maybe the best solution would be to download the already-prepared env inside a Docker container. I also know that I might have later additional problems with musl library.

So recently I found this stuff: https://github.com/dockcross/dockcross, it looks like it might be a good fit for my endeavour. But I have some question marks here.

As far I understand, my Omnia has these properties:

  • Target: mvebu
  • Subtarget: cortexa9
  • Package architecture: arm_cortex-a9_vfpv3
  • CPU: Marvell Armada 385 88F6820
  • uname -a shows: armv7l

So which of the docker images from the dockcross will be the best fit?

  1. dockcross/linux-armv5-musl - Linux armv5 cross compiler toolchain using musl as base “libc”.
  2. dockcross/linux-armv7 - Generic Linux armv7 cross compiler toolchain.
  3. dockcross/linux-armv7a - Toolchain configured for ARMv7-A used in Beaglebone Black single board PC with TI SoC AM3358 on board, Cortex-A8.

1 - Has a musl inside, which I will need for sure leter-on,
2 - Seems the most generic - so will I have to further upgrade/refine it?
and 3 - seems to be the closest with the Cortexa8 instead of Cortex9 used in my Omnia

So I’m totally lost here. And I don’t want to pick a random one and then after hours of trials and errors, discover that that wasn’t the right one. Or maybe this approach is totally wrong, and you will know of any other, easier way of cross-compilation?

I will appreciate any help. Thanks.

3 Likes

I was playing with cross-compilation for my Turris Omnia recently. I summarized my findings in a blog post, see here: https://itnext.io/cross-compile-rust-programs-to-run-on-turris-omnia-e592b555e2aa?source=friends_link&sk=1f8c6b55e04d67482657e1a8a1e21489. The post shows how to compile a simple “hello world” program written in C to run on Turris Omnia.

TL;DR:

In practice, I was not able to get OpenSSL compiled in a way that would work with Rust, so I ended up using the following Docker image: https://github.com/messense/rust-musl-cross

alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src messense/rust-musl-cross:armv7-musleabihf'
rust-musl-builder cargo build --release

I understand my experience may not be entirely relevant to you, since you don’t seem to be compiling Rust programs, but I hope you will find the pointers helpful.

1 Like

Is there anyone in this forum who has successfully compiled TOS and is not from the Turris team?

It would be nice to have hint how to do it.

1 Like

off topic dude, don’t hijack other people’s posts…

Guys, here are the answers I found:

1 Like

Next level is compiling of TOS. Good luck!

1 Like

Not related but for this who looking how to compile Golang for Turris OS (or OpenWrt):

GOOS=linux GOARCH=arm GOARM=7 go build main.go

Then upload with scp and make it executable.

I compiled the sample Simple Golang DNS Server · GitHub
And resulted binary has size 6467709
Maybe for other projects the size will be smaller.

The CGO won’t work.

Interesting idea to check: the Alpine linux also uses musl so any program from Alpine must work on OpenWrt. I don’t know if the Alpine has packages for the armv7

1 Like

The OpenWrt and Turris has graphicsmagick package which is lightweight version of the ImageMagick

1 Like