2021-12-02 02:56 AM
Hi!
Can someone explain to me why this code:
// Is FLASH_CR register locked for writing?
if (FLASH->CR & FLASH_CR_LOCK)
{
// Unlocking FLASH_CR register
FLASH->KEYR = KEY1;
FLASH->KEYR = KEY2;
}
// Unlocking FLASH option register
if (FLASH->CR & FLASH_CR_OPTLOCK)
{
FLASH->OPTKEYR = OPTKEY1;
FLASH->OPTKEYR = OPTKEY2;
}
// Setting RDP level to 1
FLASH->OPTR &= ~FLASH_OPTR_RDP;
FLASH->OPTR |= 0xBB; // Any value except 0xAA and 0xCC
while (FLASH->SR & FLASH_SR_BSY1);
FLASH->CR |= FLASH_CR_OPTSTRT;
while (FLASH->SR & FLASH_SR_BSY1);
// Updating option bytes by resetting of the device
FLASH->CR |= FLASH_CR_OBL_LAUNCH;
kills STM32G070KB device, when was written with J-Flash, but works great with STM32G071CB with the same Errata note for RDP protection.
Same code works great for both MCUs when were written with Segger Embedded Studio.
PS: I'm also posting this question on Segger's forum.
Thank you!
2022-02-23 09:52 PM
With RDP Level 1 being enabled, MCU is not booting up completely once out of 5 times. It is getting stuck even before reaching main(). With this kind of behaviour, indeed we can't deliver the product out. So we are being forced to remove the RDP altogether.