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

nRF52832 store large size array in RAM

I'm looking to store a batch of data in a large array in RAM and send them all at once later. I start from ble_app_template in sdk examples and add an array. My memory setting is RAM (rwx) :  ORIGIN = 0x20002e70, LENGTH = 0xd190. In the code I'm only able to declare a float array with the size of around 8000. Higher than that there would be error of region RAM overflowed with stack when building the project.

Based on the memory setting, there should be about 53000 bytes available, but I could only use about 32000 bytes for the array. Do the other parts in ble_app_template main file use all the remaining 20000 bytes? Is there any way to squeeze more space to make the array larger?

Parents
  • Hi,

    Based on the memory setting, there should be about 53000 bytes available, but I could only use about 32000 bytes for the array. Do the other parts in ble_app_template main file use all the remaining 20000 bytes?

    Yes,your calculations are correct. Assuming you use SES, that reserves 8 kB for heap. Most probably you do not use any, so you can set that to 0, saving 8 kB. See screenshot:

    I suspect you allready did this though, or use another toolchain, as this takes RAM usage down to about 21 kB.

    To reduce it further you can disable things you do not need. For instance, if you do not need logging you can set NRF_LOG_ENABLED to 0 in sdk_config.h. to reduce it by a few kB. And you can continue to gain some memory hear an there by removing code and modules you do not need. 

  • Hi Einar,

    I'm using GCC in Eclipse. 

    Is the 8kB heap part of the 21kB usage or already excluded from the 21kB? Is 21kB the expected value for an application to run?

    The ble_app_template file does have some modules I don't use such as peer manager. Removing them means I should disable them in config file like the nrf_log module or remove all related codes from the main file?

    Thanks

Reply Children
  • xhr0428 said:

    I'm using GCC in Eclipse. 

    Is the 8kB heap part of the 21kB usage or already excluded from the 21kB? Is 21kB the expected value for an application to run?

    I see. I do not think so, the GCC projects generally do not have heap, and the SES project was about 29 kB when including the 8 kB heap.

    xhr0428 said:
    The ble_app_template file does have some modules I don't use such as peer manager. Removing them means I should disable them in config file like the nrf_log module or remove all related codes from the main file?

    Yes, you should remove the code and disable the modules in sdk_config.h.

    You could also try to optimize for size with -Os instead of -O3, and you can add link time optimization with -flto . I have not tested to check how much you will gain thoguh.

Related