cancel
Showing results for 
Search instead for 
Did you mean: 

stm32_IAP

kaabiines
Associate II
Posted on March 28, 2013 at 11:12

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 plz
19 REPLIES 19
Posted on March 28, 2013 at 12:05

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
kaabiines
Associate II
Posted on March 28, 2013 at 12:30

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 executed

Posted on March 28, 2013 at 12:54

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;

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
kaabiines
Associate II
Posted on March 28, 2013 at 13:23

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);

}

kaabiines
Associate II
Posted on March 28, 2013 at 13:42

I DON'T KNOW IF pin (boot0, boot1) have rules to jump?? i try to change from system memroy (boot0 =1 boot1 = 0) to flash user (boot0) but i can't see any change :(

kaabiines
Associate II
Posted on March 28, 2013 at 13:57

note:

when i develop an application without interruption (flashing led) the jump is done correctly but with interruption the jump is not done

kaabiines
Associate II
Posted on March 28, 2013 at 15:50

so, no one can help me??!

Barbie
Associate II
Posted on March 28, 2013 at 16:21

Sorry for intervantion but I have a question about the sentence ''it's behaviour is also problematic if called twice (loader + app).''

I use the Boot APP start at address 0x08000000 and my APP I put at 0x0800C000. SO for every application I put the offset (0 and C000) in SystemInit() . If not I don't get correct interrupt location . SO you say it not allow? So where I should put the SystemInit()  and what offset to use (the Boot or the APP)?

Regards

Bar.

kaabiines
Associate II
Posted on March 28, 2013 at 16:32

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