cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader STM32f103V8

meratterman
Associate II
Posted on July 26, 2011 at 18:15

Hi everyone,

I am new to the ARM Chips and am trying to implement a bootloader using the example code from AN2557.

I am using IAR workbench for ARM 6.2 and a segger Jlink educational JTAG.

In IAR I have 2 separate projects. One for the bootloader and another for the user application.

I have set the bootloader to be programmed at address 0x8000000 and the user app at 0x8003000

when I get to this part in the code:

if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x2000000)

    { 

      /* Jump to user application */

      JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);

      

      Jump_To_Application = (pFunction) JumpAddress;

      

      NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x3000);

      /* Initialize user application's Stack Pointer */

      __set_MSP(*(__IO uint32_t*) ApplicationAddress);

      

      

      Jump_To_Application();

    }

  }

it does not execute the If statement.  I dont know if I understand exactly whats going on.

Thank you for your help

#stm32-bootloader
5 REPLIES 5
Posted on July 26, 2011 at 18:21

if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x2000000)

It's confirming the stack is in RAM, and the comparative address should be 0x20000000 (Seven Zeros, Not Six)
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
meratterman
Associate II
Posted on July 26, 2011 at 19:01

Clive1,

Thank you for your reply.

I forgot to mention my application address in code is defined:

#define ApplicationAddress 0x08003000

shouldn't this work then?

Mike

Posted on July 26, 2011 at 19:47

shouldn't this work then?

It should work if your comparison used 0x20000000 (SEVEN TRAILING ZEROS) and not 0x02000000 (SIX TRAILING ZEROS)

And that you RAM address is correctly defined in your Linker Script, Scatter File, or GUI interface.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
atakancesim88
Associate II
Posted on January 26, 2016 at 10:01

I found following and did not understand why  __set_MSP(0x20002000) , why main stack pointer hold 0x20002000 ; why not 0x20000000 (sram start address) for stm32f429. 

 

 

When  I debug and look in 0x1FFF0000 , I saw 0x20002318?

 

Should I  use __set_MSP(0x20002318) ? 

 

 

void jump_to_BootLoader(void) {

 

    void (*SysMemBootJump)(void) = (void (*)(void)) (*((uint32_t *) 0x1FFF0004));

 

    __set_PRIMASK(1);

 

    RCC_DeInit();

 

    SysTick->CTRL = 0;

 

    SysTick->LOAD = 0;

 

    SysTick->VAL = 0;

 

    RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);

 

    __set_MSP(0x20002000);

 

    SysMemBootJump();

 

}
Posted on January 26, 2016 at 15:50

why not 0x20000000

Because the stack descends? And you want to mount it to the ceiling, not the floor.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..