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

Suitable values for __STACK_SIZE and __HEAP_SIZE when developing with FreeRTOS and SoftDevice

Hello!

I am developing a FreeRTOS application for nrf52832 with S132 Soft device

Recently I  ran out of ram and checked the map-file for clues. The large posts in the mapfile were
28k uCheap (heap_1.c)  (determined by configTOTAL_HEAP_SIZE in FreeRTOSConfig.h)
8k  __HEAP_SIZE
8k  __STACK_SIZE
11k Soft device 
9k  Other
Total: 64k

So I stated wondering about why there was 16k to heap and stack when FreeRTOS uses its own uCheap (28k in my case) as heap and for thread-stacks (trough its own pvPortMalloc()) 
__HEAP_SIZE can be set to 0 according to this link

__STACK_SIZE is (according to this link) used as
   * stack for main() before the scheduler is started
   * reused for ISR stack after the scheduler is started

So my questions are

1) Can the __HEAP_SIZE be reduced to 0 safely in my setup (or is there any low-level stuff relying on regular malloc (not freertos malloc))?

2) What is the lowest safe recommended __STACK_SIZE?
I don't use interrupts in my own code but I assume FreeRTOS uses atleast RTC IRQ and maybe the NRF SDK also uses ISR and requires some stack?

3) Are these topics discussed in some documenation that I have missed?

Thanks in advance, 
Axel

Related