cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G071 write protection, bricked MCU flash

SAlek
Associate II

Hello, MCU bricked after I tried to remove write protection. Now when I read the flash it shows only 0xFFFF0080. Read the full description bellow.

0693W000008GRaUQAW.jpg 

We are making new project using STM32G071.

We use serial communication custom bootloader so we can update firmware online using our internet gateways (this is other our product).

So in order to protect the bootloader from unintentional write we are locking the first 6 pages where is located the bootloader. However because we are still in development phase I need to occasionally reprogram the prototype with custom programs. Now this is when the problems start.

The first thing that I notice after the project started is that I couldn't remove the write protection from the option bytes of all 6 pages simultaneously. I found a procedure that works:

1 remove the write protection from page 0;

2 erase the page 0

3 remove write protection from pages 1-5

4 full flash erase

0693W000008GRfyQAG.jpg 

This was working fine until now. Today I tried to erase again but on the second step - erasing page 0, the MCU just bricked. After this we tried mutliple ways to erase the flash. We tried using ST-link utility and ST-link, we tried using CubeProgrammer with ST-link, we tried using Segger J-FLASH with Segger Flasher and still the problem remains. My colleague develop other project using the same MCU, he also was using the same erasing procedure but today he tried too, and he stucked at step 1, he cant remove the write protection from page1.

There is definitely some problem, I see that other people have similar problem

https://community.st.com/s/question/0D53W00000YvZSNSA3/flash-bricked-after-rdp-changes-on-several-stm32g0?t=1613571588618

https://community.st.com/s/question/0D53W00000YyDfwSAF/g070-programming-issue

 I also think that such unlocking procedure shouldn't be needed at all.

Additional information:

//Write protection locking procedure

    FLASH_OBProgramInitTypeDef OBInit;

    HAL_FLASHEx_OBGetConfig(&OBInit);

    if((OBInit.WRPStartOffset == 63)&&(OBInit.WRPEndOffset == 0))//i.e. no write protection.

    {

       OBInit.OptionType = OPTIONBYTE_WRP;

       OBInit.WRPArea = OB_WRPAREA_ZONE_A;

       OBInit.WRPStartOffset = 0;

       OBInit.WRPEndOffset = 5;

       HAL_FLASH_Unlock();

       HAL_FLASH_OB_Unlock();

       //ERASE?

       HAL_FLASHEx_OBProgram(&OBInit);

       HAL_FLASH_OB_Launch();

    }

3 REPLIES 3
Piranha
Chief II

And what's with the "Connect Under Reset" mode?

SAlek
Associate II

Unfortunately nothing to do with it. I usually am working under this mode but it doesn't matter how I set it.

SAlek
Associate II

Hello,

With the help of ST support, I will share the solution of this problem to you.

Set the option byte PCROP_RDP to 1.

Set the read protection to Level 1 (BB)

Set the read protection again to Level 0.

This procedure force reset the flash.