cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7B0 FLASH_SR_RDPERR in HAL_FLASHEx_Erase_IT()

JJ.Lin
Associate III

Hi,

Now the problem is FLASH->SR1 report FLASH_SR_RDPERR in HAL_FLASHEx_Erase_IT() and it failed to erase the BANK1 sector1 of address 0x8002000.I have checked the RDP is level0. What wrong with it ?And the code is here:

    HAL_FLASH_Unlock();  
  
    flash_erase_init.TypeErase = FLASH_TYPEERASE_SECTORS;
    flash_erase_init.Banks = FLASH_BANK_1;
    flash_erase_init.Sector = 1;
    flash_erase_init.NbSectors = 1;
    HAL_FLASHEx_Erase_IT(&flash_erase_init);
 
    HAL_FLASH_Lock();

Thanks!

3 REPLIES 3
TDK
Guru

Don't lock the flash until the operation completes. Use a blocking operation (HAL_FLASHEx_Erase) if you want to wait for it to complete.

There are other methods of locking flash memory other than RDP level. We don't have any insight into your hardware other than what you've posted here. Check PCROP settings.

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

Thank you for your reply! I have found the final cause: UID byte read operation. UID address of STM32H7B0 is 0x08FF F800, and if you access it in uint8_t *, a hardfault may occur. It is okay to access in uint32_t *.

TDK
Guru

Reading the UID causes a flash operation to report RDPERR? That doesn't sound correct.

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