Mac OS preliminary support + how to cross compile your Copper project.

Yes, Mac OS as a development target is now supported \o/ with some minor kinks we will straighten out in the next few days but we invite all the testers to check it out, report bugs and give feedback.

So now we do support Ubuntu Linux recent flavors + Arch Linux (who doesn’t??) + Mac OS as the system on which you can develop and test you algorithms on.

Also since the inception, we have been testing out Copper on Arm v7, Arm v8 and Risk-V as the target platform, ie. what your robot is running with.

Let’s do a quick show and tell about how to compile Copper from your development machine to generate your copper binaries and artifacts without having to compile on the robot itself.

Rust is already amazing at cross compiling but there is a tool that makes it even easier!

First step, be sure you have docker installed.

Check out the docker doc. It should be pretty smooth.

Second step, install “cross”:

cargo install cross

Cross is a rust tool that brings in the correct image with the correct cross compiler to target your robot’s platform.

Third step, use “cross” instead of “cargo” and use “—target” to specify which target you need.

cross build --target aarch64-unknown-linux-gnu

and that’s it, your executable will be in the target/aarch64-unknown-linux-gnu/debug directory, you then can copy it to you robot with rsync or scp etc…

Let’s list some useful platforms you can encounter on robots.

Target Triple Description
x86_64-unknown-linux-gnu General-purpose 64-bit x86 Linux systems where glibc is the default standard library
x86_64-unknown-linux-musl Linux target for 64-bit x86 processors using the musl C library: Minimalist or static linking.
armv7-unknown-linux-gnueabihf 32-bit ARM target with hardware floating-point:
Raspberry Pi 2/3 and other ARMv7-based boards where glibc is standard.
armv7-unknown-linux-musleabihf 32-bit ARM target with hardware floating-point using musl. Smaller, statically-linked binaries.
aarch64-unknown-linux-gnu 64-bit ARM target using glibc: Raspberry Pi 4, Jetson Nano ...
aarch64-unknown-linux-musl 64-bit ARM target using musl. Smaller statically-linked binaries.
riscv64gc-unknown-linux-gnu 64-bit RISC-V target using glibc. For example the Mango Pi works well.
riscv64gc-unknown-linux-musl 64-bit RISC-V target with static linking with musl.

A note on musl:

Rust is generally compile statically your binary, which is awesome as it enables a lot of various linking optimizations.

There is a catch, the glibc. The GNU license makes a special case about binaries statically linking vs dynamically linking with it. So this is why the default is to use the .so.

And here comes musl, a reimplemented libc that you can freely link with your project, with it your basic Rust program only depends on the kernel APIs!

So the main two use cases:

  1. you need a ZOMG fully static fast binary

  2. the gnu libc on the target is incompatible with the cross compiler you use. ie anytime you use Debian / Armbian etc … you will hit this, the glibc usually predates Dennis Ritchies himself Oo.

As usual, if you have any difficulties, feel free to pop in in our chatroom, we are here to help.

Previous
Previous

Meet BalanceHAT: Our New Raspberry Pi HAT to Build Fun Robots with Copper!

Next
Next

Deep Dive #2: Structured Text Logging in Rust