問題描述
在 Linux 中使用 DMA 的最簡單方法 (Easiest way to use DMA in Linux)
那麼是否有某種庫/API/任何東西真的可以從用戶空間進行 DMA 傳輸?(特別是從內存到內存映射的外圍設備(zynq 上 PS 和 PL 之間的 AXI4 端口)</p>
更新
過了一段時間夜間實驗,我得到了一個基本的 hello world 內核模塊來正確加載,所以我想我會走正確的路,寫一個小的設備驅動墊片,從用戶空間獲取大量數據(在這種情況下是圖像的一部分) 如果IC通過DMA api將其傳遞給FPGA部分
我會報告我的成功或失敗;)
參考解法
方法 1:
One potential option could be to use the UIO interface (See also this blog article)
There is some example code in the link, but the general structure of the code is:
- you have a little kernel module that handles the IO init and exposes the DMA. (See documentation)
- your userspace program then handles all the IO that you need in order to get it working. (See also example code)
Since you didn't specify what you want to do I cannot be more specific. But you need to figure how to initialize your memory in kernel (See the tag wiki for docs on that LDD3 is great).
方法 2:
I was surprised when I got a Zedboard a few years ago that I needed to write a device driver in order to connect my application to the programmable logic.
So I started work on the Connectal Framework to solve that problem. Connectal provides a generic device driver for Zynq FPGAs and for Xilinx or Altera FPGAs attached via PCI Express. The device driver enables user‑mode software to memory‑map the control interface of the hardware and to share memory (via DMA) with the hardware. It also provides an MMU for the programmable logic, so that applications and programmable logic can use the same linear offsets into shared memory objects.
Connectal uses Bluespec Systems Verilog for its hardware libraries, which might make the framework or its device drivers difficult to use in your application, but it is available and we would be happy to explain and document in more detail the hardware interface.
Connectal is available on github:
The relevant drivers are here:
- http://github.com/cambridgehackers/connectal/tree/master/drivers/zynqportal
- http://github.com/cambridgehackers/connectal/tree/master/drivers/portalmem
There are a couple of alternatives out there:
- zynq‑xdma: https://github.com/bmartini/zynq‑xdma/blob/master/dev/xdma.c
- Xillybus: http://xillybus.com/ (requires a license)
(by Filippo Savi、Alexander Oh、Jamey Hicks)