1

I was having trouble on the STM32L462xx with setting the device up for flashing over USB without having access to the BOOT0 pin. Going off of the tutorial on the ST site didn't seem to accomplish the task. Has anyone successfully set the STM32L4 into bootloader mode from software?

https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/

falon89
  • 116
  • 1
  • 5
  • Welcome to Stack Overflow, and thanks for information that others might find useful. You seem to have posted an answer in the question area, though. Please write a well-formed question that describes what you are trying to do and what issues you were facing, and then feel free to post an answer to your own question. – David Grayson Mar 09 '21 at 02:22

1 Answers1

2

I was able to set the device into a mode which it can be programmed with STM32Cube Programmer or the DFU-util program using the following code. This is partly a signal boost for this programmers solution which went against the ST tutorial on their site saying how to put jump the device memory to bootloader for USB programming

https://github.com/markusgritsch/SilF4ware/blob/94bb679119a0b9879fedc62a5e22f40623433242/SilF4ware/drv_reset.c

void jump_to_bootloader(void)
{
    __enable_irq();
    HAL_RCC_DeInit();
    HAL_DeInit();
    SysTick->CTRL = SysTick->LOAD = SysTick->VAL = 0;
    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

    const uint32_t p = (*((uint32_t *) 0x1FFF0000));
    __set_MSP( p );

    void (*SysMemBootJump)(void);
    SysMemBootJump = (void (*)(void)) (*((uint32_t *) 0x1FFF0004));
    SysMemBootJump();

    while( 1 ) {}
}
falon89
  • 116
  • 1
  • 5