cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to detect STM32G070RB MCU on ST link

K_K
Associate II

Hello,

I am facing problem where ST link is not able to detect the MCU.

My board was programmed and functional but for some reason we have to change the code and we programmed the hex file.

Afterwards that MCU is not being detected in STLINK tool/STM cube programmer and also the code execution is not happening.

This problem I faced in 14 out of 60 boards those we programmed using the same hex file.

  1. SWD connections are OK in all non working boards.
  2. Reset pin is high. I tried to pull it low and then tried to "connect under reset" mode, but not connecting.
  3. Tried hot plug and normal mode.
  4. ST link tool is working.

It is not a hardware problem. I am 100% sure but I checked again and no issue found.

My code has read protection level-1 before main loop as shown below and I am doubting on it. In any case if it is doing read protection level-2 then MCU will no longer accessible.

FLASH_OBProgramInitTypeDef OBInit;
 
 void enable_read_protection(void) 
{ 
	HAL_FLASHEx_OBGetConfig(&OBInit);
 
	if(OBInit.RDPLevel == OB_RDP_LEVEL_0) 
	{ 
		/* Unlock the Flash to enable the flash control register access *************/ 
 
		HAL_FLASH_Unlock();
 
 
		/* Unlock the Options Bytes *************************************************/
 
		HAL_FLASH_OB_Unlock(); 
			
 		OBInit.OptionType = OPTIONBYTE_RDP; 
		OBInit.RDPLevel  = OB_RDP_LEVEL_1; 
	
 
	       HAL_FLASHEx_OBProgram(&OBInit);  			
 
		if (HAL_FLASH_OB_Launch() != HAL_OK) 
		{
 
			/* User can add here some code to deal with this error */
 
			HAL_FLASH_OB_Lock();
 
			HAL_FLASH_Lock();
 
			while (1)
 
			{
 
			}
 
		}
 
	 }
 
	 HAL_FLASH_OB_Lock();
 
	 HAL_FLASH_Lock();	 
 
}
  1. Do you think this code is causing this problem?
  2. Anyway to recover the MCU?

I will be really thankful if you can point out something.

Thanks

1 REPLY 1
K_K
Associate II

Hello,

Looking for your help! Please let me know if I should try anything.

I am stuck.

Thanks.