cancel
Showing results for 
Search instead for 
Did you mean: 

STM32, Stack-Utilization

Hello,

for determining the Stack-Utilization I fill it with 0xDADBEEF. If you have recommendations and other ideas, I’d like to know and looking forward to learn from others, how they approach the issues “Stacksize” and “Stackutilization”.

Code for the Startup-File:

 

Reset_Handler:
/* BEGIN : Seppels StackInit*/
 ldr     r0, = _End_Min_Stack_Size
 ldr     r1, = _estack
 ldr     r2, =0xDEADBEEF
Fill:
 str     r2, [R0], #4
 cmp     r0, r1
 bne     Fill
/* END : Seppels Stack Init */

 

Modification of the Linker-Script:

 

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */

_Min_Heap_Size = 0x2000 ; /* required amount of heap */
_Min_Stack_Size = 0x2000 ; /* required amount of stack */
_End_Min_Stack_Size = _estack - _Min_Stack_Size ; /* Calculate the lower Address for init with the famoes "EB" */

 

Top of the Stack:

STM32CubeIDE_Deadbeef_Stack.png

Thanks a lot.

Best Regards, Seppeltronics

1 ACCEPTED SOLUTION

Accepted Solutions
gbm
Lead II

Maybe you should simply have a look at static stack usage analysis tab in the bottom-right pane after compilation?

View solution in original post

2 REPLIES 2
gbm
Lead II

Maybe you should simply have a look at static stack usage analysis tab in the bottom-right pane after compilation?

Hello,

sure, I did look at the statically calculated Stacksize as well, but I found it useful as well to fill the stack with a pattern. Actually I found code in a forum that did not work, so I took the chance to publish something working.

Best Regards,

Seppel