Skip to content

Instantly share code, notes, and snippets.

@jonahbron
Last active October 31, 2020 16:30
Show Gist options
  • Save jonahbron/640a825dd9a526d3a1c24f2c20ca44ac to your computer and use it in GitHub Desktop.
Save jonahbron/640a825dd9a526d3a1c24f2c20ca44ac to your computer and use it in GitHub Desktop.
Install AVR Rust and Compile Blink
git clone [email protected]:avr-rust/rust.git avr-rust
cd avr-rust
git checkout avr-support # 8405b30 at time of writing
cp config.toml.example config.toml
# Manually uncomment experimental-targets setting in config.toml
./x.py build
rustup toolchain link avr $(realpath $(find build -name 'stage2'))
cd ../../
wget https://downloads.arduino.cc/arduino-1.8.12-linux64.tar.xz
tar -xf arduino-1.8.12-linux64.tar.xz
git clone [email protected]:avr-rust/blink.git
cd blink
# set the linker to the toolchain from Arduino, and explicitly disable -pie
# use cargo built from avr-rust. Path will be different depending on system.
XARGO_RUST_SRC="$(realpath ../avr-rust/src)" \
RUSTFLAGS="-C linker=$(realpath $(../arduino-1.8.12/hardware/tools/avr/bin/avr-gcc)) -C link-args=-no-pie" \
rustup run avr ../avr-rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo xbuild --target avr-unknown-unknown --verbose
@Rahix
Copy link

Rahix commented Apr 9, 2020

avr-objcopy -O ihex .\target\avr-atmega328p\release\blink.elf blink.hex

I added a script for this in avr-hal: mkhex.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment