cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L073 - Jump to Bootaloader from user code

BSchm.7
Associate

Hi,

we are developing an application on a STM32L073RZT, that needs to jump to the embedded bootloader frim software, since we can not use the BOOT0 pin.

I tried to write a code that jumps to system flash, using the NUCLEO-L073RZ board. In order to achieve this, i took the following code:

void JumpToBootloader(void) {
	void (*SysMemBootJump)(void);
 
	/**
	 * Step: Set system memory address.
	 *
	 *       For STM32F429, system memory is on 0x1FFF 0000
	 *       For other families, check AN2606 document table 110 with descriptions of memory addresses
	 */
	volatile uint32_t addr = 0x1FF00000;	//STML0x3 devices have their system memory at 0x1FF0 0000
 
	/**
	 * Step: Disable RCC, set it to default (after reset) settings
	 *       Internal clock, no PLL, etc.
	 */
	HAL_RCC_DeInit();
 
	/**
	 * Step: Disable systick timer and reset it to default values
	 */
	SysTick->CTRL = 0;
	SysTick->LOAD = 0;
	SysTick->VAL = 0;
 
	/**
	 * Step: Disable all interrupts
	 */
	__disable_irq();
 
    /**
	 * Step: Remap system memory to address 0x0000 0000 in address space
	 *       For each family registers may be different.
	 *       Check reference manual for each family.
	 *
	 *       For STM32F4xx, MEMRMP register in SYSCFG is used (bits[1:0])
	 *       For STM32F0xx, CFGR1 register in SYSCFG is used (bits[1:0])
	 *       For others, check family reference manual
	 */
	SYSCFG->CFGR1 = 0x01;	//according to STM32L0x2 reference manual
 
	/**
	 * Step: 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 *)(0x1FF00000)));
 
	/**
	 * Step: 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 *)0x1FF00000);
 
	/**
	 * Step: Actually call our function to jump to set location
	 *       This will start system memory execution
	 */
	SysMemBootJump();
}

If modified correctly, the code works perfectly on a STM32F303, however i do not manage to reach the bootlaoder with the SMT32L073 (al least i do not get a response via USART). It works if i pull the BOOT0 Pin high, and then reset tzhe device, so the USART connection should be ok. Might this have something to to with the dual bank feature? Is there anything else i need to do before jumping to system memory?

I am thankfull for any help.

Best regards,

Bjoern.

0 REPLIES 0