在 Linux 中使用 DMA 的最簡單方法 (Easiest way to use DMA in Linux)


問題描述

在 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:

There are a couple of alternatives out there:

(by Filippo SaviAlexander OhJamey Hicks)

參考文件

  1. Easiest way to use DMA in Linux (CC BY‑SA 2.5/3.0/4.0)

#linux-kernel #xilinx #embedded-linux #C #linux-device-driver






相關問題

選擇 Linux I/O 調度程序 (Selecting a Linux I/O Scheduler)

Android可加載內核模塊錯誤:賦值使指針從沒有強制轉換的整數 (Android Loadable Kernel Module Error: assignment makes integer from pointer without a cast)

文件描述符中實際存儲了多少信息? (How much information is actually stored in a file descriptor?)

hrtimer mengulangi tugas di kernel Linux (hrtimer repeating task in the Linux kernel)

我可以在 C 代碼中使用 LKM 內核代碼中的“getpwuid”嗎? (Can I use "getpwuid" from kernel code in LKM in c code?)

將傳入數據包注入網絡接口 (Injecting an incoming packet to a network interface)

無法從 D3 睡眠狀態喚醒 pci 總線 (Unable to wake pci bus form D3 sleep satate)

在 Linux 中使用 DMA 的最簡單方法 (Easiest way to use DMA in Linux)

Linux I2C 通信問題 (Linux I2C communication issues)

理解 perf stat 輸出中的數字 (Make sense of numbers in perf stat output)

我如何在 amazon Linux AMI 上找到我的 Linux 發行版? (How i could find my Linux distribution on amazon Linux AMI?)

將參數傳遞給系統調用 (Passing arguments to system calls)







留言討論