This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GNU Toolchain: region RAM overflowed with stack

I've a query regarding the assert message that I see in the application.map file, when I use GNU Toolchain for building the application firmware for NRF51 SOC.

Environment:

  • Target chip: NRF51822QFAA (16kB RAM)
  • Softdevice: S110
  • SDK: v6.1.0
  • Build tool: GNU ARM Toolchain.

size information:

$ ../../tools/gcc-arm-none-eabi-4_9-2015q2/bin/arm-none-eabi-size _build/application_s110_xxaa.out
text       data     bss     dec     hex filename
44448       220    3628   48296    bca8 _build/application_s110_xxaa.out

$ du -sh _build/application_s110_xxaa.bin
44K     _build/application_s110_xxaa.bin

snip from application.map

.heap                   0x20002f08        0x0
                        0x20002f08                __end__ = .
                        0x20002f08                end = __end__
*(.heap*)
.heap                   0x20002f08        0x0 _build/gcc_startup_nrf51.o
                        0x20002f08                __HeapLimit = . 

.stack_dummy            0x20002f08      0x800
*(.stack*)
.stack                  0x20002f08      0x800 _build/gcc_startup_nrf51.o
                        0x20004000                __StackTop = (ORIGIN (RAM) + 0x2000)
                        0x20003800                __StackLimit = (__StackTop - SIZEOF (.stack_dummy))
                        0x20004000                PROVIDE (__stack, __StackTop)
                        0x00000001                ASSERT ((__StackLimit >= __HeapLimit), region RAM overflowed with stack)
OUTPUT(_build/application_s110_xxaa.out elf32-littlearm)

snip from Makefile:

ASMFLAGS := -D__HEAP_SIZE=0 <-- Not using malloc and friends

The message

region RAM overflowed with stack

is coming from the linker script:

snip from ~/nrf51822/Source/templates/gcc/gcc_nrf51_common.ld

/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")

Finally, the application specific linker script:

snip from gcc_nrf51_s110_xxaa.ld:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
        FLASH (rx) : ORIGIN = 0x00016000, LENGTH = 0x2A000 
        RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x2000 
}

INCLUDE "gcc_nrf51_common.ld

My target SOC is NRF51822QFAA which has a total of 16kB of RAM region, out of which 8kB seem to be be occupied by Softdevice s110 (refer the Softdevice s110, specification section 11.2 or the attached image nrf51_s110.png). Therefore, the maximum value for RAM region that I can set is 0x2000 (8kB) and is already set in the application specific linker script above.

Despite the assert message above (I've very little knowledge of Linkers), the application binary gets built (application.bin) but I'd like to know if I can safely ignore the linker message about the assert in the application.map file.

Related