Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Import Macro Repair
Panel
bgColor#ffffff
titleQ

How can I change the size of Stack and Heap?

Panel
bgColor#ffffff
titleQ

What does the following error mean?

ld.exe: region RAM overflowed with stack

Panel
bgColor#ffffff
titleA

The sections .stack and .heap are user defined. In the startup, build and linker scripts provided, together with our newlibc example implementation, we provide you with an examplaratory explanatory implementation of those.

Within the wscpt wscript in the Targets directory you are able to define the stack and heap size for each target individually.

Code Block
languagepy
firstline85
titleTargets > NXHX > wscript
linenumberstrue
    bld.sdkcomponent(
        name            = "cmsis_configuration_sdk",
        export_defines  = [
                           "__STACK_SIZE = 0x00002000",
                           "__HEAP_SIZE =  0x00008000",
                           ],
        )

The heap itself is used in the newlibc implementation within the sbrk funktionfunction. However, the heap area has to be initialized upfront. If you are using an Operating operating system, you need to take care on how the stacks and heaps are used.

If you now receive the message: "ld.exe: region RAM overflowed with stack" it is , because the defined size of stack and heap cannot be linked correctly.

In our examples, the heap is positioned after the sections containing .text, .rodata, .data, .bss and others containing compile time known data. The stack is always placed at the end of the selected memory. While the heap grows to the end of the memory, the stack grows from the end of it backwards in the direction of the heap.

Our example does not check the consistency of heap and stack during runtime, and it is possible, that stack and heap might overwrite each other.

Panel
bgColor#ffffff
titleSee also...

Filter by label (Content by label)
showLabelsfalse
spaces@self
showSpacefalse
cqllabel = "faq" and space = currentSpace ( )
labelsfaq