2021-09-01 08:11 AM
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?
2021-09-01 08:17 AM
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
2021-09-01 11:03 AM
Is bit-banding used in the implementation?
2021-09-01 01:33 PM
No, I have not used bit-banding anywhere, neither before using heap_5.c nor after
2021-09-02 01:58 AM
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