Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GaryLim
Employee
Employee
10 questions asked First like received 10 replies posted

Hello

I am using PSoC63 with Modustoolbox development.

When running my application, is there any method on MTB to determine or estimate the max stack and heap size that will be used by my application? Thanks.

 

Thnaks.

5 Replies
MuhammadNanda_K
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 50 likes received

Hello @GaryLim,

Basically setting stack size is in the linker.ld under bsps\TARGET_<bsp>\COMPONENT_<core>\TOOLCHAIN_GCC_ARM\

If you still have any doubts, please kindly address. 🙂 

Thank you and regards,
Muhammad Nanda

0 Likes
GaryLim
Employee
Employee
10 questions asked First like received 10 replies posted

Hello Nanda,

Thanks for directing me to the linker file.

The default stack size value for my platform is set to 0x1000. I find that I cannot make this number smaller. Any modification (reduce by 1 byte) will  cause an assertion "region RAM overflowed with stack".

Since I am just making the stack size smaller, it should not cause serious overflow issue. For my test, I disabled the following ASSERT:
/*ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")*/

Then I can managed to compile my application without the assert error. Thereafter, I tried to scale down the stack size to the point of Stack size is Zero and the application is still working. 

Is the STACK_SIZE variable a true reflection of the platform stack usage? 

Thanks,

Gary

0 Likes
MuhammadNanda_K
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 50 likes received

Hello Gary,

May you kindly inform which sample code do you use ?
(Or custom code ?)

Or can you share your build result .elf (and .map if able) ?

Thank you and regards,
Muhammad Nanda

0 Likes

The linker behavior can be seen using the HelloWorld example. I have modified the linker to allocate 0  byte stack and commented away the ASSERT such that there is no blocking of the script. The code will still allocate without stack. 

0 Likes
MuhammadNanda_K
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 50 likes received

Hello Mr. Gary,

I have observed the same behavior after some experiments.
After zeroing values in .S and .ld, the customize program is also still running.

This is still become ongoing internal discussion.

Thank you and regards,
Muhammad Nanda

0 Likes