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.
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!
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.
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.