Skip to main content
Lzhao
Associate II
Sep 25, 2019 9:47 AM UTC
Question

How to erase and modify option bytes bytes in STM32WB55CGU6?

​

0690X000009jBcIQAU.png

FLASH_CR:0690X000009jBcgQAE.png

This topic has been closed for replies.

5 replies

Remi QUINTIN
ST Technical Moderator
Oct 9, 2019 5:01 PM UTC

As a user you can get access (read/write) to any option bytes controlled by the CPU1.

All option bytes managed by CPU2 remain inaccessible and can’t be modified.

The OPTSTRT bit triggers the reloading of the option bytes to take into account all the changes.

Lzhao
LzhaoAuthor
Associate II
Oct 10, 2019 1:28 AM UTC

Yes, you're right. Users really can't change the option bytes managed by CPU2 directly. According to the value of FLASH_CR, you can see that there is no erase flag bit for selection bytes above. MER/PER is for flash memory. How can I erase and rewrite the option bytes managed by cpu1?

Remi QUINTIN
ST Technical Moderator
Oct 10, 2019 3:08 PM UTC

Set the Options Start (OPTSTRT) bit OPTSTRT in the FLASH_CR register to trigger the update of the option bytes values and wait for the BSY bit of the FLASH_SR register to be cleared.

The option bytes are located in a special part of the Flash memory (see table 9 in the RM to get the exact addresses). Programming or erasing the Flash memory is only done page per page or completely (Mass erase). So this takes time as the complete page containing the option bytes are reprogrammed. Hence the need to wait for the BSY bit to be cleared.