Skip to main content
Associate II
July 30, 2025
Question

Full Chip erase memory error

  • July 30, 2025
  • 1 reply
  • 183 views

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

TDK
Super User
July 30, 2025

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""."