[SOLVED] AVR support not working in avr-rust (xargo?)

I was able to successfully build the compiler using the instructions for AVR here. However, when I run rustc --print target-list the avr target is not in there, and naturally it won’t compile the blink program to the avr target.

I’m working on ubuntu 16.0.4. Anyone have any ideas? I can’t find any errors during the build process to give me a clue.


You’ll likely have a higher percentage of knowledgable replies on the AVR-Rust Gitter channel, but some basic troubleshooting:

  1. Did you compile the right code? A git log in the source directory should show some AVR-specific commits
  2. Are you using the right rustc binary? What does rustc --version output? It should be a nightly version from a while ago now (I have 1.22.0-dev)

I don’t think @japaric knows too much about AVR, and it feels kind of bad to me to ping specific people when asking for help on a free-for-all forum.

Apologies if I was rude, but I pinged him because of this earlier post. I though at least he might be able to point me in the right direction, and he said he was happy to help with other areas including AVR in the post.

I’ll look into those suggestions when I get back to the computer I was working on earlier. Thanks for the link to the AVR channel on gitter, that should be helpful!

1.) Yes, I am compiling the right code. I was able to find the AVR specific commits with git log.

2.) I’m not sure what you mean here. Do you mean the rust compiler I use while bootstrapping?

I have the latest stable rust compiler set as my default right now. Do I need to use an earlier version to do the bootstrap?

This is what I was referring to — once you have built the AVR-enabled rustc, you have to use it. For example, the README states:

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

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

That last step would make it so that your default is avr-rust (which seems a bit extreme to me), but you need to select that toolchain somehow whenever you want to compile AVR code.

Ok, I did originally do those link commands. But when I ran the rustc --print target-list I forgot to prepend the rustup run avr-toolchain. So I tracked all that down, and the target is installed correctly.

However, it still gives me an error when I try to compile the blink program via the instructions in the readme. The error I get is

 XARGO_RUST_SRC=/home/ryan/programming/avr/build/build/x86_64-unknown-linux-gnu/stage1 rustup run avr-toolchain xargo build --target avr-atmega328p
   Compiling arduino v0.1.0
error: Error loading target specification: Could not find specification for target "avr-atmega328p"
  = help: Use `--print target-list` for a list of built-in targets

error: Could not compile `arduino`.

To learn more, run the command again with --verbose.

I see in the blink directory there is a avr-atmega328p.json file. Now I think my root problem may actually be with Xargo.

xargo --version
xargo 0.3.10
cargo 0.24.0 (45043115c 2017-12-05)

I think I’ll move future questions for this problem to the gitter channel. Thanks so much for you help so far.

I was finally able to get all of this working. Basically, it is a moving target. Right now you need to download the libcore repository from the repo and point xargo to that source, then for the blink program I downloaded the ruduino crate and added the avr-atmega328p.json file to the rduino library. Back in the blink program I then updated Cargo.toml to point to my local download of ruduino, and everything compiled. I was able to convert the elf file to hex and upload it on my uno board, and it worked perfectly.