‎2020-10-30 02:22 AM
Hi,
I have an stm32l43 connected as a USB device. Using the BOOT0 pin, I can start the built-in Bootloader and use DFU. Now I wish to jump to the BL without this Pin by a software jump.
But with this jump, I only seem to reset the device (my code starts again like after a reset). It seems to me that the Bootloader starts, checks for valid code in flash and then streight jumps back there (as my firmware of course is valid code).
How can I get the Bootloader staying active without using a boot pin or an option bit?
here is my jump function for reference:
void jump2STinternalBootloader(void){
void (*SysMemBootJump)(void);
/**
* Set system memory address.
* check AN2606 document for descriptions of memory addresses
*/
volatile uint32_t addr = 0x1FFF0000;
/**
* Disable RCC, set it to default (after reset) settings
* Internal clock, no PLL, etc.
*/
HAL_RCC_DeInit();
/**
* Disable systick timer and reset it to default values
*/
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
/**
* Disable all interrupts
*/
__disable_irq();
/**
* Remap system memory to address 0x0000 0000 in address space
*/
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
/**
* Set jump memory location for system memory
* Use address with 4 bytes offset which specifies jump location where program starts
*/
SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));
/**
* Set main stack pointer.
* This step must be done last otherwise local variables in this function
* don't have proper value since stack pointer is located on different position
*
* Set direct address location which specifies stack pointer in SRAM location
*/
__set_MSP(*(uint32_t *)addr);
/**
* Actually call our function to jump to set location
* This will start system memory execution
*/
SysMemBootJump();
while(1);
}
Solved! Go to Solution.
‎2020-11-03 01:51 AM
Thanks for update. Don't hesitate to select your post as Best Answer in order to close this thread (I did it for you this time ;) ).
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.