STM32F072CBT6 - Entering bootloader from application
I need to enter into the bootloader from my application during runtime.
I found an example code to achieve this for another family series and followed the instructions to determine the specific memory region I should jump to based on my particular MCU.
Below is the resulting code.
typedef void jumpFunc(void);
void Bootloader_Start(uint32_t run)
{
/* Set the address of the entry point to bootloader */
volatile uint32_t BootAddr = 0x1FFFC800;
/* Set up the jump to booloader address + 4 */
jumpFunc* SysMemBoot = (jumpFunc*)0x1FFFC804;
if (run == 1)
{
// Shut down any task running
HAL_RCC_DeInit();
SysTick->CTRL = 0; // reset the SysTick Timer
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq(); // Disable interrupts
/* Set the main stack pointer to the bootloader stack */
__set_MSP(*(uint32_t *)BootAddr);
SysMemBoot();
while (1);
}
}However, this code is not working for me. Executing it always results in a Hard fault interrupt.
What am I missing?
Thanks
