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

How to configure RAM and stack and heap sizes?

Hi all,

I am working on a project with the nrf52832 and I am using softdevice S132 6.1.1. After creating my desired flash layout (with some help on this forum, thanks!) I am now running into RAM issues. I would like to set up my RAM correctly and would like to find good sizes for the stack and the heap.

If I understand correctly, the origin address for RAM should be set 0x20000000 + the amount of RAM required by the softdevice.
According to this post the minimum required start address for this softdevice is 0x20001628, I increased this to 0x20002710 to be sure. As 2710 is 10K in decimal,  that should leave me with (64KB- 10KB = ) 54KB of RAM am I right? 54K is D2F0 in hex so that results in the following entry in my LD file within the MEMORY section:

  RAM (rwx) :  ORIGIN = 0x20002710, LENGTH = 0xD2F0

Is this the correct way to calculate the RAM?

Besides that I am setting the stack and heap size in my makefile like so:

MyApp: CFLAGS += -D__HEAP_SIZE=4096
MyApp: CFLAGS += -D__STACK_SIZE=4096
MyApp: ASMFLAGS += -D__HEAP_SIZE=4096
MyApp: ASMFLAGS += -D__STACK_SIZE=4096

These values are copied from some example project and I can't seem to find how to calculate those.

Could someone point me in the right direction?

Thanks a lot!

Parents Reply Children
Related