cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
samoaibo
Observer
Observer
422 Views
Registered: ‎02-04-2020

The exchange of data between the CPU and FPGA from Petalinux. zcu104

Jump to solution

Is it possible to somehow transfer data from the CPU to the FPGA via PS ddr4 in linux application ? I want to allocate a section of physical memory, place data there, then pass the physical address to the custom IP. But as I understand it, linux doesn't allow you to do this. What other ways are there to exchange data without using PL memory and opencl?

Thanks

0 Kudos
1 Solution

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

A really good example of where this is done all the time with Xilinx is with DMA. For example, using the AXI DMA IP to move data placed in RAM to the PL (AXI MM to Stream) and vise versa (AXI Stream to MM). It's done exactly how you said too, via configuration registers on the AXI DMA IP you tell it where the data is in RAM you want it to transfer and it fetches it and streams to the PL.

https://www.xilinx.com/products/intellectual-property/axi_dma.html

As far as Linux is concerned, the challenge is usually in interfacing with the physical addresses in RAM from your userspace application to put and fetch the data. There are a couple ways to do this. In the case of AXI DMA, these IPs have Linux drivers to setup and drive the device via their config registers and the Linux DMA API and if you take this route, you will need to write a kernel proxy driver that allows your userspace application to interact with the DMA driver (Xilinx has a good example driver and app for this):

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space 

 

You can also proceed the userspace route which usually involves memory mapping the AXI device registers and an area of reserved RAM via UIO (or /dev/mem) and driving that all from userspace (search something like "UIO memory mapping" to find some topics about this).

 

 

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

View solution in original post

1 Reply
ksloatdesignlinx
Explorer
Explorer
364 Views
Registered: ‎02-24-2020

A really good example of where this is done all the time with Xilinx is with DMA. For example, using the AXI DMA IP to move data placed in RAM to the PL (AXI MM to Stream) and vise versa (AXI Stream to MM). It's done exactly how you said too, via configuration registers on the AXI DMA IP you tell it where the data is in RAM you want it to transfer and it fetches it and streams to the PL.

https://www.xilinx.com/products/intellectual-property/axi_dma.html

As far as Linux is concerned, the challenge is usually in interfacing with the physical addresses in RAM from your userspace application to put and fetch the data. There are a couple ways to do this. In the case of AXI DMA, these IPs have Linux drivers to setup and drive the device via their config registers and the Linux DMA API and if you take this route, you will need to write a kernel proxy driver that allows your userspace application to interact with the DMA driver (Xilinx has a good example driver and app for this):

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space 

 

You can also proceed the userspace route which usually involves memory mapping the AXI device registers and an area of reserved RAM via UIO (or /dev/mem) and driving that all from userspace (search something like "UIO memory mapping" to find some topics about this).

 

 

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

View solution in original post