-
Notifications
You must be signed in to change notification settings - Fork 99
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
Consistent development experience #44
Comments
I've raised avr-rust/rust-legacy-fork#93 to track porting It's not as high on the priority list compared to LLVM bugs though. |
How are target files and programmer configuration files distributed? Does it make sense to include these in the ic/soc/bsp crates or not? For RISCV we expect to have many different soc's with different combinations of extensions and custom extensions. So it would make sense to have 2-3 common combinations in rust (maybe RV32G and RV64G (G means IMFDAC)) but have custom configurations like for example in the hifive crate (RV32IMAC). |
Ideally we should add a few, baseline targets to rustc itself and ideally users shouldn't need to deal with custom targets / target configuration files.
What are "programmer configuration files"?
Crates can't change the compilation target; at most they can't preven't generate compiler errors if the wrong target is used. If we must ship target configuration files I'd say they should go in the Cargo project template.
Hmm, could we have lowest common denominator target and enable "extensions" via llvm flags? llvm flags can go in .cargo/config (
Are there 64-bit silicon implementations packed in microcontrollers packages? I think we should focus ourselves on RISCV microcontrollers and let someone deal with the
I don't see any target configuration file in that repo. In another thread, you asked about having / distributing a bunch of AVR targets / target configuration files that are pretty much the same except for the Also, you probably mentioned this to me before but how does |
I meant openocd configuration. But these are now included in the openocd riscv port, so I'll remove them from the crate. So this issue is a non-issue.
The cabi stuff can be parameterized over xlen (shared between 32bit and 64bit) as in the clang implementation [0] and the psabi docs [1]. I don't currently intend to port std to rv64. For 32bit targets it's indeed only features that changes and max-atomic-width is either 0 or 32 depending on if it has the A extension or not.
"features": "+m,+a,+c",
"max-atomic-width": 32, For 32bit targets without +m there is a missing compiler intrinsic that needs to be implemented. [2] Then there are various options in the privileged architecture manual that are configurable, but that can be handled with compile time options in the riscv crate. [0] https://github.com/lowRISC/riscv-llvm/blob/master/clang/0004-RISCV-Implement-RISCV-ABI-lowering.patch |
That could definitely work. It does feel a bit hacky though as Still a better solution than hundreds of JSON files though!
Some MCUs have hardware multiplication, some don't. The AVR backend uses the target-cpu and maps it to a list of enabled CPU features. For example
|
OK, if @dylanmckay out of curiosity do the AVR targets have max-atomic-width set to 0 or to some other Something interesting about max-atomic-width in Cortex-M land is that is not fine grained enough to Do any of the RISCV configurations / AVR target-cpu values change the ABI of the generated code. For example, in Cortex-M land If it's the case that some RISCV configurations / AVR target-cpu values have different ABIs then Build scripts have access to some information about targets via env variables that Cargo sets.
Notably Is there anything like this on AVR / RISCV? |
There are many possible ABI's depending on the combination of features (xlen = E/32/64/128, flen = 0/32/64/128, 4*4=16 possible abi's). There are currently three calling conventions: soft float, hard float, and RV32E (only requires 16 instead of 32 registers for very small implementations) and two official ABI's (ILP32 for RV32G and LP64 for RV64G). For now I'd suggest we stick to soft float (Integer Calling Convention) since that's what the only available mcu has (xlen=32, flen=0) and see what features are available in actual CPU's when they pop up. |
It is currently the default of
From the AVR side - nope.
I've made |
@dvc94ch That's a lot but I expect that most of them are forward compatible? Like you can link flen=64 objects and flen=32 objects together. The different calling conventions are likely not linkable and we may different targets for each.
But does it generate the right thing? Does
That may require an RFC to land, or at the very least I expect that the portability WG will have the give the OK. |
Hmm, doesn't passing a double require two registers if flen=32? |
@dvc94ch Yeah, you are right the CPU registers have different sizes. Bad example. The linker doesn't like merging i686 objects and x86_64 objects; my flen example would probably be rejected by the linker in the same way. |
A brief glance shows the The AVR backend implements the usual atomic load/store/add/sub operations, but not RMW operations like compare-and-swap. Currently it tells LLVM to expand these intrinsics into compiler runtime library calls. These would have to be implemented in The RMW operations can be expanded into direct AVR machine code on many chips. The ATmega328p implements atomic instructions for example
I agree. I've brought this feature up to the rust-lang folks before at rust-lang/rust#44036. For the meantime though, it works well in the fork, at least until a better solution exists. |
Closing this as part of the 2024 triage. As of today, much of this is covered by the compiler itself, as well as external tools like probe-rs. If you think this was closed incorrectly, please leave a comment and we can revisit this decision in the next weekly WG meeting on Matrix. |
Ideally the development experience for the different embedded targets should be very similar so a
user can easily transition from one target to the target instead of having to redo the setup
process, learn about new tools, learn a new development process, migrate to different crates that
basically do the same things as the ones they were previously using, etc.
This problem can be tackled from different sides:
It should be possible to use
XargoCargo, the RLS and some IDE to do development for all theembedded targets. One click "build, flash and debug" functionality should be present.
I had reports that VS Code plus the cortex-debug plugin works fine for Cortex-M development. The
plugin also has support for printing semihosting and ITM output to the console.
A CLI equivalent should also exist. For example, two subcommands like
cargo flash
andcargo debug
should Do The Right Thing for each embedded target. This may require the user to specify, forexample, what parameters to pass to OpenOCD in some configuration file.
Ideally a minimal embedded program should look like this:
for all the embedded targets. This can be accomplish by standardizing a crate like
cortex-m-rt
andreplicating it for all the embedded targets, and by providing Cargo project templates (with linker
scripts, etc.) for each embedded target.
Cargo doesn't currently provide support for project templates (there was a pre-RFC discussion
months ago but it didn't go anywhere). The solution currently adopted in Cortex-M land is to just
cargo clone
a crate from crates.io that serves as a template and go from there (cf.cortex-m-quickstart
). We could adopt that solution or push for proper project template supportin Cargo.
One of Rust's strengths is the crates.io ecosystem. Unfortunately most of the crates.io ecosystem
can't be used in
no_std
context. There are several reasons for this: the author is not aware thattheir crate is compatible with
no_std
, the author is not willing to depend on unstable crates likealloc
to supportno_std
, etc.; but hopefully the portability WG will work on this issue.There's currently an on going community effort of producing generic driver crates (crates to
interface external devices like sensors) that work with any platform that has an implementation of
the
embedded-hal
traits. Most of the participants are Cortex-M developers; to ensure thesecrates and the
embedded-hal
abstractions work with all the other embedded targets AVR, MSP430 andRISCV developers must also participate.
There are a few ways to do multitasking on bare metal: RTFM, a Tokio-like cooperative event loop,
good old threads, etc. All these multitasking models should be available for all the embedded
targets. Ideally the different ports of these models should expose the same or very similar APIs.
For more details about multitasking models check issue #45
cc @dvc94ch @pftbest @dylanmckay
The text was updated successfully, but these errors were encountered: