Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that you are using an AVR target! You may need to change directories or pass a --target flag to cargo #137

Closed
Kurren123 opened this issue Feb 11, 2021 · 4 comments
Labels
question Further information is requested

Comments

@Kurren123
Copy link

I'm on windows

I'm getting this error when I follow online tutorials. My cargo.toml:

[package]
name = "rust-arduino-blink"
version = "0.1.0"
authors = [""]
edition = "2018"

[dependencies]
panic-halt = "0.2.0"

[dependencies.arduino-uno]
git = "https://github.com/Rahix/avr-hal"

[build]
target = "avr-atmega328p.json"

[unstable]
build-std = ["core"]

And my main.rs:

#![no_std]
#![no_main]

extern crate panic_halt;

use arduino_uno::prelude::*;

#[arduino_uno::entry]
fn main() -> ! {
    let dp = arduino_uno::Peripherals::take().unwrap();

    unimplemented!()
}

Any help would be much appreciated!

@Rahix
Copy link
Owner

Rahix commented Feb 12, 2021

You need to read the instructions more carefully ;)

This part:

[build]
target = "avr-atmega328p.json"

[unstable]
build-std = ["core"]

does not belong into Cargo.toml, but into a separate file named .cargo/config.toml.

Also, you need more directives in your Cargo.toml to configure the build profile. Take another look at the Starting your own project guide to see the details.

@Rahix Rahix added the question Further information is requested label Feb 12, 2021
@Kurren123
Copy link
Author

Kurren123 commented Feb 12, 2021

@Rahix Thanks for your help! I've now created the Cargo.toml and .cargo/config.toml, repository here. However I'm now getting this error when I do rustup override set nightly and cargo build --verbose:

error: could not compile `compiler_builtins`

Caused by:
  process didn't exit successfully: `rustc --crate-name compiler_builtins "C:\Users\Kurren N\.cargo\registry\src\github.com-
1ecc6299db9ec823\compiler_builtins-0.1.39\src\lib.rs" --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-
type lib --emit=dep-info,metadata,link -C opt-level=s -C panic=abort -C linker-plugin-lto -C debuginfo=2 -C debug-
assertions=on --cfg "feature=\"compiler-builtins\"" --cfg "feature=\"core\"" --cfg "feature=\"default\"" --cfg "feature=\"rustc-
dep-of-std\"" -C metadata=c49ed016198a86a1 -C extra-filename=-c49ed016198a86a1 --out-dir C:\dev\Arduino\rust-arduino-
blink\target\avr-atmega328p\debug\deps --target \\?\C:\dev\Arduino\rust-arduino-blink\avr-atmega328p.json -Z force-
unstable-if-unmarked -L dependency=C:\dev\Arduino\rust-arduino-blink\target\avr-atmega328p\debug\deps -L 
dependency=C:\dev\Arduino\rust-arduino-blink\target\debug\deps --extern core=C:\dev\Arduino\rust-arduino-
blink\target\avr-atmega328p\debug\deps\librustc_std_workspace_core-494a22ba4d488457.rmeta --cap-lints allow --cfg 
"feature=\"unstable\""` (exit code: 101)

Any suggestions?

@Rahix
Copy link
Owner

Rahix commented Feb 12, 2021

Please try using nightly-2021-01-07 instead (#124):

rustup toolchain install nightly-2021-01-07
rustup override set nightly-2021-01-07

Also, you should probably pin the version of avr-hal in your dependencies like this:

[dependencies.arduino-uno]
git = "https://github.com/rahix/avr-hal"
rev = "b1aedf824fcb59078f8022d4464b2835ae4bd83a"

@Kurren123
Copy link
Author

Thanks, this now worked! Only issue is that my IDE is showing errors as rust language server is not available on that nightly date, and it's hard to find the most recent nightly build before the 8th jan that includes rls.

Thanks again for your help!

Repository owner locked and limited conversation to collaborators Sep 2, 2022
@Rahix Rahix converted this issue into discussion #320 Sep 2, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants