cancel
Showing results for 
Search instead for 
Did you mean: 

How to erase and modify option bytes bytes in STM32WB55CGU6?

Lzhao
Associate II

0690X000009jBcIQAU.png

FLASH_CR:0690X000009jBcgQAE.png

5 REPLIES 5
Remi QUINTIN
ST Employee

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.

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?

0690X00000ApNa4QAF.png0690X00000ApNZzQAN.png

The Flash memory erase operation can be performed at page level (Page Erase), or on the whole memory (mass erase). Mass erase does not affect the Information block (system Flash, OTP and option bytes).(Original Chip Manual)

Remi QUINTIN
ST Employee

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.