cancel
Showing results for 
Search instead for 
Did you mean: 

How can I determine the starting address of the stack in CubeIDE?

DK.7
Senior

In Keil, if you open a file with the extension .map, you can find information about starting address of stack and so on. See screen.

How can I determine the starting address of the stack in CubeIDE?Q.png

6 REPLIES 6
SofLit
ST Employee

Hello,

Go to STM32CubeIDE\Debug and open .map file. Try to find the line

_estack = (ORIGIN (RAM) + LENGTH (RAM))

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS: This is NOT an online support (https://ols.st.com) but a collaborative space. So please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

Thanks for the answer!

I found the desired line in .map file

 

_estack = (ORIGIN (RAM) + LENGTH (RAM))

 

and I don’t understand what to do with it. See screen.Q.png

SofLit
ST Employee

 

SofLit_1-1706284458542.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS: This is NOT an online support (https://ols.st.com) but a collaborative space. So please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

Thank you, but how to find out the end address of stack from this file?

SofLit
ST Employee

_estack defines the end of the Stack which is the Top of the stack.

So normally the stack starts at: _estack - _Min_Stack_Size

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS: This is NOT an online support (https://ols.st.com) but a collaborative space. So please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

It should really use the space allocated by the linker, in this case ST just lets it descend into the end of the heap

See _sbrk implementation in syscalls.c

ST sets in to the end of RAM, and it auto-decrements from there, basically the first 32-bit word gets stored at _estack-4

_bstack = (ORIGIN (RAM) + LENGTH (RAM) - _Min_Stack_Size)

_estack = (ORIGIN (RAM) + LENGTH (RAM))

 

In the Keil builds the initial stack is set to __initial_sp, and descends too Stack_Mem

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