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

  • 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

  • Right, sorry, I forget IDEs are different. I shouldn't have assumed you were using GCC.

    Sorry, but I've never used SES, so I can't help you with that.

    I think it would help if you gave more details about what you are trying to do. For instance, are you trying to allocate a huge array of something? If so, how big is your array exactly? (or are you trying to figure out how big you can make it?)

  • I would like to declare as large as possible variables. I have the following motivations: (1) Having an expected behaviour; (2) Using data management schemes such as fifo rather than heap; (3) Knowing in advance the expected storage available and using the maximal possible (since BLE connection may be intermittent); (4) Utilizing both RAM and flash.

    My problems:  I don't know (1) what are the various memory sections and if they are needed; (2) how to define those (SES is using GCC under the hood but in your examples it has different  assembly file and no makefile)

    Thanks,

    Daniel  

Reply
  • I would like to declare as large as possible variables. I have the following motivations: (1) Having an expected behaviour; (2) Using data management schemes such as fifo rather than heap; (3) Knowing in advance the expected storage available and using the maximal possible (since BLE connection may be intermittent); (4) Utilizing both RAM and flash.

    My problems:  I don't know (1) what are the various memory sections and if they are needed; (2) how to define those (SES is using GCC under the hood but in your examples it has different  assembly file and no makefile)

    Thanks,

    Daniel  

Children
Related