Skip to main content
Visitor II
July 6, 2021
Question

Software reset is occurring on its own again and again

  • July 6, 2021
  • 2 replies
  • 1046 views

I am using NUCLEO STM32L4R5ZI. 

I tried to access the boot mode using the following command

 HAL_FLASH_Unlock();
 while(FLASH->SR & FLASH_SR_BSY)
		 ;
 HAL_FLASH_OB_Unlock();
 while(FLASH->SR & FLASH_SR_BSY)
		 ; 
 FLASH->OPTR &= ~(FLASH_OPTR_nSWBOOT0 | FLASH_OPTR_nBOOT0);
 FLASH->OPTR |= FLASH_OPTR_nBOOT1;
 
 FLASH->CR |= FLASH_CR_OPTSTRT;
 FLASH->CR |= FLASH_CR_OBL_LAUNCH; 
 
 while(FLASH->SR & FLASH_SR_BSY)
		 ;
 HAL_FLASH_OB_Lock();
 while(FLASH->SR & FLASH_SR_BSY)
		 ;
 HAL_FLASH_Lock();
 while(FLASH->SR & FLASH_SR_BSY)
		 ;
 HAL_NVIC_SystemReset();

Now I removed these commands still my system resets on its own again and again.

Thank you.

    This topic has been closed for replies.

    2 replies

    Graduate II
    July 6, 2021

    The processor is only going to run code you have loaded into it.

    Pull BOOT0 HIGH and mass erase the part.

    In the future perhaps gate execution of code like this on the state of a GPIO pin you can change, or some user interaction.

    PMeht.1Author
    Visitor II
    July 6, 2021

    Thank you got the problem solved, but not able to operate uart in boot mode

    while (1)
     {
    	 if(HAL_GPIO_ReadPin(USER_BUTTON_GPIO_Port, USER_BUTTON_Pin))
    	 {
    		 Bootloader_JumpToSysMem();
     
    	 }
     }
    void Bootloader_JumpToSysMem(void)
    {
    	void (*SysMemBootJump)(void);
    	volatile uint32_t BootAddr = 0x1FFF0000;
     
    	/* Set up the jump to booloader address + 4 */
    	SysMemBootJump = (void (*)(void)) (*((uint32_t*) ((BootAddr + 4))));
     
     HAL_RCC_DeInit();
     HAL_DeInit();
     
     SysTick->CTRL = 0;
     SysTick->LOAD = 0;
     SysTick->VAL = 0;
     
     __HAL_RCC_SYSCFG_CLK_ENABLE();
     __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
     
     __set_MSP(*(uint32_t*) BootAddr);
     SysMemBootJump();
     
     while(1)
     ;
    }