2025-01-31 02:45 PM
Hi, I am working on STM32C071
I wrote code to jump to ST bootloader from my application.
The code seems to work well, after jump to ST bootloader, I can connect to ST Bootloader by USB, using STM32CubeProgrammer. I can read flash data, option byte....
But if I do erase flash or change anything, STM32CubeProgrammer throws a failed message and exit STM bootloader mode.
Below is my jump function:
void (*SysMemBootJump)(void);
void JumpToBootloader(void){
SysMemBootJump = (void (*)(void)) (*((uint32_t *) ((0x1FFF0000 + 4))));
/* Set the clock to the default state */
HAL_RCC_DeInit();
/* Disable Systick timer */
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
volatile uint32_t msp = *(__IO uint32_t*)(0x1FFF0000);
__HAL_RCC_USB_CLK_DISABLE();
/* Disable all interrupts */
__disable_irq();
__set_MSP(msp);
SysMemBootJump();
}
Below is failed message:
The error is "verify flash protection" but there is no flash protect. Because I can hold BOOT pin, hit reset pin then enter STM Bootloader again, and erase as well.