cancel
Showing results for 
Search instead for 
Did you mean: 

Flash erase error on STM32L151CB-A

URaic
Associate II

I am trying to store configuration data in flash on the STM32L151CB-A using the HAL libraries. I reserved the last page in flash for this. However, I see that already at the beginning of main the OPTVERR bit is set. (FLASH->SR: 0x80C) I never programmed the options bytes myself but got the STML151CB-A preprogrammed (within the RAK811 LoRa chip).

When reading the option bytes I see:

0x1ff800000: SPRMOD and RDP: 0x0xff5500aa which looks ok.

0x1ff800004: USER : 0x000000000 looks strange to me. However, the OPTVERRUSER bit is not set!

The FLASH->OBR register reads 0x7800aa

The reference manual says that the error bits are cleared by writing 1. What does this mean?

Do I have to set the corresponding bit? I tried to write 0x800 to FLASH-SR but this has no effect.

What are the factory settings of the options bytes ?

I tried the same program on the STM32F103C8T6 where erasing and writing the flash works fine.

Thanks for your help

Uli

2 REPLIES 2
URaic
Associate II

In the meatime I managed to clear the error. Writing the bit which cause the error with the bit set cleared the error bit.

Erasing the sector and writing it now works fine. I still do not understand where the error comes from in the first place (it is created when the machine is started up) and knowing the factory settings of the options bytes would help

I have the same problem like @URaic​ in a MxCube4.27 generated project for a STM32L46VET6.

At the beginning of main() FLASH.SR.OPTVERR is already high :(.

0690X000006D8KaQAK.jpg