cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader on MCU

RComa.1
Associate II

Hello everyone, i've been coding a bootloader for STM32L072 MCU's, i can download the binary file and write it into FLASH memory from specific address, all this process works, but at the time to jump to the code to be executed, it doesn't work...i checked the memory by debugging and the code has been wrote,so i cannot understand why it doesn't run. have i create a memory area in the .id file?

The firmware has to be placed from 0x8008000, i am not sure if i have to create a specific area for this... like this:

0693W00000LyIBzQAN.jpg 

and make section like this...:

0693W00000LyICdQAN.jpg the code to jump and check if there is firmware already is the following:

#define FLASH_APP_ADDR		0x8008000
void go2APP(void){
 
	uint32_t jumpAddress;
	pFunction jump_to_app;
 
	if(((*(uint32_t*)FLASH_APP_ADDR) & 0x2FFE0000) == 0x20000000){ //Comproba si hi ha una app instalada
		//jump to the App
		jumpAddress = *(uint32_t*) (FLASH_APP_ADDR + 4);
		jump_to_app = (pFunction)jumpAddress;
		//Inicialitza el stack de la app
		__set_MSP(*(uint32_t*)FLASH_APP_ADDR);
		jump_to_app();
	}
}

When it jumps it makes a hardfault..but i am not sure whether i have to create the APP_MEM area for this purpose or not...

Anyone can help me?¿

thanks a lot.

4 REPLIES 4

Forget creating a new section, just move the FLASH​ one so it has a different start address.

T​here are multiple references in the linker script to direct content and vectors there. Review .MAP file to see where everything is placed.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RComa.1
Associate II

Hi, firstable thanks for your answer, so i have been reviewing the .MAP file and i have found the following part:

0693W00000LyJhmQAF.jpgIs 0x8000000 the real start address of FLASH?¿ in .id file the origin is 0x8000000, so i don't understant what i have to look up in this file...i never see a .MAP file before so i don't know how to read it

Thanks.

RComa.1
Associate II

I came up with the idea to see in the .MAP file of Firmware (not the bootloader) and i see that isr_vector starts at 0x8008000

0693W00000LyJsLQAV.jpgSo it is right considering that i jump from the bootloader to that address...am i wrong?¿

1) Make sure that firmware you place at 0x8008000 compiled with FLASH ORIGIN = 0x8008000

2) Try de-initialize peripherals at the beginning of go2APP() function, something like this:

HAL_UART_DMAStop(&huart1);
HAL_UART_DeInit(&huart1);
HAL_DeInit();