Jump to content

Recommended Posts

So I'm trying to wrap my head around how Energia sets up the Heap and Stack size, using GCC compiler. TI's linker script and startup_gcc.c are a bit different from the way Energia does it.


For TI, all that's required is a linker symbol to change sizes, is there something like this for GCC Energia?


Target board is TM4C1294 btw.

Link to post
Share on other sites

@spirilis is right. The heap starts at the end of allocated RAM and grows up. Stack is allocated at the end of RAM and grows down towards the heap. You would have to change the linker script and startup_gcc.c to allocate a static heap.

What would be the advantage of a static heap (ie: pre-allocated dynamic memory?)? If one would want to have statically allocated memory, wouldn't a static/global variable be preferable, since it would reside in the static allocation below the heap?

If you run into problems because of heap space (or stack space) then you're simply running too low on memory, no compiler script could change that, you'd have to change your program to simply use less memory.

Link to post
Share on other sites

What would be the advantage of a static heap ..

If you moved the stack so that it occupies the lower end of ram, and pushed up the .bss and .data sections you could allocate a fixed stack that could throw an exception if it exceeded its limits. See this article http://embeddedgurus.com/state-space/2014/02/are-we-shooting-ourselves-in-the-foot-with-stack-overflow/ and find the section called 'A Smarter Way'





This approach would be best used during development and not during production. You could easily have two ld scripts, one setup for development and one setup for release.



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...