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!
2021-12-02 07:33 AM
What do you mean by "kill"? Does the "magic smoke" excape from the chip.
2021-12-02 09:36 AM
Why you waste time AND MONEY when ST LINK exist and woirk..??
2021-12-02 11:15 PM
The device doesn't respond anymore.
2021-12-02 11:16 PM
It wasn't my decision, but until this moment everything was working great.
2022-02-18 11:51 PM
I too had problem writing 0xBB, and lost few boards. This RDP level 1 doesn't seem to be working. This is on STM32G030C8
2022-02-20 10:43 AM
Maybe you can try BOOT pin and system bootloader UART clear RDP back to normal...
2022-02-20 10:55 AM
Doesn't seem to be working, or locking out access for people to touch and access device internals?
Does the code running internally on the chip continue running? Did you implement a method to recover / mass-erase?
As MM indicates some of these devices need to be walked out of the protection modes via the ROM loader. Segger used to have specific recovery tools
2022-02-22 10:51 PM
It works, but we want to deliver the products with RDP Level 1 to customer. Now I'm skeptical is this RDP Level 2 flawless?
2022-02-23 08:34 AM
Why you mean no. When you change RDP back chip is erased = data is protected