cancel
Showing results for 
Search instead for 
Did you mean: 

after read out protection stm32f4xx stop working

hirenakbari92
Associate
Posted on August 02, 2016 at 08:27

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I

tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

FLASH_OBProgramInitTypeDef pObStruct;
HAL_StatusTypeDef status;
send(''Locking process initialized'');
HAL_FLASH_Unlock();
send(''Flash unlock done'');
HAL_FLASH_OB_Unlock();
send(''Option bytes unlock done'');
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGAERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGPERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_BSY);
send(''all flgs are cleared'');
HAL_FLASHEx_OBGetConfig(&pObStruct);
if (pObStruct.RDPLevel == OB_RDP_LEVEL0)
{
send(''RDP level 0 found'');
pObStruct.OptionType = OPTIONBYTE_RDP;
pObStruct.RDPLevel = OB_RDP_LEVEL1;
send(''set level-1 process initialized'');
status = HAL_FLASHEx_OBProgram(&pObStruct);
send(''RDP memory flags updated'');
if(status == HAL_OK)
{
LED_YELLOW_ON;
send(''Optionbyte launch process initiated for RDP change'');
HAL_FLASH_OB_Launch(); 
send(''Optionbyte sucessfully launched'');
HAL_FLASH_OB_Lock();
send(''Option byte locked'');
HAL_FLASH_Lock();
send(''Flash locked'');
LED_YELLOW_OFF;
send(''System reset initialized'');
NVIC_SystemReset();
send(''blank check'');
LED_RED_OFF;
}
}

/

/************ and this is the result in hyperterminal

controller is initialized
Locking process initialized
Flash unlock done
Option bytes unlock done
all flgs are cleared
RDP level 0 found
set level-1 process initialized
RDP memory flags updated
Optionbyte launch process initiated for RDP change

After this nothing happen ...and if i press reset button nothing happens, nothing received on hyperterminal. after this if i check in st-link software's option byte menu, it shows RDP level is 1.

My objective is to make read out protection so no one can read my code using st-link or from flash code whatever works.

Please let me know if any other information is require. Thank you.

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

#keil #!stm32 #!stm32f4-disco #!stm32f4
6 REPLIES 6
Amel NASRI
ST Employee
Posted on August 09, 2016 at 17:15

Hi akbari.hiren,

Is it possible for you to check the same using another board? Do you have the same behavior?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

udayagle
Associate
Posted on August 23, 2016 at 06:28

Hi akbari.hiren ,

Did you get any solution to your problem , cause i am also  facing the similar problem.

In spite of trying with 5 stm32f446 boards the problem is still persisting.

Posted on August 23, 2016 at 17:20

Do you cycle the power?

Suggest you create a monitor/terminal type application to communicate from the STM32 to understand its internal state and be able to get it into and out of RDP levels interactively. You'll probably want to do this via a USART, and experiment until you are comfortable with how it all works.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Amel NASRI
ST Employee
Posted on August 23, 2016 at 17:26

Hi agle.uday,

Please note that you have to perform a power on reset to be able to run the application when the device is protected with RDP level1. In fact, no debugger should be connected to the target.

Try this way and let me know if it is OK.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

adam23
Associate II
Posted on September 13, 2016 at 11:35

Why should one cycle the power after RDP level 1 is set? I need a code to set the RDP 1 on first start, then self reset and run. Calling NVIC_SystemReset() causes it to hang, I tried also WD but no go - just hangs and does not start again. Is there a way to overcome this?

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

i am using stm32f429 development board and st-link debugger and keil uvision for firmware writing. (for programming i use both st-link utility and keil).

My code is working fine untill i set read out protection(ROP) in option byte at level-1. As soon as i set ROP to level-1 code don't work anymore not even on board LEDs.

After that if i set ROP to level-0 back and reprogram my board it works correctly without any problem at level-0.

I tried to set ROP level in st-link utility. but didn't worked. then i write it in my firmware to do the same, but still it is not working. Below is my code.

//**************** optionbyte set code for stm32f4xx

Jorge Guzman1
Associate
Posted on May 07, 2018 at 22:03

Ran into the very same problem recently with an STM32F303.

Its reference manual mentions:

'

If the read protection is set while the debugger is still connected through JTAG/SWD, apply a POR (power-on reset) instead of a system reset.

'

The solution is therefore to turn off the power to the STM32, and then turn it back on. Your firmware will then run just as well as before.