cancel
Showing results for 
Search instead for 
Did you mean: 

Empty check flag on STM32F030 (option bytes)

Stabilo
Associate III

Hello,

I have a problem when flashing my MCU (STM32F030CCT).

After flashing, a Power On reset is always needed to start my SW (to reload the option bytes due to the "empty check flag").

From manual:

On STM32F070x6 and STM32F030xC devices only, internal empty check flag is implemented to allow easy programming of the virgin devices by the boot loader. This flag is used when BOOT0 pin is defining Main Flash memory as the target boot area. When the flag is set, the device is considered as empty and System memory (boot loader) is selected instead of the Main Flash as a boot area to allow user to program the Flash memory. This flag is updated only during Option bytes loading: it is set when the content of the address 0x08000 0000 is read as 0xFFFF FFFF, otherwise it is cleared. It means a power on or setting of OBL_LAUNCH bit in FLASH_CR register is needed to clear this flag after programming of a virgin device to execute user code after System reset.

I don't want to have to apply a POR after flashing. This is a requirement of our end of line process.

So I am wondering how I can retrieve the information "empty flag active" so I can reload by myself the option bytes using the OBL_LAUNCH ?

Thanks a lot !

3 REPLIES 3

Cross posted into this thread https://community.st.com/s/question/0D50X00009kIWzJSAW/stm32f030rct6-and-stm32f030cct6-dont-reset-after-being-programmed-from-blank-flash

Not sure you get to read it, but you should be able to jump into arbitrary code from the System Loader, and start executing your own code from there. The ROM may have started the Watchdog, so you might need to kick that if it is active.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Stabilo
Associate III

Thanks for your response.

After my very first flash programming, my code starts, but it crashes at the OSC initialization. POR solves the problem because option bytes are reloaded after POR.

So my idea was to detect directly in my main() if it is the first programming or not. If yes, I could reload my option bytes there. But I don't know how to get the information "first programming".

I would suggest checking what memory is mapped into the zero address region, ie ROM or FLASH

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..