Skip to content

[embassy-rp] Enable interrupts in init function#5660

Closed
sourcebox wants to merge 1 commit intoembassy-rs:mainfrom
sourcebox:rp-int-enable
Closed

[embassy-rp] Enable interrupts in init function#5660
sourcebox wants to merge 1 commit intoembassy-rs:mainfrom
sourcebox:rp-int-enable

Conversation

@sourcebox
Copy link
Contributor

Fix for #4982

@Dirbaio
Copy link
Member

Dirbaio commented Mar 13, 2026

This is risky, the user might have good reasons to run init with interrupts disabled.

  • It might be inside a critical section, we'd be "prematurely ending" it which can cause unsoundness.
  • RTIC's init() runs with interrupts disabled because the resource sharing stuff isn't fully initialized yet, forcing enabling interrupts can probably cause unsoundness too.

@sourcebox
Copy link
Contributor Author

So what would be the alternative to make it independent of the bootloader? Because the risks you describe are probably also present when using a bootloader that enables them by default.

@Dirbaio
Copy link
Member

Dirbaio commented Mar 13, 2026

So what would be the alternative to make it independent of the bootloader?

I don't think it's possible to fix. The current convention is irqs are enabled at boot. Libraries can't enable irqs without risking unsoundness. If you have a broken bootloader that jumps to the app with irqs disabled, it's up to you, the user, to unsafely enable irqs at start of main when you know it can't cause unsoundness.

Because the risks you describe are probably also present when using a bootloader that enables them by default.

No, because the firmware will disable irqs if it's necessary for soundness, it doesn't rely on irqs being disabled on boot.

@Dirbaio
Copy link
Member

Dirbaio commented Mar 13, 2026

Maybe we can do it in pre_init. That shouldn't cause any unsoundness.

Disable+unpend all irqs individually in NVIC, then enable global interrupts.

@sourcebox
Copy link
Contributor Author

Ok, I close this PR so we can check a better solution.

@sourcebox sourcebox closed this Mar 13, 2026
@sourcebox sourcebox deleted the rp-int-enable branch March 13, 2026 14:27
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

Successfully merging this pull request may close these issues.

2 participants