rongard
rongard

Reputation: 99

In what memory region of the DDR is the FreeRTOS heap placed (Zynq 700 device)?

I'm struggling to understand the memory management concept in FreeRTOS and would appreciate if someone can confirm my understandings of things

I have a Zynq 7000 device where I have implemented some custom logic and AXI DMA controller in the FPGA side of the SoC. This logic essentially generates some data samples which then gets written into DDR memory. In the processor side I have FreeRTOS (v10) set up that has to take that data written into DDR and do some processing on this.

Now, using the AXI DMA means that I have to specify some memory region in DDR for the DMA controller where the samples can be written. In my baremetal application it was relatively easy as I could basically specify any region in DDR that was not reserved by the system (which I could see from the memory map). Regarding the FreeRTOS it is not so easy cause obviousy FreeRTOS has reserved some part of this memory for its heap and I do not know on what regions of memory are free to use and what are not.

So how would I know what memory regions are still unallocated and free to use? Or can (and should) I use pvPortMalloc() to first allocate some memory that I would then use for my DMA transactions? Is the pvPortMalloc() safe to use in my application code? Also, does the pvPortMalloc() function allocate me memory locate in the FreeRTOS heap or from the entire available memory on the DDR?

Upvotes: 1

Views: 729

Answers (2)

Richard
Richard

Reputation: 3236

If you use heap_1, heap_2, heap_4 (recommended), or heap_5 then the heap is effectively a statically allocated array, which means it goes into the .bss section - which memory it then goes into depends on where your linker script places the .bss.

Upvotes: 0

T.H.
T.H.

Reputation: 876

So how would I know what memory regions are still unallocated and free to use? Or can (and should) I use pvPortMalloc() to first allocate some memory that I would then use for my DMA transactions? Is the pvPortMalloc() safe to use in my application code?

Yes, unlike bare-metal application, in FreeRTOS you can allocate memory space by simply calling pvPortMalloc(bytesize), then pass the returned non-NULL pointer and size of the allocated space in bytes to your DMA controller. Also please recheck that the DMA controller won't write beyond the allocated space (because that could break internal data structure of free memory block management).

You don't have to know the detail e.g. which memory blocks are free, which are already allocated to other tasks ...etc. Depend on the heap implementation chosen in your FreeRTOS project, free memory block(s) is/are internally managed in heap_x.c see different heap implementations in FreeRTOS

Also, does the pvPortMalloc() function allocate me memory locate in the FreeRTOS heap or from the entire available memory on the DDR?

pvPortMalloc() allocates space only in the FreeRTOS heap, its size is determined by the define parameter configTOTAL_HEAP_SIZE.

Upvotes: 0

Related Questions