Calling Bootloader from my code and vice versa-STM32L072
- September 8, 2019
- 1 reply
- 1057 views
Hi,
I am trying to call the bootloader from my application, on a STM32L072. I followed posts in ST Community and other resources, but failed to do it.
I tried the code given in different places as below:
void BootLoaderInit(void)
{
void (*SysMemBootJump)(void);
volatile uint32_t BootJumpAddr = 0x1FF00000;
__disable_irq();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
HAL_RCC_DeInit();
/*
for (int i=0;i<5;i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}
__enable_irq();
*/
SysMemBootJump = (void (*)(void)) (*((uint32_t *)(0x1FF00004)));
__set_MSP(*(uint32_t*)BootJumpAddr);
SysMemBootJump();
while(1);
}
Once this function is called, it CubeProgrammer does not recognize the bootloader as it detects when BOOT0 pin is high and I do reset. It seems the hardware setup is fine but I have no idea why the bootloader does not work. I tried USB-DFU and USART1.
So, can someone help me to find out the problem??
Assuming the I could resolve the issue, or use BOOT0 pin to do it, how could I return to my code once the programming ends. The CubeProgrammer does not run the code after the programming:
Thank you,
Amir
