2026-01-05 10:46 PM - edited 2026-01-05 11:01 PM
Hi ST team,
I am using STM32U5G9 MCU.
After modifying option bytes, HAL_FLASH_OB_Launch() would be called to apply the changes.
But in the launch function, it states that "Option byte launch generates Option byte reset". I have other tasks need to be done after calling HAL_FLASH_OB_Launch(). I don't want device to be reset after calling HAL_FLASH_OB_Launch() immedately.
Is there a way to trigger reset manually after modifying option bytes?
1. Modify option bytes
2. Call HAL_FLASH_OB_Launch()
3. Reset device manually
Thank you.
2026-01-06 6:00 AM
You can't change the behavior of HAL_FLASH_OB_Launch. If you have other stuff to do, do it before calling HAL_FLASH_OB_Launch.
2026-01-12 12:54 PM
Hi @wesleywong,
Thanks for your pertinent question and for the details.
On STM32U5, the Reference manual explains the Option‑byte loading (OBL) mechanism as follows:
This means there are two distinct phases:
And the important part: OBL is tied to a reset event. When you call HAL_FLASH_OB_Launch(), the HAL sets OBL_LAUNCH, which triggers the option‑byte load sequence and the device reset.
So you cannot have the exact sequence:
because as soon as step 2 is executed, the hardware will perform the OBL and reset the device.
>> What you can do instead:
If you need to preserve some context across the reset (because HAL_FLASH_OB_Launch() will reset the device), you can backup your application state before triggering the option‑bytes reload. For example:
Please feel free to respond and confirm whether this resolves your request or not.
Best regards,
Hai.