cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
leroyworld1
Observer
Observer
11,756 Views
Registered: ‎09-11-2014

Compiling AXI DMA linux drivers in SDK.

Jump to solution

Hi guys,

I think I'm doing something wrong and It's making me crazy. I've got:

Vivado 2015.2 w/ SDK.

Zynq zc702.

Tested in Linux 14.04 and Windows 7.

 

And I want to use the axi dma drivers in a Linux application so that I downloaded the axidma_test.c example. At first most of the linux libraries threw an error until I linked somehow the libraries I found in the git repository "linux-xlnx/include".

repo.jpg

Then all of the "linux/*.h" libraries are recognized, but a new error appears: fatal error: asm/linkage.h not found. I tried to include this last one but I just made it worse. I cut down the code so that I only have a small snippet, having the same error:

#include <linux/dma-mapping.h>
int main() {
    printf("Hello World\n");
    return 0;
}

I'm starting to think that I'm making it more difficult than it should be.

Could anyone give me some advise how to successfully compile that small snippet? I would really appreciate it.

Regards,
Leroy

 

 

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
muzaffer
Teacher
Teacher
20,286 Views
Registered: ‎03-31-2012
actually using the dma driver from user space without any driver support is quite difficult as there is no built-in user space support for converting virtual addresses to physical addresses. You need at least one driver to do this for you. If you want SG, the filling has to be done, manually or by help of a driver.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.

View solution in original post

9 Replies
muzaffer
Teacher
Teacher
11,737 Views
Registered: ‎03-31-2012
as far as I understand axidma_test is a kernel level module not a user app so you can't link it with printf etc.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
leroyworld1
Observer
Observer
11,729 Views
Registered: ‎09-11-2014

Okay, that makes sense.

The actual problem to adress is that I want to develop a linux app in SDK (let's say the snippet above) which uses axidma libraries/drivers. But I don't know if that would be even possible as SDK is not able to compile that snippet.

It's probably a noob question but I'm kind of lost right now.

0 Kudos
bwiec
Xilinx Employee
Xilinx Employee
11,685 Views
Registered: ‎08-02-2011
Yes, as muzaffer mentioned, axidma_test is indeed a kernel module and doesn't present a user-space interface.

I'd recommend poking through @linnj 's old posts. He has a lot of info about using the AXI DMA with linux driver.
www.xilinx.com
0 Kudos
leroyworld1
Observer
Observer
11,658 Views
Registered: ‎09-11-2014

Hi @bwiec,

I've checked almost all linnj's posts and they are all about how to solve problems when using DMA, once you have compiled the application. But we're one step behind, I can't get the application to compile (to obtain the .elf).

We've already got a DMA-SG working flawlessly in baremetal and we just wanted to migrate this to Linux. We know how to generate all the files needed (dtb, uimage, ...), but we are struggling with the .elf. My guess is I should be able to use some drivers like these:

https://github.com/Xilinx/linux-xlnx/blob/master/drivers/dma/xilinx/xilinx_dma.c

For that, we are creating a "New -> Application Project -> Linux -> Helloworld" example, and as soon as we include some headers like "linux/init.h" the errors (unrecognized file) start to come up.

I don't know whether:
- I'm completely misled and this is not the way to create applications in order to use dma under Linux.
- I have to add some missing repositories.
- I have to link a directory with missing headers.
- All my SDK versions are bugged...

I know it may be the simplest thing, but I can't find any post where somebody also had this problem.


bwiec
Xilinx Employee
Xilinx Employee
11,613 Views
Registered: ‎08-02-2011

Hello Leroy,

 

Hmmm okay I found the one that I was thinking of:

http://forums.xilinx.com/t5/Embedded-Linux/AXI-DMA-with-Zynq-Running-Linux/m-p/523105#M10658

 

There's a presentation there with some code. About halfway down the pdf is an explanation of the software architecture for the AXI DMA linux driver and an explanation of where you need to add your application-specific layers and an example of doing so.

 

As far as compiling, you really need two pieces still (bear in mind, I'm a little out of my area of expertise talking about the linux software side, so someone with more knowledge may correct the finer details. This is based on what I've gathered...):

1) Kernel module to interface from the driver to userspace (for simplicity, you might use UIO for this like the second pdf that linnj posted in that link)

2) Some application that runs in userspace that communicates with 1 above.

 

For 1, you don't use SDK. You build a cross compile environment dependent on your kernel configuration and follow build steps:

http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html

 

For 2, you'd use SDK as you are to build a Linux 'Application' (the word seems to have the connotation of running in userspace).

www.xilinx.com
muzaffer
Teacher
Teacher
11,589 Views
Registered: ‎03-31-2012
xilinx_dma.c is a kernel level driver. From a user space app you can't use it at all.
What you can do is to 1) open your device and send it some ioctls 2) mmap the hardware register space of the device and write values to it by using the address map of the device.
I am assuming the latter is what you did in baremetal case. Just change your direct accesses to indirection through mmap'ed addresses.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
leroyworld1
Observer
Observer
11,365 Views
Registered: ‎09-11-2014

Hi again,

I appreciate your answers.

Bwiec, we ended up using a simpler design with a BRAM, as I'm not a Linux expert and what you said looks like a lot of trouble. I was expecting it would be easier to communicate PS->PL through DMA using Linux, but it turns out it isn't.

@muzaffer, that sounds good and it's what we are doing with the BRAM. But just out of curiosity, what happens if you are using DMA with Scatter Gather? when I use mmap (so there's no drivers), am I supposed to write manually into the registers to config the buffer descriptors, rings allocation, and so on? Or is that autoconfiged somehow when writing to DMA?

Regards,
Leroy

0 Kudos
muzaffer
Teacher
Teacher
20,287 Views
Registered: ‎03-31-2012
actually using the dma driver from user space without any driver support is quite difficult as there is no built-in user space support for converting virtual addresses to physical addresses. You need at least one driver to do this for you. If you want SG, the filling has to be done, manually or by help of a driver.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.

View solution in original post

leroyworld1
Observer
Observer
11,329 Views
Registered: ‎09-11-2014

Okay, that's what I thought. That looks like quite a lot of development time we cannot afford right now.

I really appreciate your help guys.

Cheers,
Leroy.

0 Kudos