If you’ve worked on any projects using Rust and a Raspberry Pi I would be interested to hear your story.
Cross-compiling to Raspberry PI is easy, and works great. Compiling on a Raspberry PI is rather painful due to long compile times.
(I'm assuming crosscompiling then running on Linux, not bare-metal (but that also should be possible)) Not a big project, but I've run simple HTTP server on one. To be honest, with Rust it mostly just:
rustup target add arm-unknown-linux-musleabihf
cargo build --target arm-unknown-linux-musleabihf
You might need to adjust target, depending on which Raspberry Pi version you're using.
In my case, because I've fairly old one (RPi 1 B+), I had to additionally download gcc toolchain (for linking) from arm's website, as the one from distro didn't support armv6.
How can I compile Rust code to run on a Raspberry Pi 2? - Stack Overflow
Has anyone programmed a Raspberry Pi with Rust?
(I'm assuming crosscompiling then running on Linux, not bare-metal (but that also should be possible)) Not a big project, but I've run simple HTTP server on one. To be honest, with Rust it mostly just:
rustup target add arm-unknown-linux-musleabihf cargo build --target arm-unknown-linux-musleabihf
You might need to adjust target, depending on which Raspberry Pi version you're using.
In my case, because I've fairly old one (RPi 1 B+), I had to additionally download gcc toolchain (for linking) from arm's website, as the one from distro didn't support armv6.
More on reddit.comRustDesk finally released a raspberry build: an open source TeamViewer alternative
Tutorial: Compile RustDesk-Server for a Raspberry Pi 1 (ARMv6)
We have rustup now.
$ rustup target add arm-unknown-linux-gnueabihf
$ sudo apt-get install gcc-arm-linux-gnueabihf
$ echo '[target.arm-unknown-linux-gnueabihf]' >> ~/.cargo/config
$ echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config
$ cd <project dir>
$ cargo build --target=arm-unknown-linux-gnueabihf
The Rust compiler is not distributed as a cross-compiler for the Raspberry Pi, so it needs to be compiled as a cross compiler with rpi dev tools.
Get rpi dev tools -
git clone https://github.com/raspberrypi/tools.git ~/pi-toolsget rust compiler from mozilla git repo and add rpi tools to the path
export PATH=~/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATHLook for rusty-pi dir on your home
./configure --target=arm-unknown-linux-gnueabihf --prefix=$HOME/rusty-pi && make && make installConsidering helloworld.rs ->
% ~/pi-rust/bin/rustc --target=arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-g++ helloworld.rs
It will produce an executable.