Skip to content

Allow writing to the CONTROL register #164

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

Merged
merged 4 commits into from
Sep 13, 2019
Merged

Allow writing to the CONTROL register #164

merged 4 commits into from
Sep 13, 2019

Conversation

jonas-schievink
Copy link
Contributor

This allows entering unprivileged mode.

Part of #58

@rust-highfive
Copy link

r? @adamgreig

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m labels Sep 6, 2019
@korken89
Copy link
Contributor

korken89 commented Sep 6, 2019

Hi, thanks for the PR!
CI is reporting an error with __control_w, can you have a look?

@jonas-schievink
Copy link
Contributor Author

Fixed. I should properly test this, though...

@jonas-schievink
Copy link
Contributor Author

Okay, did some manual testing and it seems to work fine

Copy link
Member

@adamgreig adamgreig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying those points, sounds good to me.

bors r+

bors bot added a commit that referenced this pull request Sep 13, 2019
164: Allow writing to the CONTROL register r=adamgreig a=jonas-schievink

This allows entering unprivileged mode.

Part of #58

Co-authored-by: Jonas Schievink <[email protected]>
@bors
Copy link
Contributor

bors bot commented Sep 13, 2019

Build succeeded

@bors bors bot merged commit 3d1fd33 into rust-embedded:master Sep 13, 2019
@jonas-schievink jonas-schievink deleted the control-write branch September 13, 2019 13:17
@kanishkarj
Copy link

Hey! i need the set_npriv badly for proceeding further with a project I am working on. Which version of cortex-m crate will support it?

@jonas-schievink
Copy link
Contributor Author

@kanishkarj Since this is not a breaking change it could be in 0.6.2

@jonas-schievink jonas-schievink mentioned this pull request Jan 9, 2020
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
224: Allow general exception / interrupt discovery in cortex-m-rt-macros r=korken89 a=mciantyre

We propose changes to the `cortex-m-rt-macros` crate that should help us use the macros independent of the `cortex-m-rt` runtime. The changes in this PR should be backwards compatible for all `cortex-m-rt` users, while expanding the utility of the macros beyond the cortex-m-rt repository.

In the [Teensy 4 libraries](https://github.com/mciantyre/teensy4-rs) we're developing, we've opted to create our own runtime crate, `teensy4-rt`. We require more support than what's available in `cortex-m-rt` to boot and take advantage of NXP iMXRT106x variants. Specifically, we have a unique start-up process, and a custom memory layout with tightly-couple memory (TCM) regions. As discussed in #164, the `cortex-m-rt` crate does not support custom memory layouts. To address the limitations and provide a faster proof-of-concept, we forked the `cortex-m-rt` crate, focusing on the runtime needs of our specific system.

Despite the fork, we strive for compatibility with the `cortex-m-rt` crate. Our eventual goal is to drop the `teensy4-rt` crate, and rely on a future version of the `cortex-m-rt` crate that supports our use-case. Compatibility means supporting the macros; just as the `cortex-m-rt` crate exports the macros, the `teensy4-rt` crate exports the same macros. By requiring that the macros maintain `extern crate cortex_m_rt` declarations, we assume that the `cortex_m_rt` crate is available. However, we don't believe this is a necessary requirement.

To take advantage of the `#[interrupt]` and `#[exception]` macros, a set of crates need to export two identifiers: `interrupt`, an enumeration of valid interrupt handlers; and `exception`, an enumeration of exceptions for the Cortex M variant. We have a precedent for this pattern, in that crates generated by `svd2rust` export the enumeration of valid interrupt handlers (provided the correct features are enabled) for discovery by the `#[interrupt]` macros. The PR proposes a similar strategy: export the `Exceptions` enumeration as `exception` (lower case) from the `cortex-m-rt` crate, so that exception variant discovery occurs the same as it does for interrupts.

After the rename, and with the removal of `extern crate cortex_m_rt` in the two macros, it doesn't matter where the `exception` or `interrupt` enums are defined. The changes let us define a similar `exception` enumeration in our `teensy4-rt` crate, which may be picked up by the `#[exception]` macro. We've shown this to be a successful strategy in the Teensy 4 Rust libraries, which are based on our fork of the macros crate.

We realize that the macros are a feature of the `cortex-m-rt` crate, not a library that others should directly depend on. Ideally, we rally around the `cortex-m-rt` crate, and keep the macros coupled to that implementation. But until we reach that point, having the macros defined without expectations of the `cortex-m-rt` crate lets us bring up new embedded targets faster while maintaining compatibility with the existing ecosystem.

Co-authored-by: Ian McIntyre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants