Skip to main content
Zed
Associate III
Dec 2, 2021 10:56 AM UTC
Question

STM32G070KB with RDP set to level 1 with J-Flash kills the device.

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!

This topic has been closed for replies.

10 replies

Uwe Bonnes
Chief
Dec 2, 2021 3:33 PM UTC

What do you mean by "kill"? Does the "magic smoke" excape from the chip.

Zed
ZedAuthor
Associate III
Dec 3, 2021 7:15 AM UTC

The device doesn't respond anymore.

MM..1
Super User
Dec 2, 2021 5:36 PM UTC

Why you waste time AND MONEY when ST LINK exist and woirk..??

Zed
ZedAuthor
Associate III
Dec 3, 2021 7:16 AM UTC

It wasn't my decision, but until this moment everything was working great.

vamsi
Associate II
Feb 19, 2022 7:51 AM UTC

I too had problem writing 0xBB, and lost few boards. This RDP level 1 doesn't seem to be working. This is on STM32G030C8

MM..1
Super User
Feb 20, 2022 6:43 PM UTC

Maybe you can try BOOT pin and system bootloader UART clear RDP back to normal...

vamsi
Associate II
Feb 23, 2022 6:51 AM UTC

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?