Skip to content

zeroherolin/xdma-dma-sg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuring FPGA DMA-SG via PCIe XDMA

This repository provides a paradigm of operating DMA-SG with the usage of XDMA driver. By calling Shell script in the terminal, the host PC can control the FPGA device programmatically without compiling.

The flow is based on connecting the DMA-s port to PCIe XDMA. This may seem redundant, but it is just for testing. You can connect the s-port to any stream device without reconstructing the shell scripts.

Getting Started

Prerequisites

  • Make sure you have the necessary hardware and software environment set up, including the DMA IP drivers [https://github.com/Xilinx/dma_ip_drivers].
  • Make sure you have the required permissions to execute commands and access devices.

Instructions

Note: You must first modify dma_param.sh according to your platform.

  • Compile XDMA driver and tools
cd external/dma_ip_drivers/XDMA/linux-kernel/xdma
make
sudo insmod xdma.ko # Temporary installation
cd ../tools
make
  • Generate test data
# cd external/dma_ip_drivers/XDMA/linux-kernel/tools
rm -f *.bin
# dd if=/dev/zero of=test0.bin bs=4096 count=1 # Generate all 0s
python -c 'open("test01.bin", "wb").write(bytes([i % 256 for i in range(4096)]))' # Generate increasing numbers
cd ../../../../..
  • Add executable permissions
sudo chmod +x dma_rst.sh
sudo chmod +x dma_wr_desc.sh
sudo chmod +x dma_h2c.sh
sudo chmod +x dma_c2h.sh
  • Perform test
# DMA soft reset
sudo ./dma_rst.sh

# XDMA writes DMA data (to MM)
sudo external/dma_ip_drivers/XDMA/linux-kernel/tools/dma_to_device -d /dev/xdma0_h2c_0 \
    -f external/dma_ip_drivers/XDMA/linux-kernel/tools/test01.bin -s 4096 -a 0 -c 1

# DMA Write Descriptors
sudo ./dma_wr_desc.sh

# DMA S2MM (H2C) transfer
sudo ./dma_h2c.sh

# DMA MM2S (C2H) transfer
sudo ./dma_c2h.sh

# XDMA reads DMA data (from MM)
sudo external/dma_ip_drivers/XDMA/linux-kernel/tools/dma_from_device -d /dev/xdma0_c2h_0 \
    -f external/dma_ip_drivers/XDMA/linux-kernel/tools/test1.bin -s 4096 -a 0 -c 1

# Check data back
xxd external/dma_ip_drivers/XDMA/linux-kernel/tools/test1.bin

Flow

About

Host shell scripts: configure FPGA's DMA-SG via PCIe XDMA.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages