-
Notifications
You must be signed in to change notification settings - Fork 214
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
RISC-V support over CLINT #815
Conversation
I added backend-specific configuration arguments to the app macro. This solves #816 |
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.
awesome, one small comment from a quick look
I followed the In case of my RISC-V SLIC, this field is mandatory to be false (again, I still need a pre-processing step in which I can manipulate the app args before generating all the code). With this approach, removing core peripherals from RTIC is very similar to #720. Related issue: #746 |
I added the You can see how the SLIC backend uses this binding here. In this case, I force the With all these changes I am happy with the final result. So it's time to discuss my proposal and fine-tune/reorder the code before merging it :) Let me know what you think. |
d1eb6be
to
fb20aee
Compare
Last week I've been working on integrating use cases of RTIC on a HiFive1 RISC-V microcontroller in the CI. I adapted the CI of the repo to test examples for a RISC-V target using my new backend. The main changes are explained below:
About usage examples builds, I'm not sure if these are longer needed, as we can now treat them as regular examples. Of course, we now should adapt all the examples to be emulated in QEMU when possible. In this way, the CI will be enriched, as it does not limit to a single platform. |
Small comment, RTIC typically should require no unsafe user code. For the Cortex and ESP32 targets setting up the interrups are done by the framework. This also ensures that the |
4ee01cc
to
a47383b
Compare
@perlindgren I'll take a loop to ESP's implementation to see where is the proper place to enable the interrupts right after the init code finishes |
the global interrupt enable is already there here, so it's probably just a matter of removing it from the example. We were also discussing offline the premature interrupt enable being a possible cause of some concurrency issues leading to the CI weirdness. the |
I fixed the unsafe code issue. The weird thing is that the shared variable is correctly read and written from all the tasks but when it comes to idle, it reads the initial value as if the other tasks didn't run before |
Hey wait! The issue is that idle locks the shared counter before the medium task preempts it! That makes more sense. I'll take a look to find the bug. (still weird that CI fails depending on which host system is running QEMU) |
QEMU version via apt is 6.2, while I'm using 8.2.0 on my machine. I'll try to build the latest version of QEMU from source and see if that was it. |
8263e3e
to
7139493
Compare
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
334c0e9
to
1debe31
Compare
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.
This is looking great!
Love the cleanup of the examples structure, the platform makes it tidy and extensive!
Some comments and nitpicks here and there
Do you have a plan for riscv-slic
crate? For long term I guess there will be some release we'll depend on, rather than the current git-rev dep :)
xtask/src/main.rs
Outdated
} | ||
Commands::Book(args) => { | ||
info!("Running mdbook"); | ||
cargo_book(globals, &args.arguments) | ||
} | ||
// TODO these two commands are not needed anymore |
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.
Great! Then I think you should remove them together with the associated "usage" functions etc.! 👍
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.
Done (maybe I forgot something, a second check would be very useful :D)
input.span(), | ||
"cortex backend does not accept any arguments", |
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.
Discussion point: the features exposed are cortex-m-*
, and some modules are cortex
, while others are riscv_xyz
.
I wonder if it makes sense to keep to cortex-m
/cortex_m
here too for consistency? That includes module name etc.
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.
Good point. I guess that we should use cortex-m
/ cortex_m
, as it follows the name of the architecture crate (for RISC-V, the crate is riscv
).
examples/hifive1/Cargo.toml
Outdated
heapless = "0.8.0" | ||
hifive1 = { git = "https://github.com/romancardenas/hifive1.git", features = ["board-redv"] } | ||
e310x = { git = "https://github.com/greenlsi/e310x.git", features = ["rt"]} | ||
# riscv-rt = {path = "../../../riscv/riscv-rt", features = ["single-hart"]} |
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.
TODO before publish
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.
The issue with the official e310x and hifive1 crates is that they do not follow the new riscv-peripheral crate fashion. It is something I have to start moving, but I'm now kind of busy with riscv-pac and adding support to vectored mode in riscv-rt
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.
Once RTIC provides support to any RISC-V uC with a CLINT peripheral provided the PAC uses riscv-peripheral, maintainers will have a strong motivation to adopt the new crate 😁
I also plan to look at svd2rust and contribute there to ease the port task.
esp32c3 = { version = "0.20.0", optional = true} | ||
riscv = {version = "0.11.0", optional = true} | ||
cortex-m = { version = "0.7.0", optional = true } | ||
bare-metal = "1.0.0" | ||
#portable-atomic = { version = "0.3.19" } | ||
# portable-atomic = { version = "0.3.19" } |
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.
Not used at all, do we need it? 🤔 @korken89
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 think it is a "reminder" that we should move from atomic-polyfill to portable-atomic :D
I will ship a 0.1.0 release as soon as I get your OK to merge the PR :) I'm still waiting in case we detect any deficiency during the review process |
@AfoHT I addressed all your comments :) |
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.
Nice! 🚀
I think we can have this on master to really start playing with it.
@perlindgren you also had some devices to test on?
The Software-Level Interrupt Controller (SLIC) is a software interrupt controller that aims to mimic the PLIC but using a single interrupt source. It currently works for the CLINT peripheral, but I plan to add additional mechanisms so a broader amount of RISC-V targets can benefit from it.
This PR is a work-in-progress effort for adapting the SLIC to RTIC. I already modified some aspects:
interrupt_mod
codegen function.extra_modules
codegen function.But I'd like to do two additional major changes before this PR is accepted:
rtic::export
(I currently use a very dirty patch to avoid issues with my implementation)backend
field to theAppArgs
struct that, depending on the selected backend, can potentially parse additional configuration parameters.Additionally, as the SLIC is able to generate any number of synthetic interrupt sources, I would like to modify the current implementation so users won't need to define their dispatchers. Instead, the dispatchers will be automatically generated as needed by the application.
All the feedback is more than welcome, let me know what do you think about my proposals :)