Skip to content

cortex-m-rt: add reset-interrupt-state feature - #688

Open
rhgndf wants to merge 1 commit into
rust-embedded:masterfrom
rhgndf:disable-interrupts-on-startup
Open

cortex-m-rt: add reset-interrupt-state feature#688
rhgndf wants to merge 1 commit into
rust-embedded:masterfrom
rhgndf:disable-interrupts-on-startup

Conversation

@rhgndf

@rhgndf rhgndf commented Aug 20, 2026

Copy link
Copy Markdown

Some bootloaders don't disable interrupts when exiting and jumping into user code.

What should be the order to execute this with respect to set-vtor/set-sp?

@adamgreig

Copy link
Copy Markdown
Member

Which bootloaders? This seems like a bootloader bug, although we have the set-sp and set-vtor also just to work around bootloader bugs...

@rhgndf

rhgndf commented Aug 21, 2026

Copy link
Copy Markdown
Author

I encountered this with the bootloader on py32f072 after flashing a firmware using its usb hid bootloader.

It seems like the bootloader enables the USB interrupt, SysTick and PendSV and doesn't disable it after jumping to user code, so if an interrupt fires before the user firmware data structures are set up, the interrupt handler can corrupt data or crash causing a stuck cpu.
The instructions in the bootloader before jumping are just:

  1fff01d2  ldr   r1,[r0,#4]       ; application reset handler
  1fff01d4  ldr   r0,[r0]          ; application initial MSP
  1fff01d6  msr   msp,r0
  1fff01da  bx    r1

The fix would be to enable both this feature and the set-vtor feature which seems to make it reliably boot.

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