But now i have to flash apllication written using just CMSIS and some st libraries (app2) and I have a problem. Application flashes fine but bootloader can't jump to the app2 correctly.
bootloader starts from 0x08000000 and app1 and app2 starts from 0x08008000. Microcontroller is stm32f407ig.
The app2 uses Keil compiler. To prepare the app2 to new address base I made following things:
1. set VECT_TAB_OFFSET to 0x8000 in system_stm32f4xx.c file
2. in linker options set new fash range: IROM1: 0x08008000, 0xF8000
3. in st-link options add new flash rule to 0x08008000-0x080FFFF range
I thing that app2 is linked and flashed well, because if I starts app2 form st-link command line:
Code: Select all
ST-LINK_CLI.exe -c SWD -Run 0x00008000
Everything starts fine, and application works (interesting that command ST-LINK_CLI.exe -c SWD -Run 0x08008000 doesn't work).
I thing that problem is connected with vector table: If application is rather simple and doesn't use any interrupts:
Code: Select all
int main( void ) {
pin p = {GPIOH, 3};
gpio_init ( p, GPIO_MODE_OUTPUT, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, GPIO_PUPD_FLOAT );
while(1) {
u32 i = 0xFFFFFF;
gpio_up(p);
while(i--);
i = 0xFFFFFF;
gpio_down(p);
while(i--);
}
}
after jumping from bootloader it works fine, len on the PH3 is blinking.
I'm jumping using the following function:
Code: Select all
void flashJumpApplication(uint32_t address) {
boardStop();
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
volatile u32* JumpAddress;
const volatile u32* ApplicationAddress = (volatile u32*) address;
JumpAddress = (volatile u32*) ApplicationAddress[1];
Jump_To_Application = (pFunction) JumpAddress;
chSysDisable();
SCB->ICSR &= ~SCB_ICSR_PENDSVSET_Msk;
int i;
for(i=0; i<8; i++)
NVIC->ICER[i] = NVIC->IABR[i];
__set_MSP((u32) (ApplicationAddress[0]));
Jump_To_Application();
}
found on some bootloader code based on chibios. I just add here boardStop() to stop any peripherals.
Does anybody have any idea, where is my mistake?