cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to trigger STM32L431 USART1 bootloader via SW

Lex
Associate III

Hi guys,

I could set MCU into bootloader mode manually by using PH3/Boot0, but I can't get trigger bootloader via SW... 

I did check previous posts, but somehow it does not help.

HW setup: I have dev board with STM32L431. It has USART1 (PA9, PA10) connected to CP2105, which connected to the linux pc.

So far I wonder about these points:

  •  Based on other posts, could someone confirm that system memory address on STM32L431 is 0x1FFF0000 (as in AN2606) ?
  • Is __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() step needed on STM32L4?
  • Anything else shall be changed in the code?
  • Could CP2105 somehow affect the overall result?
  • Any other suggestion or clues why triggering bootloader via SW does not work?

Relevant code:

void JumpToBootloader(void)
{
    uint8_t i;
    void (*SysMemBootJump)(void);
    volatile uint32_t addr = 0x1FFF0000;

    __disable_irq();

    SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;

    HAL_RCC_DeInit();

    for (i = 0; i < (sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0])); i++) {
      NVIC->ICER[i] = 0xFFFFFFFF;
      NVIC->ICPR[i] = 0xFFFFFFFF;
    }

    __enable_irq();

    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

    SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));
    __set_MSP(*(uint32_t *)addr);
    SysMemBootJump();
}

 

 

 

 

 

3 REPLIES 3

> I can't get trigger bootloader via SW

How do you know?

Did you single-step the code above, or tried to stop it while running?

> Is __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() step needed on STM32L4?

If if does what its name promises (I don't use Cube/HAL), then yes - you need to map the system memory to address 0, as that is what the hardware does when you activate the bootloader, and the bootloader expects it to be mapped there. You may also make sure that VTOR is set to the default value of 0. You may also want to reset all peripherals in RCC during that process - essentially, you want to undo everything your program did with the mcu's registers until this point.

JW


@waclawek.jan wrote:

> I can't get trigger bootloader via SW

How do you know?


I checked it by two different ways:

1. I see that after JumpToBootloader() is executed, MCU is restarted with normal boot printouts.

2. By using STM32CubeProgrammer and trying to open /dev/ttyUSB1, which fails (and works if manually set boot mode).

I also saw a note in 2606 that "Due to empty check mechanism present on this product, it is not possible to jump from user code to system bootloader." However, it was stated for STM32L0 and absent for STM32L4 MCUs. Still wonder if it could be the case..

∕Lex

 

You still can single-step the jump in debugger, preferrably in disasm view. That should reveal, what's happening.

JW