RAM usage not affected by heap/stack size

Hi,

working with nRF52840 with S140 v7.2.0, not sure about SDK version. VS Code + ARM GCC + LD Gold linker.

I changed stack and heap sizes via __HEAP_SIZE and __STACK_SIZE defines. Change is confirmed by .map file, but RAM usage(reported by linker flag --print-memory-usage) is not affected.

No matter what size I set to defines, RAM usage reported by linker stays the same.

How to fix this?

Parents
  • I think by default head and stack are defined as COPY sections and not the NOLOAD (modules/nrfx/mdk/nrf_common.ld: line 137) , COPY sections are not included in the print mem usage option.

    if you want --print-memory-usage to include heap and stack aswell then you need to change the linker script to NOLOAD , prestine build and check if that works.

  • Does not help. Even if I remove (NOLOAD) / (COPY), RAM usage does not change. 

  • If you have changed from COPY->NOLOAD, that should have worked.

    can you show me your arm-none-eabi-ld --version?

    Are you using bfd or gold version of the linker. if you were using bfd, then my suggestion should have helped.

  • arm-none-eabi-gcc --version
    arm-none-eabi-gcc (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 14.2.1 20241119
    Copyright (C) 2024 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    GNU ld (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 2.43.1.20241119
    Copyright (C) 2024 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) a later version.
    This program has absolutely no warranty.

    I'm using gold. Tried with BFD, same result. 
    Linker command is

    $(DIR_BUILD)/$(BUILD_NAME).elf: $(OBJECTS) $(MAKEFILE)
        $(TC_CC) $(OBJECTS) $(LINKER_FLAGS) -o $@

    Linked with gcc, not ld.
  • hmm, then nrf_common.ld does not seem to be built to count the heap and stack usage using --print-memory-usage. 

    Else change     .heap (COPY) : -> .heap (NOLOAD) :

    and add       . = MAX(., __HeapBase + __HEAP_SIZE); in the heap definition for heap to actually take space somethign like below

    .heap (NOLOAD):
    {
        __HeapBase = .;
        __end__ = .;
        PROVIDE(end = .);
        KEEP(*(.heap*))
        . = MAX(., __HeapBase + __HEAP_SIZE);  ///// add this
        __HeapLimit = .;
    } > RAM

Reply
  • hmm, then nrf_common.ld does not seem to be built to count the heap and stack usage using --print-memory-usage. 

    Else change     .heap (COPY) : -> .heap (NOLOAD) :

    and add       . = MAX(., __HeapBase + __HEAP_SIZE); in the heap definition for heap to actually take space somethign like below

    .heap (NOLOAD):
    {
        __HeapBase = .;
        __end__ = .;
        PROVIDE(end = .);
        KEEP(*(.heap*))
        . = MAX(., __HeapBase + __HEAP_SIZE);  ///// add this
        __HeapLimit = .;
    } > RAM

Children
Related