im thinking about it less in terms of what each option is capable of and more about what is more intuitive to the user. imo, calling a chip or board a "feature" isnt really intuitive, but theres not a huge difference either way.
true, and ultimately this is an abuse of cargo's feature system, for lack of a better option. Ideally, we'd get something like rust-lang/cargo#2980 to solve it properly.
looking at the attiny crate in the next branch
attiny-hal is a bad choice because it is so bare-bones.
atmega-hal is much bigger already and you can see how multiple MCUs share certain items. With separate crates we'd have to duplicate all that.
shouldnt any addon crates use embedded-hal rather than arduino-hal?
It really depends.
embedded-hal is for anything truly platform-agnostic, e.g. a plain sensor driver. Targeting
arduino-hal makes sense for libraries which are specific to Arduino boards, but still work across the entire family. Think, for example, of a crate supporting a certain Arduino shield.
why is it so bad if they start to diverge?
it's hell when things work differently across different MCUs. The entire point of a HAL is to abstract away the details of each MCU so you get a common interface ontop. Also, you'll have to re-learn the API each time and always be cautious if you missed some non-obvious difference. By forcing a common API, we'll ensure this can never happen and that if an API is supported across multiple MCUs it is guaranteed to work the same. If one MCU is harder to support, we can still
cfg() out the relevant stuff until it's implemented.
avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude -C/etc/avrdude/avrdude.conf -v -patmega168 -carduino -P/dev/ttyUSB0 -b19200 -D -Uflash:w:/home/dietrich/Projekte/Source/rust-arduino-blink/target/avr-atmega168/release/rust-arduino-blink.elf:e
ravedude nano --open-console --baudrate 57600 -P /dev/ttyUSB0 target/avr-atmega168/release/rust-arduino-blink.elf Board Arduino Nano Programming target/avr-atmega168/release/rust-arduino-blink.elf => /dev/ttyUSB0 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
arduino-halsupport as well in the meantime
Cargo.tomlto e72faada6bb7f67990216525aeb2132bbb3d53e9, you should be able to use it just like you'd do for the Arduino Nano (with ATmega328P)
[dependencies.arduino-uno] git = "https://github.com/Rahix/avr-hal" features=["arduino-nano"]
rev = "e72faada6bb7f67990216525aeb2132bbb3d53e9"and change the features to
features = ["nano168"]
what should work after that does not work before?
as the two chips are almost identical, most likely nothing. But to keep everything clean I'd want to have the 168 version be handled separate, ontop of its own HAL layer. This means if there ever are any differences to care for, it is easy to differentiate the two.
❯ cargo run Updating git repository `https://github.com/Rahix/avr-hal.git` error: no matching package named `arduino-uno` found location searched: https://github.com/Rahix/avr-hal.git?rev=e72faada6bb7f67990216525aeb2132bbb3d53e9 perhaps you meant: arduino-hal required by package `rust-arduino-blink v0.1.0 (/home/dietrich/Projekte/Source/rust-arduino-blink)`
avr-hal... Sorry :(
avr-halrecently... Maybe check https://github.com/Rahix/avr-hal#repository-structure to familiarize yourself with the new layout if you intend to update your own projects)
cargo generate --git https://github.com/Rahix/avr-hal-template.git --branch wipand then selecting
Nano168as the board. If I didn't mess anything up,
cargo runshould be enough with that to make your board blink (might need to set a port with
cargo run -- -P /dev/ttyFOO).
cargo run --bin test-nano168 Finished dev [optimized + debuginfo] target(s) in 0.02s Running `ravedude nano168 -cb 57600 -P /dev/ttyUSB0 target/avr-atmega168/debug/test-nano168.elf` Board Nano Clone (ATmega168) Programming target/avr-atmega168/debug/test-nano168.elf => /dev/ttyUSB0
cargo run(after I pasted the code from your example)
profile=minimalin toolchain.toml do?