cancel
Showing results for 
Search instead for 
Did you mean: 

osSemaphoreRelease() stopped working when heap was placed in CCMRAM instead of SRAM

dimmykar
Associate II

Hello everybody! I am using STM32F405RG with FreeRTOS in my project. In the course of development, I encountered the problem of lack of SRAM. The solution to the problem I thought would be placing 64 KB of the FreeRTOS heap in CCMRAM and its 16 KB in SRAM after .bss, using heap_5.c. The heap was allocated correctly, and freertos objects are created correctly in the heap. But after such a heap allocation in two different segments, all osSemaphoreRelease() from the ISR no longer work. Semaphores are allocated in the CCMRAM heap. Has anyone faced a similar problem?

4 REPLIES 4
dimmykar
Associate II

How I allocated the heap:

static void InitRTOSHeap(void)
 
{
 
 static u8 ccmram_rtos_heap[CCMRAM_RTOS_HEAP_SIZE] __attribute__((section(".ccmram")));
 
 static u8 sram_rtos_heap[SRAM_RTOS_HEAP_SIZE] __attribute__((section(".rtos_heap")));
 
 
 
 HeapRegion_t xHeapRegions[] =
 
 {
 
  { (u8 *)&ccmram_rtos_heap[0], sizeof(ccmram_rtos_heap) },
 
  { (u8 *)&sram_rtos_heap[0], sizeof(sram_rtos_heap) },
 
  { NULL, 0 } /* Marks the end of the array. */
 
 };
 
 
 
 vPortDefineHeapRegions(xHeapRegions);
 
}
 
int main(void)
{
  InitRTOSHeap();
 
...
}

Everything works correctly except for the semaphores from the ISR. Semaphores from different threads are working fine

Is bit-banding used in the implementation?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

No, I have not used bit-banding anywhere, neither before using heap_5.c nor after

dimmykar
Associate II

I discovered such a thing:

If swap the parts of the heaps

HeapRegion_t xHeapRegions[] =

{

{ (u8 *)&sram_rtos_heap[0], sizeof(sram_rtos_heap) },

{ (u8 *)&ccmram_rtos_heap[0], sizeof(ccmram_rtos_heap) }, 

{ NULL, 0 } /* Marks the end of the array. */

};

then I cannot allocate the heap after calling vPortDefineHeapRegions (xHeapRegions);

In this case, I hang on checking

/* Check blocks are passed in with increasing start addresses. */

configASSERT( xAddress > ( size_t ) pxEnd );

in vPortDefineHeapRegions (xHeapRegions) definition in heap_5.c

If CCMRAM is placed first, then the heap is allocated, but osSemaphoreRelease() from the ISR does not work

I attach a startup and a linker file for analysis, maybe I made a mistake in them