on 2025-02-11 07:38 AM
Sharing a MCU board between multiple users may be sometimes challenging when someone makes a modification on the board or in the MCU option bytes and doesn’t notify about it. Additionally, the board owner might forget the changes applied previously to his board or in the option bytes. These situations often result in unexpected behavior of the application, leading to significant time being wasted.
If you have recovered a board from your colleague that you use for a test or a development, the first recommended thing to do is to restore the option bytes to their factory values.
For this reason, two features have been implemented in STM32CubeMX. This article describes how to restore the option byte factory reset configuration. This feature is available starting from STM32CubeProgrammer V2.18.0.
Note that not all options bytes are restorable. For example, the RDP lever from RDP L2 to 0 is not possible. This is by product construction.
This option supposes that you did not modify the option bytes on the MCU. This is especially useful after purchasing a new STM32 MCU or new STM32 based board where you can export the factory option bytes to save them elsewhere. Afterwards, you can import them when you need to restore the option bytes factory values.
Connect to the STM32 with STM32CubeProgrammer either with ST-LINK or with bootloader, and:
Figure 2. Saving the option bytes file config
At this stage, the factory option bytes values are stored on your hard drive. You will use it when needed.
Consider you did some modifications in the option bytes and you need to restore it without taking care about all the modifications you performed previously. In this section, we describe how to restore the MCU option bytes to the factory reset values with the import option.
Connect to the STM32 with STM32CubeProgrammer either with ST-LINK or a bootloader, and:
Figure 3. Importing option bytes in “OB” menu
Figure 4. Opening the option bytes file config
Figure 5. Applying the new option bytes config (factory values)
At this stage, the option bytes have been restored to their factory values.
This option is very simple to use as it is done in a simple click without any other operation.
Note that this option has occurred in the STM32CubeProgrammer V2.18.0 and available only for the STM32U5 family for now. But it will be deployed gradually on other STM32 MCU families in the future.
All you need to do is to connect the MCU to the STM32CubeProgrammer,
Figure 6. Using “Reset MCU to Factory Settings” option
Figure 7. Applying the option factory settings
Figure 8. Waiting for the operations to complete
In this article two methods to restore the option bytes to their factory reset have been described step by step. One is based on the Export/Import feature and the other is based on the [Reset MCU to Factory Settings] option.