2025-01-12 10:05 PM - last edited on 2025-01-13 04:53 AM by SofLit
Hello STM Community,
I'm working on an STM32 project that involves a custom bootloader and application code. Here's the setup:
Here's the goto_application function I am using in the bootloader:
void goto_application(void)
{
/* Disable all interrupts */
__disable_irq();
/* Set the application's vector table address */
SCB->VTOR = 0x08040000UL;
/* Get the application reset handler address */
void (*app_reset_handler)(void) = (void (*)(void))(*((volatile uint32_t*)(0x08040004UL)));
/* Set the application's main stack pointer (MSP) */
__set_MSP(*(volatile uint32_t*)(0x08040000UL));
/* Disable SysTick */
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
/* Ensure changes are applied */
__DSB();
__ISB();
/* Jump to the application's reset handler */
app_reset_handler();
}
2025-01-13 03:08 AM
Hello,
When sharing a code please use </> button to paste your code. See this post. (I've edited your post).
Thank you for your understanding.
2025-01-13 04:33 AM
1. What MCU type exactly?
2. How do you know that "it doesn't jump"? Maybe it's stuck in your app in some loop waiting for something, like clock startup?
3. As it was discussed in many topics on bootloaders, the safest way to invoke the app is to jump to it at the very beginning of a bootloader, based on some flag set in RTC/Backup registers or in non-initilaized RAM location. To invoke the app, set the flag and issue soft reset - this way you ensure that all the peripherals are in the default state.