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

Heap size

Hi,

I'm using the latest everything for the nrf52840 with SES.

When I define a global variable that require substantial memory I get the linkage errors:

 .bss is too large to fit in RAM memory segment

   .heap is too large to fit in RAM memory segment

   section .heap overlaps absolute placed section .stack

   .bss is too large to fit in RAM memory segment

   .heap is too large to fit in RAM memory segment

   section .heap overlaps absolute placed section .stack

I don't use any malloc (all memory is preallocated or on the stack).

My questions:

1. How can I determine the various RAM memory allocation segments?

2. Same as (1) but for the Flash.

3. Does Softdevice use heap memory?

Thanks,

Daniel

Parents
  • I haven't used the latest SDK, but I think you should look at your linker script (.ld) file. At the beginning it should define the RAM and FLASH memory regions which determine the amount of memory available to the applications (they are offset from the flash/RAM start addresses to leave room for the SoftDevice). It should also have the line '#include "nrf_common.ld"' which refers to <sdk dir>/modules/nrfx/mdk/nrf_common.ld. That file determines how sections like .bss and .data are allocated, and may clear things up if you know or can learn how to read linker scripts.

    3. Does Softdevice use heap memory?

    Nope (at least not the same heap that your application uses, although I nevertheless don't expect that it uses a heap), if you are not using malloc then you should be able to safely eliminate the heap by adding -D__HEAP_SIZE=0 to your compiler flags (I've done that without any trouble, albeit using SDK v12.3.0). This old question talks a bit about that.

    Removing the heap won't solve your problem if .bss alone is too large, though. It seems like the variable you're defining really is too large to fit in memory (you're not defining global variables in header files, are you?).

  • Tlongeri,

    I'm using global variables (of course not in header files) in order to have full control of memory, and I would like to use the full capacity of the RAM and Flash (which I cannot do if using the out of the box definitions). It is vital to my application and I would hate adding external memory where there is sufficient memory in the soc.

    It seems SES is utilizing "thumb_ct0.s" rather than the ld files. I would like avoiding messing assembly files and there must be a clean way to do so. 

    Would you kindly check how to do so using SES and double check the dynamic memory usage of the Softdevice? Please also refer to the Flash side.

    Thanks,

    Daniel

  • This is SDK 15.3?

    How does your section placement macros look like ?

    Something like this ?
     

    Would you kindly check how to do so using SES and double check the dynamic memory usage of the Softdevice?

    The RAM usage of the SD is printed in nrf_sdh_ble_enable(), but you should be able to compile your project even if this is not correctly configured.

    How does the Memoery Usage display in SES looke like?

    If configured correctly, it should looke something like this;

  • Sigurd,

    Can you kindly share the configuration that created the example you showed (or a similar example)? I don't understand which keys to use.

    Thanks,

    Daniel

  • For the project options, right click on "Project '<example you are using>", and click Options..:

    For Memory Usage: View -> Memory Usage, or CTRL+ALT+Z

    What example in the SDK are you using ?

  • I understand how to get to the right place in the IDE (I'm using my own code). When I get there the info provided is:

    Section Placement Macros

    Macro values to substitue in section placement nodes - MACRO1=value1;MACRO2=value2.

    Inherits

    "FLASH_PH_START=0x0;FLASH_PH_SIZE=0x100000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x40000;FLASH_START=0x26000;FLASH_SIZE=0xda000;RAM_START=0x200022e0;RAM_SIZE=0x3dd20" from project in Common configuration
    "FLASH_START=0x26000;FLASH_SIZE=0x5a000;SRAM_START=0x20002a98;SRAM_SIZE=0xd568" from solution in Debug configuration

    The issues I don't understand:

    1. How to define the ".data", ".bss" etc. sections?

    2. Which section is related to static variables? (I guess it is the ".bss". right?)

    3. Which sections correspond to static variables on the flash.

    Are my questions clear?

    Thanks,

    Daniel

Reply
  • I understand how to get to the right place in the IDE (I'm using my own code). When I get there the info provided is:

    Section Placement Macros

    Macro values to substitue in section placement nodes - MACRO1=value1;MACRO2=value2.

    Inherits

    "FLASH_PH_START=0x0;FLASH_PH_SIZE=0x100000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x40000;FLASH_START=0x26000;FLASH_SIZE=0xda000;RAM_START=0x200022e0;RAM_SIZE=0x3dd20" from project in Common configuration
    "FLASH_START=0x26000;FLASH_SIZE=0x5a000;SRAM_START=0x20002a98;SRAM_SIZE=0xd568" from solution in Debug configuration

    The issues I don't understand:

    1. How to define the ".data", ".bss" etc. sections?

    2. Which section is related to static variables? (I guess it is the ".bss". right?)

    3. Which sections correspond to static variables on the flash.

    Are my questions clear?

    Thanks,

    Daniel

Children
No Data
Related