I'm developing an application on an ARM Cortex-M microcontroller which has two RAM banks à 64kB. The first bank is directly followed by the second bank in the memory map.
The memory banks are currently split into two regions in my linker script. The first region contains the sections
For example you have 2 banks at
0x20010000. You wants use Bank2 for heap and (main) stack. I assume that you have large
.bss because of
configTOTAL_HEAP_SIZE in FreeRTOSConfig.h. Now see heap sources in FreeRTOS/Source/portable/MemMang/. There are 5 implementations of
pvPortMalloc() that do memory allocation.
Looks at lines in heap_X.c that you use
/* Allocate the memory for the heap. */ #if( configAPPLICATION_ALLOCATED_HEAP == 1 ) /* The application writer has already defined the array used for the RTOS heap - probably so it can be placed in a special segment or address. */ extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; #else static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; #endif /* configAPPLICATION_ALLOCATED_HEAP */
So you can set
configAPPLICATION_ALLOCATED_HEAP at 1 and say to you linker to place
Another way is writing headers for each device that includes addresses of heap and stack and edit sources. For heap_1.c we can do next changes:
// somewhere in devconfig.h #define HEAP_ADDR 0x20010000 // in heap_1.c // remove code related ucHeap // // remove static uint8_t *pucAlignedHeap = NULL; // and paste: static uint8_t *pucAlignedHeap = (uint8_t *)HEAP_ADDR;
For heap_2.c and heap_4.c edit function
prvHeapInit() as well.
Pay attention to heap_5.c that includes
pvPortMalloc() will returns pointers to memory in Bank2.
pvPortMalloc() used for allocations stacks of tasks, TCB and user varables. Read sources. Location of main stack depends of your device/architecture. For stm32 (ARM) see vector table or how to change MSP register.