Fix jump from STM bootloader to application - #319
Merged
marckleinebudde merged 1 commit intoSep 17, 2026
Merged
marckleinebudde merged 1 commit into
marckleinebudde merged 1 commit into
Conversation
Semiotmo
force-pushed
the
fix-jump-to-application-from-bootloader
branch
from
September 16, 2026 06:38
6e97490 to
cf9c31a
Compare
marckleinebudde
requested changes
Sep 16, 2026
marckleinebudde
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for your contribution!
Works for me on stm32g0b1. Please squash suggested fix.
Collaborator
|
This will fix #176 (comment) and |
marckleinebudde
force-pushed
the
fix-jump-to-application-from-bootloader
branch
from
September 17, 2026 07:35
cf9c31a to
7c92044
Compare
marckleinebudde
self-requested a review
September 17, 2026 07:35
marckleinebudde
approved these changes
Sep 17, 2026
marckleinebudde
force-pushed
the
fix-jump-to-application-from-bootloader
branch
from
September 17, 2026 07:59
7c92044 to
21148b5
Compare
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jump from STM bootloader to application is currently broken.
When jumping from STM integrated bootloader to application (e.g. after a firmware update via dfu), SCB->VTOR is still set to point to the bootloaders vector table.
The STM bootloader does not reset this to the appropriate value on exit. It expects that the application itself sets the correct VTOR, as documented in AN3156, Rev 18, page 20.
When VTOR is not set to the applications vector table and an interrupt arrives, the application executes the interrupt handler defined in STM bootloader code instead of its own. In my case this crashed the MCU.
This pull request fixes this by making sure that the VTOR is set appropriately and no interrupt can arrive before it is set.
Additionally it ensures that after a successful jump from bootloader to application, the application does not directly jump back to bootloader by explicitly clearing the
dfu_reset_to_bootloader_magicvariable.I decided to explicitly do it as well as I don't know if the STM bootloader will reset the memory associated with this variable itself.
This fix enables using the
:leaveparameter ofdfu-util(dfu-util -s 0x08000000:leave ...).Closes: #195