cancel
Showing results for 
Search instead for 
Did you mean: 

Setting BORF on STM32G041F8 bricks the processor???

STM32CubeProg 2.19.0.  STM32G041F8. MacOS 15.5. ST-Link.

I'm working on setting the brown-out rising, falling, and enable options on an STM32G041F8.

I started out by just using CubeProg to set the BOR_EN enable bit in the option bytes. Works correctly. It gives me the reaction I expected and I'm able to reconnect via CubeProg.

Next I wanted to set the BORF_LEV to something other than 3 so I can test my code. I set it to 1, hit Apply, Cube prog complains that the connection is lost and it has disconnected from the device, and now when I try and connect I just get:

17:13:46 : UR connection mode is defined with the HWrst reset mode
17:13:46 : ST-LINK SN  : 31FF6A064D4E353828580643
17:13:46 : ST-LINK FW  : V2J46S7
17:13:46 : Board       : --
17:13:46 : Voltage     : 3.31V
17:13:46 : Error: Unable to get core ID
17:13:46 : Error: No STM32 target found! If your product embeds Debug Authentication, please perform a discovery using Debug Authentication

No, I did not mess with the RDP values, just BORF_LEV.

CubeProg can't unbrick it. CubeIDE gets similar results. Unfortunately, for me, I duplicated the result in another processor so I thought I'd stop and reach out.

Any ideas as to how to unlock these things?

Thanks,

Andrei (your neighbour from The Great White North) 

2 REPLIES 2

Okay, I officially hate this.

I figured that, since this topic got moved to the CubeProg list instead of the MCU products list, someone within ST had a thought that CubeProg is the problem. So I went ahead with my program. I wrote:

#define BORR_LEVEL OB_BOR_LEVEL_RISING_1
#define BORF_LEVEL OB_BOR_LEVEL_FALLING_1

void MachineInit(void) {
	/* OB Program structure */
	FLASH_OBProgramInitTypeDef FLASH_OBInitStruct;
	bool needsLock = false;

	/*
	 * Arrange for the highest brown out detect possible.
	 */

	HAL_FLASHEx_OBGetConfig(&FLASH_OBInitStruct);

	if (((FLASH_OBInitStruct.USERConfig & FLASH_OPTR_BOR_EN_Msk) != FLASH_OPTR_BOR_EN) ||		// BOR must be enabled
			((FLASH_OBInitStruct.USERConfig & FLASH_OPTR_BORR_LEV_Msk) != BORR_LEVEL)  ||		// Rising BOR must match needs
			((FLASH_OBInitStruct.USERConfig & FLASH_OPTR_BORF_LEV_Msk) != BORF_LEVEL))			// Falling BOR must match needs
	{
		(void) HAL_FLASH_Unlock();
		(void) HAL_FLASH_OB_Unlock();

		FLASH_OBInitStruct.OptionType = OPTIONBYTE_USER;
		FLASH_OBInitStruct.USERType = OB_USER_BOR_LEV;
		FLASH_OBInitStruct.USERConfig = BORR_LEVEL | BORF_LEVEL;
		HAL_FLASHEx_OBProgram(&FLASH_OBInitStruct);

		FLASH_OBInitStruct.OptionType = OPTIONBYTE_USER;
		FLASH_OBInitStruct.USERType = OB_USER_BOR_EN;
		FLASH_OBInitStruct.USERConfig = OB_BOR_ENABLE;
		HAL_FLASHEx_OBProgram(&FLASH_OBInitStruct);

		(void) HAL_FLASH_OB_Launch();

		needsLock = true;

	}

	if (needsLock) {
		/* Locks the option bytes block access */
		HAL_FLASH_OB_Lock();
		HAL_FLASH_Lock();
	}
}

and it worked. CubeProg now shows that the enable bit is set and the BOR levels are set to 1.

Screenshot 2025-05-27 at 14.33.10.png

So I change my code to the way that I need it:

#define BORR_LEVEL OB_BOR_LEVEL_RISING_3
#define BORF_LEVEL OB_BOR_LEVEL_FALLING_3

no other changes. Run the program and the net result in CubeIDE is:

Screenshot 2025-05-27 at 14.37.58.png
CubeProg won't talk to it either.
Another bricked processor.

Hello @Andrei Chichak,

 

Apologies for the delayed response. 

Could you please attempt to connect the target under reset using STM32CubeProgrammer?

 

Maryem.


In order 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.