Skip to main content
shikha
Associate
Dec 12, 2019 9:18 AM UTC
Question

I have enabled level 1 rop in stm32f030c8, now my code is not working in device and m not able to load fresh code or debuge it using attolics true studio.

here's my code for RDPprotection:

void Flash_SetRDPLevel(uint8_t ReadProtectLevel) //level 1 (0xBB)

{

 uint32_t tmp_reg;

 Unlock();

 OB_unlock();

  /* Read RDP level bits */

  tmp_reg = (FLASH->OBR & (FLASH_OBR_RDPRT1 | FLASH_OBR_RDPRT2));

  //if (tmp_reg == 0U)

  {

  /* proceed to erase the option bytes */

  FLASH->CR |= FLASH_CR_OPTER;

  FLASH->CR |= FLASH_CR_STRT;

  /* If the erase operation is completed, disable the OPTER Bit */

  FLASH->CR &= ~FLASH_CR_OPTER;

  /* Enable the Option Bytes Programming operation */

  FLASH->CR |= FLASH_CR_OPTPG;

   OB->RDP = ReadProtectLevel;

  /* if the program operation is completed, disable the OPTPG Bit */

   FLASH->CR &= ~FLASH_CR_OPTPG;

  }

  Flash_OB_launch();

  OB_lock();

  Lock();

}

at the moment  Flash_OB_launch() is called debugger stops,nothing to do further.

void Flash_OB_launch(void)

{

 /* Set the OBL_Launch bit to launch the option byte loading */

  SET_BIT(FLASH->CR, FLASH_CR_OBL_LAUNCH);

}.

in main i called  Flash_SetRDPLeve() before any other peripheral initialization.

please help asap. thanks in advance.

This topic has been closed for replies.

3 replies

Ozone
Principal
Dec 12, 2019 10:08 AM UTC

Most RDP levels can be undone by booting into system mode (BOOT0/BOOT1 pins), and doing a Flash mass erase.

Cube should come with a tool that supports the system bootloader protocol, and do exactly that.

I'm no Cube user, so check the documentation, or wait for people more proficient in Cubism...

shikha
shikhaAuthor
Associate
Dec 12, 2019 10:41 AM UTC

hey I solved that issue.

thanks for reply:)

TAshe
Visitor II
Apr 1, 2020 4:11 PM UTC

Hi, can you post the solution?