SmokinGrunts 5 Posted April 10, 2016 Share Posted April 10, 2016 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. Quote Link to post Share on other sites
spirilis 1,265 Posted April 10, 2016 Share Posted April 10, 2016 IIRC it puts stack at top of SRAM so it grows down, while heap begins at start of SRAM and grows up. So I'm not sure they can be "adjusted" per se but it definitely doesn't do stack the default TI way (where stack is an array basically allocated inside the heap). energia 1 Quote Link to post Share on other sites
energia 485 Posted April 11, 2016 Share Posted April 11, 2016 @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. Quote Link to post Share on other sites
roadrunner84 466 Posted April 12, 2016 Share Posted April 12, 2016 @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. Quote Link to post Share on other sites
Rickta59 589 Posted April 12, 2016 Share Posted April 12, 2016 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' http://embeddedgurus.com/state-space/files/2014/02/fig3.jpg 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. -rick tripwire 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.