Writing to the FLASH_OPTR to switch banks
I am designing a system that will utilize the dual bank feature of the STM32 devices to make a robust system for OTA updates. I am currently using a STM32U545 for my project and have questions about writing to the FLASH_OPTR to change the SWAP_BANK bit.
My setup has an external microcontroller connected to my STM32U545 that interfaces through UART and has control of the BOOT0 pin and the RST pin of the STM32 device. I was confused by the statement in the AN3155 pg. 20 when it talked about the Write Memory command and said "If the Write Memory command is issued to the option byte area, all bytes are erased before writing the new values, and at the end of the command the bootloader generates a system
reset to take into account the new configuration of the option bytes". What does it mean by all bytes are erased?
My current plan was to use the read memory command and read the register FLASH_OPTR at 0x4002 2040 and then read bit 20 of that register(SWAP_BANK bit) then perform an operation on that bit to swap the banks. Then I would write the new value of the register using the Write Memory Command. My initial thought was that I only needed to read 4 bytes and then write 4 bytes, but after researching I am concerned if that would be problematic. Will it be a problem to only try to read/write the 4 bytes of the reigister?

