cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read the level of the BOOT0 pin after boot? Is BOOT0 pin sampled when protection level 2 is enabled?

MSipo
Senior II

I would like to be able to read the BOOT0 pin level at boot.

I tried the following. It reads the BOOT_MODE from the SYSCFG register:

// Turn on blue LED if BOOT0 is low at boot
if (__HAL_SYSCFG_GET_BOOT_MODE() == SYSCFG_BOOT_MAINFLASH)
{
  // BOOT0 pin is low (turn off the blue LED)
  HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_RESET);
}
else
{
  // BOOT0 pin is high (turn on the blue LED)
  HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
}

Then I activated protection level 2, and pulled BOOT0 high. But It does not turn on the blue LED. I tried the blue LED before so I know it worked.

I thought the MCU samples the BOOT0 pin at startup even if protection level 2 is enabled, or am I wrong?

I also tried (on another board) the following to send the hex values from SYSCFG->MEMRMP and FLASH->OBR on the serial port.

uint32_t regValue = SYSCFG->MEMRMP;
sprintf(outString, "SYSCFG->MEMRMP = 0x%08" PRIX32 "\r\n", regValue);
sendString(outString);
 
regValue = FLASH->OBR;
sprintf(outString, "FLASH->OBR = 0x%08" PRIX32 "\r\n", regValue);
sendString(outString);

I got:

SYSCFG->MEMRMP = 0x00000000 <-- Does not indicate the BOOT pins!!!!!!

FLASH->OBR = 0x007800CC <-- CC = protection level 2

  

 The reference manual states that the SYSCFG_MEMRMP shall be updated after reset with the BOOT pins:0693W000007ZUz2QAG.png 

5 REPLIES 5

Hello

>> SYSCFG->MEMRMP = 0x00000000 <-- Does not indicate the BOOT pins!!!!!!

Is SYSCFGEN bit enabled(clock enable for syscfg) before try to read MEMRMP register?

Pavel A.
Evangelist III

Protection level 2 disables booting to the "system memory" bootloader.

So what you see can mean just this.

-- pa

Yes. It is enabled before.

/**
  * Initializes the Global MSP.
  */
void HAL_MspInit(void)
{
  /* USER CODE BEGIN MspInit 0 */
 
  /* USER CODE END MspInit 0 */
 
  __HAL_RCC_COMP_CLK_ENABLE();
  __HAL_RCC_SYSCFG_CLK_ENABLE();   <----- Here it is enabled
  __HAL_RCC_PWR_CLK_ENABLE();
 
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
 
  /* System interrupt init*/
 
  /* USER CODE BEGIN MspInit 1 */
 
  /* USER CODE END MspInit 1 */
}

But the reference manual says:

After reset these bits take the value selected by the BOOT pins.

If this is not so when protection level 2 is selected then ST should make a change to the reference manual.

MSipo
Senior II

Anyone from ST that could comment on this?