rustrust-cargoattiny

How do I specify my target chip as a feature


I would like to program a bare attiny85 with rust. No existing development board, just my own layout. I figured that attiny-hal would be what I need, but I'm stuck at this error:

$ cargo check
    Checking attiny-hal v0.1.0 (https://github.com/rahix/avr-hal?rev=4c9c44c314eb061ee20556ef10d45dea36e75ee4#4c9c44c3)
error: This crate requires you to specify your target chip as a feature.
       
           Please select one of the following
       
           * attiny85
           * attiny88
           * attiny167
           * attiny2313

I tried these (and many other) settings in Crate.toml without success:

[package]
name = "avr01"
version = "0.1.0"
edition = "2021"

[features]
attiny85 = []

[dependencies.arduino-hal]
git = "https://github.com/rahix/avr-hal"
rev = "4c9c44c314eb061ee20556ef10d45dea36e75ee4"
features = ["attiny-hal"]

How do I select the target chip?


Solution

  • In your dependencies you have listed arduino-hal but you say you're programming a bare attiny85. You should include the attiny-hal crate directly and specify one of those features on the crate for example using this cargo command for an attiny85:

    cargo add --git "https://github.com/rahix/avr-hal" attiny-hal -F attiny85
    

    Which for some reason (I believe it's a bug) currently thinks attiny85 isn't a feature of attiny-hal but you can just specify it in your Cargo.toml. The key for attiny-hal should include the required feature:

    [dependencies.attiny-hal]
    git = "https://github.com/rahix/avr-hal"
    version = "*"
    features = ["attiny85"]