Skip to main content
Visitor II
September 1, 2021
Question

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

  • September 1, 2021
  • 3 replies
  • 1271 views

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?

    This topic has been closed for replies.

    3 replies

    dimmykarAuthor
    Visitor II
    September 1, 2021

    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

    Graduate II
    September 1, 2021

    Is bit-banding used in the implementation?

    dimmykarAuthor
    Visitor II
    September 1, 2021

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

    dimmykarAuthor
    Visitor II
    September 2, 2021

    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