cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
cam_b
Visitor
Visitor
693 Views
Registered: ‎06-04-2020

Linux AXI DMA Design Flow

Jump to solution

Hi all,

I've been really struggling with implementing the AXI DMA Scatter Gather engine in the embedded Petalinux image.

I have developed it in baremetal and is working well. I wanted to then create the same functionality in the embedded Linux image. This obviously must be a different program than the baremetal program due to the different drivers, memory map, etc. I ensured my Petalinux image was configured correctly based on online resources, but now I'm not sure where to go from there.

I have tried multiple ways to use the Linux drivers to make this function correctly and cannot seem the correct way to go about it.

What I've tried:

  1. Copy sysroot to my windows machine from Linux VM to use in development in Vitis using mmap to translate addresses.
  2. Develop application following the steps in UG1144 using mmap to translate addresses. 
  3. Download drivers from here: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842337/Linux+Soft+DMA+Driver#LinuxSoftDMADriver-KernelConfiguration and follow along with these steps.

I can see the dma drivers in the petalinux project and some dma related modules names in /lib/modules/4.19.0-xilinx-v2019.2/modules.builtin. But I have no idea how to use these or develop some code taking advantage of these. Not sure if my blockage is that I don't understand how these drivers work in Linux well enough, or I'm missing something fundamental in the design flow.

My end goal is to have a binary on the Linux image that can run and do the same thing my baremetal program did, but on the Linux side. Any help as far as the design flow on how to get to this point would be greatly appreciated. 

Thanks in advance for your help,
Cameron

1 Solution

Accepted Solutions
ksloatdesignlinx
Explorer
Explorer
620 Views
Registered: ‎02-24-2020

If you are using PetaLinux you should just be able to select AXI DMA drivers in the kernel config and then when you boot and run "dmesg" you should see messages regarding AXI DMA being probed.

If you are using the Linux driver then you must use the Linux DMA API to control the DMA engine. Note that the API is not directly accessible from the userspace and is intended to be used by another driver in kernel space. The usual way to allow some type of userspace control is to write a custom kernel space "proxy driver" to handle the DMA portion and then that driver can provide an interface to userspace (ioctl, read/write, etc) to allow your userspace application to perform DMA. Xilinx has an example userspace application and "proxy driver" that uses the Linux AXI DMA driver:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com

View solution in original post

3 Replies
ksloatdesignlinx
Explorer
Explorer
621 Views
Registered: ‎02-24-2020

If you are using PetaLinux you should just be able to select AXI DMA drivers in the kernel config and then when you boot and run "dmesg" you should see messages regarding AXI DMA being probed.

If you are using the Linux driver then you must use the Linux DMA API to control the DMA engine. Note that the API is not directly accessible from the userspace and is intended to be used by another driver in kernel space. The usual way to allow some type of userspace control is to write a custom kernel space "proxy driver" to handle the DMA portion and then that driver can provide an interface to userspace (ioctl, read/write, etc) to allow your userspace application to perform DMA. Xilinx has an example userspace application and "proxy driver" that uses the Linux AXI DMA driver:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com

View solution in original post

cam_b
Visitor
Visitor
603 Views
Registered: ‎06-04-2020

Thanks,

This answers the question I asked. That helps us know which direction we want to go with the design.

Thank you for your help with this!

Lordlothard
Observer
Observer
148 Views
Registered: ‎03-12-2021

Hi, Thank you for the tip ! As a linux novice, it is clear to me now.

However I still have some unclear things about the device tree. We have to add the client node to the device tree in order to use the driver dma_proxy : 

/* To use this driver a node must be added into the device tree.  Add the
 * following node while adjusting the dmas property to match the name of
 * the AXI DMA node.
 */
  dma_proxy {
     compatible ="xlnx,dma_proxy";
     dmas = <&axi_dma_0 0
             &axi_dma_0 1>;
     dma-names = "dma_proxy_tx", "dma_proxy_rx";
  }

While its quite evident that the IP DMA Node is located in pl.dtsi , under the node of the amba Bus :  amba_pl: amba_pl@0     ,  Where does this small dma client node go ? 

Thak you very much for your help, 

Gautier

0 Kudos