2023-06-19 04:04 AM - edited 2023-06-19 06:04 AM
Hello everyone,
I have board and I used STM32G071 MCU on this board. I want to activate RDP Level 1. There is my code:
Solved! Go to Solution.
2023-06-20 02:22 AM - edited 2023-06-21 05:53 AM
Hello @RE11
Try to disable Prefech before programming your OB.
Please refer to my test code :
FLASH_OBProgramInitTypeDef OptionsBytesInit= {0};
HAL_RCC_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq();
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
/* Unlock Flash Control register and Option Bytes */
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&OptionsBytesInit);
if(OptionsBytesInit.RDPLevel!=OB_RDP_LEVEL_1){
/* First step: Choose option byte type.*/
OptionsBytesInit.OptionType =OPTIONBYTE_RDP;
OptionsBytesInit.RDPLevel = OB_RDP_LEVEL_1;
/* Program Option Bytes */
HAL_FLASHEx_OBProgram(&OptionsBytesInit);
/* Launch Option Bytes Loading */
HAL_FLASH_OB_Launch();
Regards
DianeP
2023-06-20 02:22 AM - edited 2023-06-21 05:53 AM
Hello @RE11
Try to disable Prefech before programming your OB.
Please refer to my test code :
FLASH_OBProgramInitTypeDef OptionsBytesInit= {0};
HAL_RCC_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq();
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
/* Unlock Flash Control register and Option Bytes */
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&OptionsBytesInit);
if(OptionsBytesInit.RDPLevel!=OB_RDP_LEVEL_1){
/* First step: Choose option byte type.*/
OptionsBytesInit.OptionType =OPTIONBYTE_RDP;
OptionsBytesInit.RDPLevel = OB_RDP_LEVEL_1;
/* Program Option Bytes */
HAL_FLASHEx_OBProgram(&OptionsBytesInit);
/* Launch Option Bytes Loading */
HAL_FLASH_OB_Launch();
Regards
DianeP
2023-06-20 06:11 AM
Hello @Diane POMABIA
Thanks for reply and your help. I will try it for my boards. I want to ask one more question. My some boards crushed after I upload my code. I can not connect them. There is any way to connect them again ? Can I save my boards ?
2023-06-20 08:03 AM - edited 2023-06-23 12:31 AM
@RE11 At this point, you have lost your board, we suspect that your last code have created OB missmatch that have activated your bootlock.
Regards
Diane
2023-06-20 01:20 PM
2023-06-21 06:01 AM - edited 2023-06-21 06:01 AM
We are still analysed the issue. An updated will be done on product document (RM or Errata) when we will finish.
Regards
Diane
2023-06-22 01:01 AM
Hello again @Diane POMABIA
2023-06-23 12:25 AM - edited 2023-06-23 12:30 AM
Hi @RE11
Is it the same board or new board ?
I tested your code on a part and I do not encounter the same problem. Can you confirm me that you are not using the same sample ?
Regards
Diane
2023-06-23 01:55 AM
I'm using same boards but this not happening always. I have many boards and they are same. My some boards working well but some of them when I update my code They are not working again. Also I was having F series board too. I didn't experienced it with F series board. But this time I'm using STM32G071 microcontroller and after I enable RDP Level 1 bootlocking this started to happen. After I tried your solution code this didn't fix. Still my some boards not working again. As i said It is not happening always.
2023-06-23 05:30 AM
Maybe you may try to check state of BOOT_LOCK before trying to set RDP1.
I don't know why would BOOT_LOCK be set, but maybe this is the mechanism through which the chips are "lost".
JW