2013-03-28 03:12 AM
Hi,
My application requires a bootloader that loads an application into a FLASH device. I have created two different applications: bootloader. start 0x08000000 A FLASH application. start 0x08001000 if i creat an application without interruption (flash led) the jump from bootloader to appli work but when i creat an application that use timer interrupt to flash the led the jump don't work the code of jump is: NVIC_DeInit(); NVIC_DISABLE(); NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x1000); SCB->VTOR = 0x08001000; /* Jump to user application */ JumpAddress = *(__IO uint32_t*) ((uint32_t)0x08001000 + 4); Jump_To_Application = (pFunction) JumpAddress; __disable_irq(); /* Initialize user application's Stack Pointer */ __set_MSP(* ( __IO uint32_t* ) 0x08001000); //__enable_irq(); Jump_To_Application(); can anyone help me plz2013-03-28 04:05 AM
Tried using a debugger to determine what actually happens? Do you get a Hard Fault? Which interrupt are you using, and do you disable it at the source? ie not NVIC
2013-03-28 04:30 AM
no i 'dont get hard fault
in fact, the bootloader consist of programming the flash from the @0x08001000 when the writting complete, we have to jump to 0x08001000 which is the binary of the application (flash a led using timer interruption this is the code of application main() { uint16_t index_compt = 0; //NVIC_SystemReset(); RCC_DeInit(); TIM_DeInit(TIM1); /* Enable GPIOF clocks */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOF , ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); /* Interrupt Configuration */ NVIC_Config(); GPIO_Configuration(); TIM_Cmd(TIM1, DISABLE); TIM_Cmd(TIM1, ENABLE); //TIM_ARRPreloadConfig(TIM1, ENABLE); //TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); if(GPIO_ReadOutputDataBit(GPIOF,GPIO_Pin_6) == RESET) { GPIO_WriteBit(GPIOF,GPIO_Pin_6,SET); } else { GPIO_WriteBit(GPIOF,GPIO_Pin_6,RESET); } TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); while (1) { if(index_compt == 0xFFFE) { if(GPIO_ReadOutputDataBit(GPIOF,GPIO_Pin_7) == RESET) { GPIO_WriteBit(GPIOF,GPIO_Pin_7,SET); } else { GPIO_WriteBit(GPIOF,GPIO_Pin_7,RESET); } index_compt = 0; } index_compt++; } } void TIM1_UP_IRQHandler(void) { if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { //TIM_ITConfig(TIM1, TIM_IT_Update, DISABLE); TIM_ClearITPendingBit(TIM1, TIM_IT_Update); if(GPIO_ReadOutputDataBit(GPIOF,GPIO_Pin_6) == RESET) { GPIO_WriteBit(GPIOF,GPIO_Pin_6,SET); } else { GPIO_WriteBit(GPIOF,GPIO_Pin_6,RESET); } } } ) when the bootloader call the jump,only the first allumation of the led is done so the interruption is not executed2013-03-28 04:54 AM
I'm familiar with how boot loaders work.
I'm asking if you've used a debugger and single stepped into the code across the transition point. What's the part number the the STM32 you're using? Have you fixed the vector relocation code in SystemInit() in system_stm32fxx.c of the application? In the CMSIS model this routine is called prior to main(), it's behaviour is also problematic if called twice (loader + app). These two lines do the same thing, one or both are unnecessary if it's fixed up properly in SystemInit() NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x1000); SCB->VTOR = 0x08001000;2013-03-28 05:23 AM
yes i use a debugger (gdb in eclipse)
the board that i use: stm3210E-eval i use the relocation vector in the application not in system_init i call it in the main of the application int main(void) { uint16_t index_compt = 0; //NVIC_SystemReset(); RCC_DeInit(); TIM_DeInit(TIM1); /* Enable GPIOF clocks */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOF , ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); /* Interrupt Configuration */ NVIC_Config(); ... } void NVIC_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; /* Set the Vector Table base address at 0x08001000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x1000); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15;//0 NVIC_InitStructure.NVIC_IRQChannelSubPriority =0;//1 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); }2013-03-28 05:42 AM
2013-03-28 05:57 AM
2013-03-28 07:50 AM
2013-03-28 08:21 AM
2013-03-28 08:32 AM
he said ''Have you fixed the vector relocation code in SystemInit() in system_stm32fxx.c of the application? In the CMSIS model this routine is called prior to main(), it's behaviour is also problematic if called twice (loader + app).''
so he ask me if i fixed the vector relocation in systeminit() because it is necessary when we have two application