Skip to content
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

Consider using critical_section for the init-context CriticalSection token #1002

Open
urdh opened this issue Dec 3, 2024 · 0 comments
Open

Comments

@urdh
Copy link

urdh commented Dec 3, 2024

Currently (since rtic-rs/rfcs#32) the init::Context contains a bare_metal critical section token to indicate that the initialization routine runs with interrupts disabled. This causes issues when trying to use RTIC with the STM32F0 HAL and an updated cortex-m crate, which has moved away from using bare_metal to instead use critical_section in rust-embedded/cortex-m#447.

With stm32-rs/stm32f0xx-hal#180, the STM32F0 HAL is going to be usable with more recent cortex-m versions, but this will instead introduce an incompatibility with RTIC which will require users to work around this incompatibility with a bit of unsafe:

    #[init]
    fn init(mut cx: init::Context) -> (Shared, Local) {
        let cs = unsafe { critical_section::CriticalSection::new() };
        // ...
    }

This isn't a show-stopper but given that critical_section::CriticalSection already seems to be used elsewhere in RTIC, and that STM32F0 seems to be the origin of the bare_metal CS to begin with, it seems reasonable to move that CS to critical_section as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant