‎2020-01-03 02:10 AM
Device: STM32L412
Code:
typedef void (*pFunction)(void);
volatile uint32_t addr = 0x1FFF0000;
uint32_t JumpAddress = *(__IO uint32_t*) (addr + 4);
pFunction Jump_To_Boot = (pFunction) JumpAddress;
#if defined(USE_HAL_DRIVER)
HAL_RCC_DeInit();
#endif /* defined(USE_HAL_DRIVER) */
#if defined(USE_STDPERIPH_DRIVER)
RCC_DeInit();
#endif /* defined(USE_STDPERIPH_DRIVER) */
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq();
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
__set_MSP(*(__IO uint32_t*) addr);
Jump_To_Boot();
SOURCE: https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/
I also tried configuring BOOT0 pin as ouput and setting it high before Jump_To_Boot() but without success.
‎2020-01-03 03:16 AM
The hardware method
Add some external components to the pin so it can hold its state for a couple of microseconds.
The software method
Boot pins can be overridden by the nSWBOOT0, nBOOT0, nBOOT1 user option bits
but then you'll have to change them back through the DFU or serial bootloader interface to be able to boot from main flash again.
‎2020-01-03 04:37 AM
Thank you for this very fast and accurate response. Amazing!
:)
(I will implement the hardware method on the next board revision.)