Skip to main content
Dat Tran
Senior II
January 31, 2025
Question

STM32C07: Jump to STM Bootloader but can't erase or change anything

  • January 31, 2025
  • 2 replies
  • 893 views

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. 

DatTran_0-1738363342615.png

 

2 replies

TDK
Super User
February 1, 2025

Interrupts should be enabled for USB DFU bootloader. It's possibly they added to code enable them in the C0 bootloader, but it's not there on other families.

See here for example working jump to bootloader code:

How to jump to system bootloader from application ... - STMicroelectronics Community

"If you feel a post has answered your question, please click ""Accept as Solution""."
Dat Tran
Dat TranAuthor
Senior II
February 1, 2025

Hi, thank you for your reply,

 

I tried enable interrupt but still don't work.

My code is from your link actually, and it does work to jump ST bootloader. Problem is after jump to bootloader, all thing I can do just read, can't change for write to flash.

Here is an update with enable interrupt, share to me if any recommend

 

 

void (*SysMemBootJump)(void);
void JumpToBootloader(void){
	
	SysMemBootJump = (void (*)(void)) (*((uint32_t *) ((0x1FFF0000 + 4))));
	
		/* Disable all interrupts */
	__disable_irq();

		/* 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();

	

	for (int i = 0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]); i++)
 {
 NVIC->ICER[i] = 0xFFFFFFFF;
 NVIC->ICPR[i] = 0xFFFFFFFF;
 }
	
			/* Disable all interrupts */
	__enable_irq();

	
	__set_MSP(msp);

	SysMemBootJump();
	
}
alnicko_artem
Associate II
July 11, 2025

Hi, @Dat Tran , I have a similar problem, please tell me if you managed to solve it and how

 

 

Dat Tran
Dat TranAuthor
Senior II
July 11, 2025

Hi, I still have this issue and not sure how to solve it yet.

We changed our design, using boot0 pin now, but it would be nice if there is a way to jump by code.

Please share to me when you solve this issue.