cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 G071 System bootloader question

IPavl.3
Associate

I am trying to use the system bootloader G071 MCU with NUCLEO board using USART2. The factory programmed flash option bytes are 0xFFFFFEAA, and after I modify the nBOOT0 bit the MCU resets and the bootloader is activated after setting FLASH->CR |= FLASH_CR_OBL_LAUNCH; as expected. I use Pattern 11 (nBoot0(bit) = 0, nBoot1(bit) = 1, nBOOT0_SEL(bit) = 1 and BOOT_LOCK(bit) = 0)

I am able to upload the application successfully without any errors/NACKs to 0x0800 0000, but the bootloader is not deactivated after the Go command. I can see that the option bits still remain modified as 0xFBFFFEAA (nBoot0(bit) = 0). The application in the main flash does not start after POR.

Now, I can see that (AN3155, p. 16) "the bootloader firmware initializes the registers of the peripherals used by the bootloader to their default reset values..." But then in (AN2606 p.29) "When executing the Go command, the peripheral registers used by the bootloader are NOT initialized to their default reset values before jumping to the user application". I would assume that the flash option bits should also reset to their original values. Also, what may as well be the reason, AN2606, p. 230: "Option byte launch missing when using USART protocol" - specific for STM32G07xx/08xxx, BL ver. V11.2.

So my question is - whether I am doing something wrong or there is an MCU bug that prevents resetting the flash option register after execution of the Go command.

2 REPLIES 2
Antoine Odonne
ST Employee

Hello,

Option bytes are not modified by Go Command of the bootloader, behavior you observe is expected.

"The Go command is used to execute the downloaded code or any other code by branching to an address specified by the application."

Regarding the statement:

"Option byte launch missing when using USART protocol"

So far you only modified flash memory content and no option bytes. To update OB in order to revert OB value to user flash as boot area, please use write memory command:

"The Write Memory command is used to write data to any valid memory address (see note below) i.e. RAM, Flash memory, or option byte area" from AN3155.

Once OB are modified, it's possible that Bootloader itself do not launch them (thanks to setting OBLAUNCH bit) it means they are modified in the device, but not yet applied to it. A power sequence is required, or setting the OBLAUNCH bit from your user code after Go Command would fix this.

Hope it might help,

Best regards,

Antoine

Hello Antoine,

Thank you for your answer. Yes, I did not mention that I tried to set nBOOT0 bit and then OBLAUNCH from the app, but after the reset the application would not boot. It was difficult to debug the code after MCU resets. So I decided to just port a custom bootloader from my earlier project and it works now.

Kind Regards,

Igor