Skip to content
A fork of the Rust programming language with AVR support
Branch: avr-support
Clone or download
Pull request Compare This branch is 11 commits ahead, 4432 commits behind rust-lang:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src [AVR][NO UPSTREAM] Cherry-pick the fix for #123 Jan 21, 2019
.gitattributes
.gitignore
.gitmodules
.mailmap
.travis.yml [AVR][No Upstream] Add AVR-Rust specific travis-ci manifest Dec 19, 2018
.travis_rust.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
COPYRIGHT Remove references to AUTHORS.txt file Jul 30, 2018
Cargo.lock Rollup merge of rust-lang#56832 - alexcrichton:external-demangle, r=M… Dec 16, 2018
Cargo.toml
Jenkinsfile [AVR][No Upstream] Add Jenkinsfile Dec 19, 2018
LICENSE-APACHE
LICENSE-MIT LICENSE-MIT: Remove inaccurate (misattributed) copyright notice Jul 26, 2017
README.md
RELEASES.md Include changes from 1.30.1 in release notes Nov 22, 2018
RUST_README.md
appveyor.yml Revert "appveyor: Use VS2017 for all our images" Nov 24, 2018
config.toml.example
configure rustbuild: Rewrite the configure script in Python Aug 28, 2017
x.py

README.md

Rust with AVR support

Gitter

This project adds support for the AVR microcontroller to Rust.

It uses the AVR-LLVM backend.

Caveats

While the stock libcore may be compiled, certain code patterns may still exercise code in LLVM that is broken or that produces miscompiled code. Looking for existing issues or submitting a new issue is appreciated!

Building and installation

This will compile Rust with AVR support. This will not create a fully-fledged cross-compiler, however, as it does not compile any libraries such as libcore or liblibc. To do this, the --target=avr-unknown-unknown flag must be passed to configure, which is not fully supported yet due to bugs.

First make sure you've installed all dependencies for building, as specified in the main Rust repository here. Then use the following commands:

# Grab the avr-rust sources
git clone https://github.com/avr-rust/rust.git

# Create a directory to place built files in
mkdir build && cd build

# Generate Makefile using settings suitable for an experimental compiler
../rust/configure \
  --enable-debug \
  --disable-docs \
  --enable-llvm-assertions \
  --enable-debug-assertions \
  --enable-optimize \
  --enable-llvm-release-debuginfo \
  --experimental-targets=AVR \
  --prefix=/opt/avr-rust

# Build the compiler, optionally install it to /opt/avr-rust
make
make install

# Register the toolchain with rustup
rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage1'))

# Optionally enable the avr toolchain globally
rustup default avr-toolchain

Usage

With Xargo (recommended)

Take a look at the example blink program.

Vanilla rustc

AVR support is enabled by passing the --target avr-unknown-unknown flag to rustc.

Note that the Rust libcore library (essentially required for every Rust program), must be manually compiled for it to be used, as it will not be built for AVR during compiler compilation (yet). Work is currently being done in order to allow libcore to be automatically compiled for AVR.

You can’t perform that action at this time.