This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Top of stack placement logic in uvison

Hi all, 

TL;DR: why does not uvision sets the initial stack pointer to the top of the sram?

Verbose:

I'd like to understand how uVsion sets the top of the stack for STM cortex m0+ devices for a project that I have to inspect and debug (bare metal, no rtos in place). 

Also pelase notice that I am familiar with ARMv6m and ARMv7m architecture and startup process.

The configuration I got for the project is the following

I'd expect to see the initial stack pointer in the hex file set to 0x20002000. BUT in the hex file the top of the stack is set to 0x20001918.

This is confirmed by also by inspecting the core registers before startup is called: 

If I uncheck the "Use Micro LIB" checkbox in the "Target" tab, I see that the initial stack pointer address changes, so I presume that (at least some of) microlib stuff is allocated in the range [0x2000192A: 0x20002000].

Is this correct?

I also imagine that this is to prevent stack overflow corrupting the library sram before or something similar. 

I wasn't able to find documentation on this specific topic (stack and NO RTOS) so any link would also be gladly appreciated.

K.R.

Luca. 

Parents
  • Hi Luca,

    you should inspect .map file which will tell you more on where variables, heap, stack and code were placed by the linker.

    Also, stack is by default not allocated at the end of RAM, but after the variables and heap used in your project.

    You could have a better control by using your own linker script, that way you can control all placements yourself.

    Best regards, Milorad

Reply
  • Hi Luca,

    you should inspect .map file which will tell you more on where variables, heap, stack and code were placed by the linker.

    Also, stack is by default not allocated at the end of RAM, but after the variables and heap used in your project.

    You could have a better control by using your own linker script, that way you can control all placements yourself.

    Best regards, Milorad

Children
No data