AnsweredAssumed Answered

Relocate app in STM32F105

Question asked by Caleg on Dec 1, 2014
Latest reply on Dec 10, 2014 by Caleg

On a board with a STM32F105 uC I am implementing a uSD bootloader. First of all I wanted to relocate the application to a different address in flash, but I'm getting a stack pointer error.
Here the 2 changes:

Linker file:  
FLASH (rx)      : ORIGIN = 0x0800C000, LENGTH = 128K - 0xC000

File system_stm32f10x.c:
#define VECT_TAB_OFFSET  0xC000

Right after start (even before getting to the main() function) the application crashes due to a stack pointer problem, in fact the sp register points to 0xFFFFFFFF instead of 0x20010000.

However, the .map seems correct... 
                0x20010000                __stack = (ORIGIN (RAM) + 0x10000)
                0x20010000                _estack = __stack
                0x00000400                __Main_Stack_Size = 0x400
.isr_vector     0x0800c000      0x1e4
                0x0800c000                . = ALIGN (0x4)

If I change the sp register manually (debug) at the beginning, the application starts correctly.

Does anyone have an idea why I'm getting this error?

Many thanks for your help!