Skip to content

Commit d020dd7

Browse files
shepmasterdylanmckay
authored andcommitted
[AVR][No Upstream] Add AVR-Rust README
1 parent c8c7654 commit d020dd7

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Rust with AVR support
2+
3+
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/avr-rust)
4+
5+
This project adds support for the [AVR](https://en.wikipedia.org/wiki/Atmel_AVR)
6+
microcontroller to Rust.
7+
8+
It uses the [AVR-LLVM backend](http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/).
9+
10+
## Caveats
11+
12+
While the stock libcore may be compiled, certain code patterns may
13+
still exercise code in LLVM that is broken or that produces
14+
miscompiled code. Looking for existing issues or submitting a new
15+
issue is appreciated!
16+
17+
## Building and installation
18+
19+
This will compile Rust with AVR support. This will not create a
20+
fully-fledged cross-compiler, however, as it does not compile any libraries
21+
such as `libcore` or `liblibc`. To do this, the `--target=avr-unknown-unknown`
22+
flag must be passed to `configure`, which is not fully supported yet due to bugs.
23+
24+
First make sure you've installed all dependencies for building, as specified in
25+
the main Rust repository [here](https://github.com/rust-lang/rust/#building-from-source).
26+
Then use the following commands:
27+
28+
``` bash
29+
# Grab the avr-rust sources
30+
git clone https://github.com/avr-rust/rust.git
31+
32+
# Create a directory to place built files in
33+
mkdir build && cd build
34+
35+
# Generate Makefile using settings suitable for an experimental compiler
36+
../rust/configure \
37+
--enable-debug \
38+
--disable-docs \
39+
--enable-llvm-assertions \
40+
--enable-debug-assertions \
41+
--enable-optimize \
42+
--enable-llvm-release-debuginfo \
43+
--experimental-targets=AVR \
44+
--prefix=/opt/avr-rust
45+
46+
# Build the compiler, optionally install it to /opt/avr-rust
47+
make
48+
make install
49+
50+
# Register the toolchain with rustup
51+
rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage1'))
52+
53+
# Optionally enable the avr toolchain globally
54+
rustup default avr-toolchain
55+
```
56+
57+
## Usage
58+
59+
# With Xargo (recommended)
60+
61+
Take a look at the example [blink](https://github.com/avr-rust/blink) program.
62+
63+
# Vanilla `rustc`
64+
65+
AVR support is enabled by passing the `--target avr-unknown-unknown` flag to `rustc`.
66+
67+
Note that the Rust `libcore` library (essentially required for every Rust program),
68+
must be manually compiled for it to be used, as it will not be built for AVR during
69+
compiler compilation (yet). Work is currently being done in order to allow `libcore`
70+
to be automatically compiled for AVR.

0 commit comments

Comments
 (0)