6
votes

I would like to write a driver in kernel space that:

  • Communicate a FPGA connected by PCIe in a embedded system( with powerPC).
  • It uses DMA to transfer information from the FPGA to RAM.
  • User programs have to access to this information.

I need some example that make something similar to guide me. Does anyone any idea where I can found some source?

2
There are many PCIe IP cores for FPGAs on the internet: XillyBus, Riffa, ... many of them have open source drivers.Paebbels
Check latest kernel sources under drivers/dma0andriy

2 Answers

2
votes

Connectal (http://www.connectal.org) is an open source framework that enables user-space software to communicate to Xilinx or Altera FPGAs. Very little of that communication involves the device-driver, actually.

Connectal supports message-passing between the software and hardware over memory mapped hardware FIFOs, and it supports shared memory via DMA from the FPGA.

The device-driver is designed to be architecture independent but PCIe communication has only been tested from x86.

Connectal also supports Zynq, so some of the problems you will run into (non-snooped I/O) have been debugged.

Connectal's hardware is currently implemented in Bluespec Systems Verilog and uses Xilinx or Altera PCIe cores.

0
votes

The Linux Device Drivers 3rd Edition is a good resource for this. It contains all of the information that you would need to map in a PCIe device and create device files that user space programs can use. It also comes with example source code that can be found from the website that accompanies the book. I would recommend purchasing the book if you plan on doing much kernel module development.

As far as getting the FPGA to perform the DMA... Here are some of my assumptions: * You have the hardware part down because you have only mentioned needing help with kernel driver * You have a PCIe PLB bridge (also assuming Virtex 5 with PowerPC) * You also have a hardware DMA controller in your FPGA that is mapped into the PCIe address space

I would create a device driver that has IOCTLs to set source/destination addresses for the DMA. That way your user space program can perform the IOCTLs to program the DMA controller in the FPGA.