cancel
Showing results for 
Search instead for 
Did you mean: 

Full Chip erase memory error

JamesMoriarty
Associate II

Hi.
I am developing a bootlaoder Code by using STM32U073MCT6.
when ı am using code protection code which is below, RDP is becoming BB however, after this process, when I turn on back protection (AA) I get an error when doing a full chip erase. it says Mass erase operation failed. Please verify flash operation.


protection code

void ReadProtection(void)
{
FLASH_OBProgramInitTypeDef obConfig;

    // Clear all FLASH flags
    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);

    HAL_FLASHEx_OBGetConfig(&obConfig);

    if (obConfig.RDPLevel == OB_RDP_LEVEL_0)
    {
        // this is first time we run mcu after flashing firmware
        obConfig.RDPLevel = OB_RDP_LEVEL_1;

        HAL_FLASH_Unlock();
        HAL_FLASH_OB_Unlock();

        HAL_FLASHEx_OBProgram(&obConfig);

        HAL_FLASH_OB_Launch();

        HAL_FLASH_OB_Lock();
        HAL_FLASH_Lock();
    }
}

 

Edited by ST Moderator to apply source code formatting - Please follow the recommendation in this article How to insert source code

 
 
1 REPLY 1
TDK
Super User

So the code posted works as expected?

> when I turn on back protection (AA) I get an error when doing a full chip erase

How are you doing this? Show the error.

If you feel a post has answered your question, please click "Accept as Solution".