2022-01-20 06:44 PM
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!
2022-01-24 05:17 PM
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.
2022-01-24 11:22 PM
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 *.
2022-01-25 05:47 AM
Reading the UID causes a flash operation to report RDPERR? That doesn't sound correct.