Git Product home page Git Product logo

axi-dma-api's Introduction

AXI-DMA-API

Simple API for working with AXI DMA on Zynq-7000 without using driver on Linux.
For correct work of this API you must to disable support of AXI DMA in kernel configurations. Like this (option DMA Engine support must be without asteriks *):

Image

Example

One of examples of transferring data between Zynq-7010 and Kintex-7.
Send command to Kintex and receive result (status) to Zynq:

#include <AxiDMA.h>
#include <AxiDmaBuffer.h>


int main() {
  AxiDmaBuffer *dynamic_tx_buffer = new AxiDmaBuffer();
  AxiDmaBuffer non_dynamic_rx_buffer;
  size_t statuses_len = 15; // size of waiting data

  // Set TX buffer: send command for getting statuses (i.e. from Zynq to Kintex)
  dynamic_tx_buffer->PushBack(0x01); // pnum
  dynamic_tx_buffer->PushBack(0x02); // pnum
  dynamic_tx_buffer->PushBack(0x0D); // command

  AxiDMA *dma_dev = new AxiDMA();
  int rs = dma_dev->Transf(dynamic_tx_buffer, &non_dynamic_rx_buffer, statuses_len);
  if (rs != 0) {
    delete dma_dev;
    delete dynamic_tx_buffer;
    return rs;
  }

  auto *rx_buff = new uint8_t[non_dynamic_rx_buffer.GetSize()];
  std::cout << "Get " << non_dynamic_rx_buffer.GetSize() << " bytes. So: "
            << std::endl;

  for (int i = 0; i < non_dynamic_rx_buffer.GetSize(); i++)
    printf("%d) 0x%02x\r\n", i, rx_buff[i]);

  delete[] rx_buff;
  delete dma_dev;
  delete dynamic_tx_buffer;
  return 0;
}

Other examples you could find in examples directory.

Install

To build this library, you must have cmake version of >= 3.13.
In the file toolchainfile.cmake in the variable CROSS_PATH, you must specify the path to your cross-compiler (which located in the ../Xilinx/SDK/../gnu/<your arch>/lin/bin).
And then in the console execute:

$ cd <path_to_this_repository>
$ cmake -DCMAKE_TOOLCHAIN_FILE=toolchainfile.cmake .
$ make

At the exit, you will get the compiled static library libaxidma_api.a.

Motivation

This API was written because Xilinx doesn't provide user friendly DMA character driver for Linux OS. All their examples (axidmatest.c, etc) is difficult understand (for non kernel/driver programmers) and in most cases is useless, IMHO.
In current time on github is exist good character driver written by bperez77. But it is very general and unfortunately has some problems in work with multithreading and you can't get information about (how much) transmission bytes (but it is not trouble of driver, so set by DMA engine in Linux OS).
Using this API you can create your own system which process AXI DMA transactions.

Note

Work with AXI DMA in SG (scatter gather) and Direct Register mode.
API is more slowly than using driver, but you can control all transaction how you need.
Used C++14.
Project work with Zynq-7010.
Linux kernel version of 4.14.
Vivado version of 2018.02.
SDK version of 2017.01.
In the branch original contains original repository of AXI DMA API from which was started this project.

Issues

In the current version of API not correct implemented wait* methods. Thus polling the status register for interrupts it may early get timeout.

axi-dma-api's People

Contributors

good-stuff avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nbarros tylorb

axi-dma-api's Issues

Linux 5.x

Hi,

Is this API tested on the linux kernel 5.x version?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.