2022-04-19 01:12 AM
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:
and make section like this...:
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.
2022-04-19 01:37 AM
Forget creating a new section, just move the FLASH one so it has a different start address.
There are multiple references in the linker script to direct content and vectors there. Review .MAP file to see where everything is placed.
2022-04-19 03:31 AM
Hi, firstable thanks for your answer, so i have been reviewing the .MAP file and i have found the following part:
Is 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.
2022-04-19 03:48 AM
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
So it is right considering that i jump from the bootloader to that address...am i wrong?¿
2022-04-19 10:12 PM
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();