cancel
Showing results for 
Search instead for 
Did you mean: 

Jumping into bootloader of STM32H563 from user code

Quentin Ch
Associate III

Hello,

I try to jump into the default bootloader of the STM32H563 from user code by setting the NSBOOTADDR:

extern void HalRebootInBootloaderMode(void) {
    FLASH_OBProgramInitTypeDef options;
    HAL_FLASHEx_OBGetConfig(&options);

    options.BootAddr = 0x0BF97000u;  // From AN2606. Also tried 0x0BF80000 start of sytem memory found in table 48 of RM0481
    options.BootConfig = OB_BOOT_NS;
    options.OptionType = OPTIONBYTE_BOOTADDR;

    HAL_FLASH_Unlock();     //Returns HAL_OK
    HAL_FLASH_OB_Unlock();  //Returns HAL_OK
    
    HAL_FLASHEx_OBProgram(&options);    //Returns HAL_OK
    HAL_FLASH_OB_Launch();              //Returns HAL_ERROR, because of OPT_CHANGE_ERR
    
    HAL_FLASH_OB_Lock();
    HAL_FLASH_Lock();
    HAL_NVIC_SystemReset();
}​

A similar mechanism worked pretty well on STM32H743 (using registers BOOT_ADDR1 and BOOT_ADDR_0 instead on that MCU).
But the snippet above fails on the H563 (HAL_FLASH_OB_Launch() returns HAL_ERROR, and my application always start in my user code).
However HAL_FLASH_OB_Launch() return HAL_OF if I set another address like 0x08000000 or 0x08000100.

- TrustZone is disable
- Provisionning state is 0xED (OPEN)
- BootLock option bytes are on 0xC3 (disabled)
- This article [1] at §3.3 reports a successful jump to bootloader from user code.

What am I missing ?

[1] https://community.st.com/t5/stm32-mcus/understanding-the-bootloader-issue-with-the-go-command-on-the/ta-p/750839

 

1 ACCEPTED SOLUTION

Accepted Solutions
Saket_Om
ST Employee

Hello @Quentin Ch 

Did you flow the instruction on the following article please? 

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

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

View solution in original post

2 REPLIES 2
Saket_Om
ST Employee

Hello @Quentin Ch 

Did you flow the instruction on the following article please? 

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

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
Quentin Ch
Associate III

Indeed, I overlooked about this article as some errors/fixes were reported and the HAL functions looked clearer and were working on a previous project with STM32F743.

Just need to send then a "Reset" bootloader command instead of "Go" as explained in https://community.st.com/t5/stm32-mcus/understanding-the-bootloader-issue-with-the-go-command-on-the/ta-p/750839

I assume it is not possible to set an address corresponding to System Memory in NSBOOTADDR of STM32H563