cancel
Showing results for 
Search instead for 
Did you mean: 

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

Zed
Associate II

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!

10 REPLIES 10
Uwe Bonnes
Principal III

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

MM..1
Chief III

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

The device doesn't respond anymore.

Zed
Associate II

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

vamsi
Associate II

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

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

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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?

Why you mean no. When you change RDP back chip is erased = data is protected