cancel
Showing results for 
Search instead for 
Did you mean: 

How to program option bytes from STM32H7xx of STM32F7xx bootloader

KDuff.15
Associate II

I am developing code on my PC that uses Serial Comms to interface to my STM32H7xx and STM32F7xx processors using the system bootloader on USART1.

I have successfully loaded code on both processors into both bank 1 and bank 2 and can jump to and run the code I have just loaded from either bank, no problem.

Now I am trying to write to BOOT_ADD0 and BOOT_ADD1 in the option bytes so that the selected bank is run on system reset.

I cannot seem to access the option bytes through the Flash Controller's registers from within the system bootloader. The Application Note for the USART Bootloader (AN3155) says, about writing to memory:

"For the option byte area, the start address must be the base address of the option byte area (see note) to avoid writing inopportunely in this area."

On the STM32F7xx processor the reference manual specifies that the option bytes can be read from address 0x1fff 0000 in four 64 bit elements. I can read option bytes at address 0x1fff 0000, but this data is full of reserved bits, and I am afraid to even try to write to them. If I perform an incorrect write and the RDP gets inadvertently set to Level 2 my processor will become essentially useless.

On the STM32H7xx processor I cannot find anywhere in the reference manual the address at which the option bytes live, nor how they would be formatted.

Does anybody have any advice on how to set the boot addresses (BOOT_ADD0 and BOOT_ADD1) of both STM32H and STM32F processors from within the system bootloader?

Thanks in advance for any help.

Later addition.

It seems that if I ignore the "For the option byte area, the start address must be the base address of the option byte area (see note) to avoid writing inopportunely in this area." statement then on the STM32H7xx processor just write to the FLASH_BOOT_PRGR register, it works. But I still cannot access the option bytes through the FLASH controller registers on the STM32F7xx processor.

2 REPLIES 2
Piranha
Chief II

Maybe missing FLASH_OPTKEYR unlock?

The app note says that it does that when it detects that the write is to the Option Bytes area (and I didn't need to write to FLASH_OPTKEYR to change the BOOT_ADDRs on the STM32H7xx). But then again, the app note was unclear where the STM32H7xx processor is concerned so maybe I should try that for the STM32F7xx anyway. Thanks.