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
kaabiines
Associate II
Posted on March 28, 2013 at 16:35

for me

even if

I relocate vector table in system_init the jump doesnt work !!

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

for me

even if

I relocate vector table in system_init the jump doesnt work well (bootloader jump but dont execute code on the TIM1_UP_IRQHandler(void) (interruption dont work))!!

Posted on March 28, 2013 at 16:47

Calling SystemInit(), as usually constructed, twice is a problem because the code in it assumes reset conditions with respect to HSI, CPU clock source etc. For example it would need to switch the processor to a different running/functional clock if it wanted to reprogram the PLL?

If the app doesn't work properly, you need to ponder what the boot loader is doing to the system, and how that deviates from what the application code, yours and the library, expects in terms of the initial condition.

When the TIM1 interrupt fires it goes some where.

If you want to isolate the bootloader activities for the purpose of debugging and identifying a cause, I would suggest jumpping to your application immediate at the ResetHandler code in startup_stm32f1xx_xx.s

BOOT0=0 should be your setting to boot the device from FLASH, it is only relevant a reset, and doesn't impact where you jump or what you do later.

so, no one can help me??!

No it's a forum, no one here works for you, and some of us have other things to do.

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 17:02

ooo sorry i dont mean any think when i say any one help me just i'am pressed with the time sorry

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

I call system_init function only in bootloader code :

Reset_handle for bootloader is

void Reset_Handler(void)

{

/* FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is

  required, then adjust the Register Addresses */

 // SystemInit_ExtMemCtl();

    SystemInit ();

  /* restore original stack pointer */

  asm('' LDR r0, =_estack'');

  asm('' MSR msp, r0'');

 

  /* Initialize data and bss */

   __Init_Data();

   NVIC_SetVectorTable(0x08000000, 0x0);

  /* Call the application's entry point.*/

  main();

}

for appli is

void Reset_Handler(void)

{

/* FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is

  required, then adjust the Register Addresses */

  //SystemInit_ExtMemCtl();

 // SystemInit ();

  /* restore original stack pointer */

//  asm('' LDR r0, =_estack'');

//  asm('' MSR msp, r0'');

 

  /* Initialize data and bss */

  // __Init_Data();

   NVIC_SetVectorTable(0x08000000, 0x1000);

  /* Call the application's entry point.*/

  main();

}

when i execute only the application it run correcttly (flashing led)

when i execute bootloader with application without interruption (flashing led) work correctly

but when i execute bootloader with application that use timer interruption don't work

it is clear my problem?

thanks

Posted on March 28, 2013 at 17:43

I'm not a big fan of using C for the start up code

Something like this for the boot loader would be illustrative if the problem lies in the App or not.

Reset_Handler

                LDR        R0, =0x08001000

                LDR        SP,[R0, #0]

                LDR        R0,[R0, #4]

                BX        R0

You should probably also review the .MAP and .HEX files and confirm the Application is built and situated correctly. If not you'll need to review the linker script.

Failing that you're going to have to use the debugger and walk through the code, and review the vector table content, and compare and contrast the peripheral/register settings in your working, vs non-working situation.
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 17:52

the Application is built and situated correctly.

i reveiw .map file

for appli:

/* Entry Point */

ENTRY(Reset_Handler)

/* Highest address of the user mode stack */

_estack = 0x20005000;    /* end of 20K RAM */

/* Generate a link error if heap and stack don't fit into RAM */

_Min_Heap_Size = 0;      /* required amount of heap  */

_Min_Stack_Size = 0x800; /* required amount of stack */

/* Specify the memory areas */

MEMORY

{

  FLASH (rx)      : ORIGIN = 0x08001000, LENGTH = 0x4000

  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 20K

  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K

}

/* Define output sections */

SECTIONS

{

  /* The startup code goes first into FLASH */

  .isr_vector :

  {

    . = ALIGN(4);

    KEEP(*(.isr_vector)) /* Startup code */

    . = ALIGN(4);

  } >FLASH

   /* The program code and other data goes into FLASH */

   .text :

  {

    . = ALIGN(4);

    *(.text)           /* .text sections (code) */

    *(.text*)          /* .text* sections (code) */

    *(.rodata)         /* .rodata sections (constants, strings, etc.) */

    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */

    *(.glue_7)         /* glue arm to thumb code */

    *(.glue_7t)        /* glue thumb to arm code */

    KEEP (*(.init))

    KEEP (*(.fini))

    . = ALIGN(4);

    _etext = .;        /* define a global symbols at end of code */

  } >FLASH

...

for bootloader:

/* Entry Point */

ENTRY(Reset_Handler)

/* Highest address of the user mode stack */

_estack = 0x20005000;    /* end of 20K RAM */

/* Generate a link error if heap and stack don't fit into RAM */

_Min_Heap_Size = 0;      /* required amount of heap  */

_Min_Stack_Size = 0x800; /* required amount of stack */

/* Specify the memory areas */

MEMORY

{

  FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 0x1000

  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 20K

  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K

}

/* Define output sections */

SECTIONS

{

  /* The startup code goes first into FLASH */

  .isr_vector :

  {

    . = ALIGN(4);

    KEEP(*(.isr_vector)) /* Startup code */

    . = ALIGN(4);

  } >FLASH

.map for bootloader:

Memory Configuration

Name             Origin             Length             Attributes

FLASH            0x08000000         0x00001000         xr

RAM              0x20000000         0x00005000         xrw

MEMORY_B1        0x60000000         0x00000000         xr

*default*        0x00000000         0xffffffff

..

.isr_vector     0x08000000      0x1e4

                0x08000000                . = ALIGN (0x4)

 *(.isr_vector)

 .isr_vector    0x08000000      0x1e4 ./libraries/cmsis/Core/CM3/startup/gcc/startup_stm32f10x_hd.o

                0x08000000                g_pfnVectors

                0x080001e4                . = ALIGN (0x4)

..

and .map for appli:

.isr_vector     0x08001000      0x1e4

                0x08001000                . = ALIGN (0x4)

 *(.isr_vector)

 .isr_vector    0x08001000      0x1e4 ./libraries/cmsis/Core/CM3/startup/gcc/startup_stm32f10x_hd.o

                0x08001000                g_pfnVectors

                0x080011e4                . = ALIGN (0x4)

I thought that i need configuration to re use interruption vector

thank you for spending your time to reply me

Posted on March 28, 2013 at 18:16

I thought that i need configuration to re use interruption vector

 

In the normal course of events the code in SystemInit() would be setting that up.

Personally, I use a construct like this to ensure it sets it up as linked.

extern void * __Vectors;

NVIC_SetVectorTable((u32)(&__Vectors), 0x0);

You're at a point where you need to go through the code the compiler/linker have given you and try and figure out why they are giving you such a bad day. With other tool chains this really isn't something that is hard to accomplish.

Use the debugger, add some break points to the interrupt handler and hard fault handler, examine the TIM1 registers, make sure the clocks are running, and the timer is ticking. ie stop poking with the code you have, and see what the processor is doing with the code you've got. Once you've got a proper handle on what's going wrong, rather than the symptoms, you'll be in a better place to fix the problem.

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 29, 2013 at 08:59

Hi,

i debug only the application (flushing), i make breakpoint it run ok. now when i go to the bootloader i debug it too. buuuuuut when it will jump how can i do the debug??? In fact, in my case i use the two spi (SPI1 and SPI2) one is used as master and the second is used as slave. the application (flashing led using timer interruption) after it is compeled i take the .hex and i write it into SPI_buffer SPI1 will send this buffer SPI2 will receive this buffer using DMA then write it in the specific @(0x08001000) all this is ok I look to the flash (using stlink utility) I compare binary between application and bootloader starting from the @0x080010000 they are equal so the write is ok but we will do the next step which is jumping to the @ of application only one flash of the led is done and nothing is done (you understand sorry for the bad english)

---> only one flash of the led is done = we can't jump to the TIM1_UP_IRQHandler(void) (function of the application not of the bootloader)

kaabiines
Associate II
Posted on March 29, 2013 at 10:21

ok it work now. In fact, the problem is that i have to do a reset before juming i create a test of one button if it is pressed i go to bootloader else i have to reset the board and execute the application