Code Monkey home page Code Monkey logo

dma's Introduction

UDMA

Background

We are used to controlling our custom AXI4-Full/Lite IP through UIO driver, but not AXI4-Stream IP. Because AXI4-Stream IP has different architecture(customStreamIP.jpg), the UIO device node will not be created. Instead, DMA controler will appearing, and UIO driver can't adapt this situation. As a result, we decide to make a little modification on UIO driver and make a little tricky setting in devicetree file. After modifying, we can control our custom AXI4-Stream IP through UIO driver.

Usage

  1. Specify which dmaengine-compatible DMA channels you'd like to create userspace-accessible device files for in your device tree:

    udma0 {
        compatible = "generic-uio";
        dmas = <&loopback_dma 0 &loopback_dma 1>;
        dma-names = "loop_tx", "loop_rx";
        udma,dirs = <2 1>;      // direction of DMA channel: 
                                //   1 = RX (dev->cpu), 2 = TX (cpu->dev)
    };
    

For now, udma only support two channel device(one s2mm and one mm2s), please ensure the device node get the correct reference of dma channel.

  1. After booting Linux, uio node will become available,

        /dev/uioX
    
  2. Sending data is as simple as:

        int xfer_size = 16;
        uint32_t tx_buf[xfer_xize], rx_buf[xfersize];
        int fd = open("/dev/uio0", O_RDWR | O_SYNC);
    
        write(fd, tx_buf, xfer_size);    // send a DMA transaction
        read (fd, rx_buf, xfer_size);
    

Compiling the Kernel

We make a little modification on uio.c and uio_pdrv_genirq.c, so we need to replace these two files. Further, we add udma.c and udma.h, please put udma.c under "KERNEL_DIR/drivers/uio/" and udma.h under "KERNEL_DIR/include/linux/". After recompiling, you will get a Linux Kernel with UIO drvier supporting AXI DMA.

Shell Script

We will write a shell script to help users doing these works including creating a virtual device node in devicetree file, replacing and adding files in Linux Kernel directory, compiling kernel, and generating boot files.

License (GPL)

Copyright (C) 2018 Billy Liu

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.

dma's People

Contributors

yllibliu avatar

Watchers

 avatar

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.