cancel
Showing results for 
Search instead for 
Did you mean: 

Set ROP 1 from code without POR

Flint
Associate II

Hello everyone,

we are developing a product using STM32F413.

We got a new requirement, that the chip needs to activate ROP level 1. We want to do this from firmware code, if possible.

I noticed that after flashing my firmware and running the code that activates the ROP, the mcu stops working until i perform a power on reset. The ROP is set to level 1 after the power on reset, as expected. The need for the power on reset seems to be caused by not having a power on reset between using the programmer and setting the ROP level. Problem is, that we have a huge super-cap on the board, buffering the power, so a power on reset is out of the picture for production.

I know that for STM32L0x3, there was a way around this by performing a wakeup from standby instead of a POR. I had no luck implementing the same for STM32F413. Is there any way to set the ROP from a just flashed firmware without doing a power on reset?

 

From RM0367 Rev8 chapter 3.4 (stm32l0x3 ref manual):

Flint_0-1707913768430.png

im in the situation described in the note, but on another chip. what can i do?

1 ACCEPTED SOLUTION

Accepted Solutions

I found the solution to my problem. ST uploaded some youtube videos, explaining the problem and the solution.

For STM32L4xx:

https://www.youtube.com/watch?v=f7vs0NwZPFo

Modification for STM32F4xx:

https://www.youtube.com/watch?v=S_6MavJFREU

Cant say I understand the explaination, but you dont argue with results.

 

View solution in original post

3 REPLIES 3
TDK
Guru

On the F4 series you can set the option byte, then launch them to apply. This causes a system reset. Does that work for you?

This is typically done by checking the option byte at the start of the program. If it's not what you want, then it's modified and lauched and the chip resets. When it comes back up, the check passes.

If you feel a post has answered your question, please click "Accept as Solution".
Flint
Associate II

No. Flashing this code hangs the Chip. Blue LED is on, Yellow LED is off. After a Pin-Reset, no LED is on. Only after a power on reset, both LEDs get on and i can read that the POR Level is set to 1 using the programmer. My problem is, that i can not do a power on reset in production.

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();

  HAL_GPIO_WritePin(LED_BL_GPIO_Port, LED_BL_Pin, GPIO_PIN_SET);
  (void) rop_enable();
  HAL_GPIO_WritePin(LED_YE_GPIO_Port, LED_YE_Pin, GPIO_PIN_SET);

  MX_DMA_Init();
  MX_IWDG_Init();
bool rop_enable(void)
{
	FLASH_OBProgramInitTypeDef config;

	HAL_FLASHEx_OBGetConfig(&config);

	//readout protection is enabled -> exit
	if(config.RDPLevel == OB_RDP_LEVEL_1)
	{
		return true;
	}

	config.OptionType = OPTIONBYTE_RDP;
	config.RDPLevel = OB_RDP_LEVEL_1;

	//set readout protection in interrupt protected environment
	if(HAL_FLASH_Unlock() != HAL_OK)
	{
		return false;
	}

	if(HAL_FLASH_OB_Unlock() != HAL_OK)
	{
		return false;
	}

	if(HAL_FLASHEx_OBProgram(&config) != HAL_OK)
	{
		return false;
	}

	if(HAL_FLASH_OB_Launch() != HAL_OK)
	{
		return false;
	}

	if(HAL_FLASH_OB_Lock() != HAL_OK)
	{
		return false;
	}

	if(HAL_FLASH_Lock() != HAL_OK)
	{
		return false;
	}

	return true;
}

 

I found the solution to my problem. ST uploaded some youtube videos, explaining the problem and the solution.

For STM32L4xx:

https://www.youtube.com/watch?v=f7vs0NwZPFo

Modification for STM32F4xx:

https://www.youtube.com/watch?v=S_6MavJFREU

Cant say I understand the explaination, but you dont argue with results.