cancel
Showing results for 
Search instead for 
Did you mean: 

question about startup vector

aalmax
Associate II
Posted on January 25, 2012 at 14:44

I am learning how STM32 works. I looked at startup file and starup vector using simulator and example project.

And I have question (STM32F105):

1.

First dword location of vector is stack pointer and it is initialized to 0x10000 (stack is growing to lower addresess). It is ok, procesor RAM size os 0x10000. 

Second dword location is reset vector and it is 0x8001077D.

But I can see at simulator that program starts at address 0x8001077C. Why is it the difference ?

2.

Startup file is written in assembly. How can i change the location of startup file ? I know how to do it with C functions using sections) but how do it with .s files ?

thanks in advance

Peteros

2 REPLIES 2
hpipon957
Associate III
Posted on January 25, 2012 at 15:07

Hi

1) The Cortex M3/M4 devices operate in Thumb-2 mode. This means that it has function calls to odd addresses which effectively sets the processors' operating mode to Thumb (2) mode when the routine is called (the actual routine is positioned on an even address).

2) The assembler code will not set the start address as a fixed value in code but will instead use a reference pointer (like _start_up) which will be filled out by the linker at link time.

Regards

Mark

http://www.uTasker.com

Posted on January 25, 2012 at 16:07

Using what toolchain? The vector location is pretty much defined by the scatter file or linker script, some tools present this in the GUI as IROM. While you can use a 0x00000000 origin, I'd probably be using the 0x08000000.

Your stack also needs to be in the SRAM zone at 0x20000000, dropping from 0x20010000 would be appropriate for a 64KB part.

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