-
Notifications
You must be signed in to change notification settings - Fork 18
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
Support/avr platform #12
Conversation
This commit adds support for AVR (Arduino) platforms via direct implementation of interrupt enable/disable functionality via AVR assembly. The underlying motivation for this support is to enable further integration with the greater Embedded Rust ecosystem. As an example, `embedded-nal` depends upon `heapless`, which in turn depends upon atomic support, either natively or via `atomic-polyfill`. `atomic-polyfill` uses `critical-section`, and so enabling AVR support in this crate has great benefits to the downstream packages that hvae come to depend upon `critical-section`.
…and feature(llvm_asm). Also had to disable #![doc because the AVR compiler can't handle it
The CI check appears to have choked because |
ci.sh
Outdated
@@ -7,3 +7,4 @@ cargo build --target thumbv6m-none-eabi | |||
cargo build --target thumbv7em-none-eabi | |||
cargo build --target riscv32imc-unknown-none-elf | |||
cargo build --target riscv32imac-unknown-none-elf | |||
cargo +nightly-2021-01-07 build -Zbuild-std=core --target avr-specs/avr-atmega328p.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use such an old nightly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Attempting to use a modern version of rust fails with
error: ran out of registers during register allocation
It may be covered by rust-lang/rust#88252 , but Rust on AVR has been waiting for a fix for a long time and has to muddle along with old tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see. No problem then, was just curious :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it is possible to just rustup install nightly-2021-01-07
in the ci.sh
, but I don't know how to test it without pushing another commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment in the main thread. also feel free to push as many commits as you need! you can squash/amend later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a way to make ci.sh
work. I just did a rustup toolchain install nightly-2021-01-07 --component rust-src
before I compile for AVR. There might be a more elegant way to do it, but I do not know what it would be.
#[no_mangle] | ||
unsafe fn _critical_section_acquire() -> u8 { | ||
let mut sreg: u8; | ||
llvm_asm!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use the newer asm!
, or is it not supported on AVR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last I checked asm!
was not supported by Rust for AVR target.
- llvm_asm! removed in latest nightly rust Rahix/avr-device#91
- llvm_asm macro has been deprecated avr-rust/delay#10
Also, the last time I dealt with assembly language was 1987 on an 8086.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, just wanted to confirm!
Also, the last time I dealt with assembly language was 1987 on an 8086.
😂
It's standard |
…te rust toolchain
…alternate rust toolchain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, Thank you!
torrancew's pull request #6 seems to have stalled. I picked up where it left off and performed the changes to the CI system you requested. Let me know if there is anything else you would like adjusted.