element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development AXI_DMA device driver for Linux
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Avnet Boards Forums requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 28 replies
  • Subscribers 309 subscribers
  • Views 3308 views
  • Users 0 members are here
Related

AXI_DMA device driver for Linux

Former Member
Former Member over 12 years ago

Does any one know how to use the AXI_DMA device driver linux-xlnx/drivers/dma/xilinx_dma.c?
Does it work, has anyone tested it for AXI_DMA IP?
I need to use it as a module.

I have a bare metal AXI_DMA driver but porting it to Linux seems more complicated than I though.


I am new to Linux device drivers, this might be a trivial question for some of you.

Thanks,
Silviu

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 12 years ago

    Hi Silviu,
    I use VDMA IP. I try to use exactly same driver, but without succeed. I dont know how to use it. I found information about xvdma.c driver (http://forums.xilinx.com/t5/Embedded-Linux/Xvdma-Driver/td-p/279964) who works as bridge between base VDMA kernel driver and user application, but I am not able to colmpile it. I spent 2 days without succeed.
    My final solution is easy. I use mmap to access VDMA IP registers and program it. I have working solution after 2 hours.

    Linux is little hell. :-)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago

    Hi Vatu,
    Can you please share the code that uses mmap to control the driver from user space?

    Thank you,
    Silviu

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to Former Member

    Hi Vatu,
    In my case AXI DMA is at 0x40400000 but
    mmap() needs a file descriptor, fd.
    How do you create this fd if there is only a physical address that I need to access?
    Can fd be NULL?
    Does it mean that there must be a driver running already?
    Do I need to configure the device-tree file before I use the mmap()?


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to Former Member

    Hi Silviu,
    hete is my solution http://www.arbot.cz/post/2013/03/20/VDMA-on-ZedBoard.aspx.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to Former Member

    Hi Silviu,
    you can use fd=open("/dev/mem", O_RDWR) to get file descriptor.
    Function mmap maps physical addres to virtual adress space.

    mmap(NULL, <length>, PROT_READ | PROT_WRITE, MAP_SHARED, fd, <physical adress>);

    This solution access directly to VDMA IP registers, therefore you does not need any driver.

    You does not need instantiate any driver in device-tree, but is good idea to limit memory used by kernel to reserve physical memory for store data by DMA engine.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to Former Member

    Thanks, I spent more time reading a device driver book and I got to the same conclusion. The quick way to drive and get data from the AXI-DMA device is with mmap function. After that is like a bare metal driver.

    Another interesting way is to implement a small character driver that redefines the mmap to map it to a physical address. In theory you can use kmalloc() convert its return address to physical address with virt_to_phys().
    But I get a fragmentation issue  when using kmalloc().

    Thanks for your help,
    Silviu

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to Former Member

    Thanks, it helps a lot.

    Silviu

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago

    Hi Vatu,
    How do you invalidate the cache for one of your mmap regions?

    Thanks,
    Silviu

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago

    Hi Silviu,
    I have not yet figured out.
    One option is use ACP.

    Functional solution is interesting for me.

    Vatu

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Hi Vatu,
    A user space driver is like this:

    int dma_initUser(DmaDevId_t devid, XAxiDma_User_t *pUserConfig)
    {
    tconst XAxiDma_Config_t *pPhyConfig;
    tint fd;
    tvoid *vAddr;

    tpPhyConfig = LookupConfig(devid);
    tprintf("DMA phys addr = 0x%x
    ", (int)pPhyConfig->physDmaAddr);

    t//-------------------------------------
    t//Get base virtual address for the DMA registers
    t//-------------------------------------
    tfd = open("/dev/mem", O_RDWR | O_SYNC);
    tpUserConfig->fd = fd;

    tvAddr = mmap(NULL, pPhyConfig->dmaSize,
    tttPROT_READ | PROT_WRITE,
    tttMAP_SHARED, fd,
    tttpPhyConfig->physDmaAddr);

    tif(vAddr == MAP_FAILED) {
    ttgoto mmap1_err;
    t}

    tpUserConfig->virtDmaAddr = (u32)vAddr;
    tpUserConfig->dmaSize = pPhyConfig->dmaSize;

    t//-------------------------------------
    t//Get virtual address for the DMA RX buffer
    t//-------------------------------------
    tfd = open("/dev/mem", O_RDWR | O_SYNC);
    tvAddr = mmap(NULL, pPhyConfig->buffPoolSize,
    tttPROT_READ | PROT_WRITE,
    tttMAP_SHARED, fd,
    tttpPhyConfig->physBuffAddr);

    tif(vAddr == MAP_FAILED) {
    ttgoto mmap2_err;
    t}

    tpUserConfig->virtBuffAddr = (u32)vAddr;
    tpUserConfig->physBuffAddr = pPhyConfig->physBuffAddr;
    tpUserConfig->buffPoolSize = pPhyConfig->buffPoolSize;
    tpUserConfig->fpgaPktSize = pPhyConfig->fpgaPktSize;
    tpUserConfig->devid = pPhyConfig->DeviceId;

    treturn 1;

    mmap1_err:
    tperror("[dma_driver]ERROR: DMA mmap() failed
    ");
    tclose(fd);
    tassert(0);

    mmap2_err:
    tperror("[dma_driver]ERROR: Buffer mmap failed
    ");
    tmunmap((void*)pUserConfig->virtDmaAddr, pUserConfig->dmaSize);
    tclose(fd);
    tassert(0);
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube