2025-02-23 12:53 PM
Hello, I am trying to write to the option byte area of an stm32u5g9vjt6q using the built in bootloader over the canFD protocol. I have verified I am able to erase and write my programs to flash over canFD using the built in boot loader so I know that my python script is working so far. As far as option byte data is concerned the information is scattered and scarce, I think I have identified the correct option byte base address as 0x4002 2040 as that is the address that is written to when updating option bytes from within cubeProg. I have also verified in RM0456 table 6 memory map that the flash registers are 0x4002 2000 - 0x4002 23FF and using table 79(flash register map) found at offset 0x40 is register FLASH_OPTR.
AN5405 does not go deep into writing option bytes but I assume it unlocks and writes the keys to be able to write to the option bytes when it receives an address matching the option byte area as outlined in the USART bootloader ref manual.
I also assume that I should be writing all 64bytes of option byte data, if my math is correct it looks like the option bytes occupy 64 bytes for memory.
Can someone confirm the following
- That the option byte base address is correct (0x4002 2040).
- I should perform a 64 byte read at 0x4002 2040 to download all of the option byte data.
- Modify the option bytes I want to change out of the downloaded 64 bytes.
- Write the modified 64 bytes back to 0x4002 2040.