Skip to main content
Zed
Associate III
December 2, 2021
Question

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

  • December 2, 2021
  • 3 replies
  • 3849 views

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.

3 replies

Uwe Bonnes
Chief
December 2, 2021

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

Zed
ZedAuthor
Associate III
December 3, 2021

The device doesn't respond anymore.

MM..1
Chief III
December 2, 2021

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

Zed
ZedAuthor
Associate III
December 3, 2021

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

vamsi
Associate II
February 19, 2022

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
Chief III
February 20, 2022

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

vamsi
Associate II
February 23, 2022

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?