🌐
Rust Programming Language
users.rust-lang.org › t › whats-up-with-the-rust-compiler-for-arm › 34929
What's up with the Rust compiler for ARM? - The Rust Programming Language Forum
November 23, 2019 - Sometimes even better. However on the ARM processor the Rust version performs substantially worse that the C. Let's take a simple example. The recursive Fibonacci algorithm: In C: #include "stdio.h" int fibonacci(int n) { if (n
🌐
PubNub
pubnub.com › pubnub blog › the exciting world of rust + arm processors
The exciting world of Rust + ARM processors
February 20, 2024 - The workload is a high-concurrency Rust API Web Application that services millions of users. Typically we think of processors such as AMD or Intel. An ARM processor is general purpose CPU that's used in many different devices, such as smartphones, tablets, Raspberry Pi, microcontrollers, development boards, and even some laptops.
🌐
The Rust Programming Language
doc.rust-lang.org › nightly › rustc › platform-support › arm-none-eabi.html
arm-none-eabi - The rustc book
Most Arm chips support both Thumb mode and Arm mode, with the notable exception that M-profile processors (thumbv*m*-none-eabi* targets) only support Thumb-mode. Rust targets ending with eabi use the so-called soft-float ABI: functions which take f32 or f64 as arguments will have those values packed into integer registers.
🌐
Arm Learning
learn.arm.com › install-guides › rust
Rust for Linux Applications | Arm Learning Paths
This install guide provides a quick solution to install Rust on an Arm Linux distribution.
🌐
Arm Learning
learn.arm.com › learning-paths › cross-platform › simd-on-rust › intro-to-rust
Learn how to write SIMD code on Arm using Rust: Introduction to Rust
While there are similar libraries for C and C++, this is different in that the intent is for it to be merged as an official extension to the Rust standard library under std::simd. You will learn how to use both of these interfaces to write code that uses Advanced SIMD/Neon instructions on an Arm CPU.
🌐
Hackster.io
hackster.io › locnnil › running-rust-on-arm-processor-281d22
Running Rust on ARM Processor - Hackster.io
January 5, 2023 - $ cd target/armv7-unknown-linux-gnueabi/debug/ $ adb push cross-arm /data $ adb shell # cd /data # chmod +x cross-arm # ./cross-arm ... And It's done! Congratulations, you have made your first Rust application on NL668 Fibocom module.
Find elsewhere
🌐
Arm Developer
developer.arm.com › community › arm-community-blogs › b › tools-software-ides-blog › posts › rust-on-arm-building-safe-secure-software
Building Safe and Secure Software with Rust on Arm
November 11, 2024 - This popular microcontroller features an Arm Cortex-M4 processor, along with 256 KiB of SRAM and 1 MiB of Flash. Bare-metal Rust firmware for Arm Cortex-M can rely on the start-up code produced by the Rust Embedded Devices Working Group, in ...
Top answer
1 of 2
2

A match “arm” is simply one of the cases of the match. The arm consists of a pattern to match against, followed by =>, followed by the value to produce if the pattern matches.

“Arm’s pattern” here simply means the pattern for that particular arm. For example, in the match expression

let x = 1;

match x {
    1 => println!("one"),
    2 => println!("two"),
    3 => println!("three"),
    _ => println!("anything"),
}

there are four arms, with patterns 1, 2, 3 and _ (match anything) respectively.

2 of 2
1

The "arms pattern" is the pattern (plain english word) that belongs to the arm (each case for the match statement is called an arm, as is common for branching statements). It is not a pattern as in the "design patterns" buzzword.

The thing that should match to select a specific arm is called a pattern (rather than, say, a value) as it is not limited to static values, but can, thanks to the expressivenes of the rust type system, describe parts of the value while selecting other parts for use in the pattern.

Here's an example where the thing to match is a tuple:

match (price_in_cents / 100, price_in_cents % 100) {
   (d, 0) => format!("{d} dollar"),
   (0, c) => format!("{c} cents"),
   (d, c) => format!("{d}:{c}"),
}

Note that order is important here, if I would have put the last arm first it would match any value (and the compiler would warn that the other arms are unreachable).

Note that _ in the example from @nneonneo s example is not a magic symbol to match anything, it is a declaration of a variable to put any value in. The only thing special is that the name _ implies that you are not going to use it. You can say x with the same result, except that the compiler will warn about you declaring a variable x and then not using it.

🌐
Japaric
blog.japaric.io › quickstart
Rust your ARM microcontroller! | Embedded in Rust
$ # Switch to the nightly channel $ rustup default nightly-2017-04-24 $ rustc -V rustc 1.18.0-nightly (2bd4b5c6d 2017-04-23) $ sudo pacman -S arm-none-eabi-binutils arm-none-eabi-gdb openocd $ arm-none-eabi-ld -V | head -n1 GNU ld (GNU Binutils) 2.28 $ arm-none-eabi-gdb -v | head -n1 GNU gdb (GDB) 7.12.1 $ openocd -v 2>&1 | head -n1 Open On-Chip Debugger 0.10.0 $ cargo install xargo $ xargo -V xargo 0.3.6 cargo 0.19.0-nightly (8326a3683 2017-04-19) $ # for Xargo $ rustup component add rust-src
🌐
Embedded Rust
docs.rust-embedded.org › faq.html
Frequently Asked Questions - Embedded Rust documentation
As of 2018-09-18 the Rust compiler supports cross compiling to these embedded architectures (see rustup target list): ... ARMv5TE (e.g.
🌐
Medium
medium.com › @wizofe › cross-compiling-rust-for-arm-e-g-raspberry-pi-using-any-os-11711ebfc52b
Cross compiling Rust for ARM (e.g. Raspberry Pi) using any OS! | by ioannis valasakis | Medium
July 8, 2018 - file target/armv7-unknown-linux-gnueabihf/debug/hellovagrant@stretch:~/hello$ target/armv7-unknown-linux-gnueabihf/debug/hello: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=39cfb5d9c8cda29ecac841120a2ef9c170f84399, not stripped# you can scp and run the executable on the ARM to finalise your test! Hurray! Now you can cross-compile Rust for ARM-based devices from the comfort of your own OS🤩
🌐
crates.io
crates.io › crates › arm
arm - crates.io: Rust Package Registry
Note: for now this crate was checked only against ARMv7 targets. ... rustup install nightly rustup default nightly rustup target add armv7-unknown-linux-gnueabihf cat >>~/.cargo/config <<EOF [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc" EOF
Top answer
1 of 2
12

Thanks to @Notlikethat's comment:

a) Yes you need to provide your own GCC cross-compiler.

b) You can get one here (select a mingw32 build).

Just unzip linaro's GCC then point cargo to it:

[target.armv7-unknown-linux-gnueabihf]
linker = "C:/Users/me/gcc-linaro-5.3.1-2016.05-i686-mingw32_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc.exe"

It seems to work even though it is arm- and not armv7-. I guess linking doesn't depend on the ISA. Actually I haven't run it yet, but it builds without errors!

Edit:

You can now use armv7-unknown-linux-musleabihf instead and get an actually portable binary (i.e. it doesn't depend on the GNU C library which often causes compatibility issues).

2 of 2
9

For MacOS better use: musleabihf, for Windows you can use gnueabihf as bellow:

Mac

$ brew install arm-linux-gnueabihf-binutils
$ rustup target add armv7-unknown-linux-musleabihf

In .cargo/config

[build]
target = "armv7-unknown-linux-musleabihf"
[target.armv7-unknown-linux-c]
linker = "arm-linux-gnueabihf-ld"

With simple src/main.rs

fn main() {
    println!("Hello, Raspberry!");
}

Then things are fine:

Hasans-Air:rpi hasan$ cargo build
   Compiling rpi v0.1.0 (/Users/hasan/PycharmProjects/rpi)
    Finished dev [unoptimized + debuginfo] target(s) in 0.41s
Hasans-Air:rpi hasan$ scp target/armv7-unknown-linux-musleabihf/debug/rpi [email protected]:
[email protected]'s password: 
rpi                                                                                         100% 2702KB   2.6MB/s   00:01    
Hasans-Air:rpi hasan$ ssh [email protected] 'chmod +x ~/rpi && ~/rpi'
[email protected]'s password: 
Hello, Raspberry!

Win 10 Get the linker from here, and run:

rustup target add armv7-unknown-linux-gnueabihf

Creating file .cargo/config with content:

[build]
target = "armv7-unknown-linux-gnueabihf"

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

And with simple src/main.rs:

fn main() {
    println!("Hello, Raspberry! from Win 10");
}

I was able to get things done

🌐
Rust Embedded
docs.rust-embedded.org › book › intro › install.html
Installation - The Embedded Rust Book
NOTE Make sure you have a compiler version equal to or newer than 1.31. rustc -V should return a date newer than the one shown below. ... For bandwidth and disk usage concerns the default installation only supports native compilation. To add cross compilation support for the ARM Cortex-M ...
🌐
InfoQ
infoq.com › news › 2021 › 01 › rust-149-supports-64bits-ARM
Rust 1.49 Released with Tier-1 Support of 64-Bit ARM Linux - InfoQ
January 9, 2021 - The Rust team released on the eve of last year Rust 1.49. The new version of Rust features 64-bit ARM support and minor language enhancements.
🌐
Rust
rust-lang.github.io › rustup › cross-compilation.html
Cross-compilation - The rustup book
With the arm-linux-androideabi target installed you can then build for Android with Cargo by passing the --target flag, as in cargo build --target=arm-linux-androideabi. Note that rustup target add only installs the Rust standard library for a given target. There are typically other tools necessary to cross-compile, particularly a linker.
🌐
Rust Documentation
doc.rust-lang.org › beta › embedded-book › peripherals › a-first-attempt.html
A first attempt in Rust - The Embedded Rust Book
Typically you’ll be looking these up in the chip manufacturer’s data sheet or Technical Reference Manual, but this example is common to all ARM Cortex-M cores, let’s look in the ARM reference manual. We see there are four registers: In Rust, we can represent a collection of registers in exactly the same way as we do in C - with a struct.