cortex-m-rt: add reset-interrupt-state feature - #688
Conversation
|
Which bootloaders? This seems like a bootloader bug, although we have the |
|
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 fix would be to enable both this feature and the set-vtor feature which seems to make it reliably boot. |
|
I think you could just disable interrupts, and write code in Rust inside main to reset your peripherals? I don't think restting all the interrupts needs to be pre-main, and I don't think it needs to be in cortex-m-rt, given it's only to work-around buggy bootloaders on specific platforms. |
|
There would still be a small window between setting vtor and disabling peripherals though. Putting it before setting vtor would be much less likely to crash since we assume that the data structures in ram are still set up for the bootloader's ISR. Yeah I agree trying to fix every bootloader's bugs in cortex-m-rt isn't a good idea so I wanted to get some comments on this. |
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?