tomoyuki-nakabayashi / zephyr-rust-integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust integration as a Zephyr application

How to build

# at a directory you can build Zephyr application
# setup Zephyr build environment variables, e.g., using `zephyr-env.sh`
git clone https://github.com/tomoyuki-nakabayashi/zephyr-rust-integration.git
cd zephyr-rust-integration/hello_rust
mkdir build && cd build
(cd ../hello; make)
cmake -GNinja -DBOARD=qemu_cortex_m3 ..
ninja run

Then, you can finally see:

***** Booting Zephyr OS zephyr-v1.13.0-3321-g7f956a9 *****
*** Booting Zephyr OS build zephyr-v2.1.0  ***
Hello Rust

prerequisite

Zephyr side

First of all, you must setup Zephyr development environment to build application targeting qemu_cortex_m3. Zephyr Getting Started Guide will help you to setup the development environment.

I tested this sample using Zephyr v2.1.0 with zephyr-sdk-0.10.3. I recommend you use the same version of zephyr-sdk.

Rust side

  • Rust 1.40.0 stable channel.
  • cargo-binutils
$ rustup component add llvm-tools-preview

$ cargo install cargo-binutils --vers 0.1.4

$ cargo size -- -version
LLVM (http://llvm.org/):
  LLVM version 8.0.0svn
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake
  • cbindgen
cargo install cbindgen

Limitations

  • Build only for thumbv7m-none-eabi.

About

License:Apache License 2.0


Languages

Language:Rust 98.2%Language:C 1.3%Language:CMake 0.4%Language:Makefile 0.1%