cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
2,052 Views
Registered: ‎05-10-2017

Access DMA from linux

Hello,

i need to trans-fair some data from PS to PL, with Debian running on PS. As far as I know, since kernel 3.6, is the approach to use the Linux DMA API.
So i have to include dma-mapping.h or dmaengine.h in module or application.

My problem now is that in my petalinux build dir none of this files are present.
There is no files with dma, no dmaengine.h, dma-mapping.h or xilinx_dma.h ... except rdma in kernel include or rootfs /usr/include directory. But in the kernel 4.4  source are thoes files present and
In the kernel config alls options with the xilinx dma engine is enabled.

So what did go wrong in my build process, how do i get those DMA header files!?

Thanks,

Steve

0 Kudos
17 Replies
Highlighted
Voyager
Voyager
2,039 Views
Registered: ‎06-24-2013

Hey @steve-82,

 

i need to trans-fair some data from PS to PL

While DMA is one way to transfer the data, there are a number of other ways as well ...

  • By using a memory mapped AXI slave
  • By reading the memory directly from the PL via one of the high performance busses
  • Via one of the PS peripherials with EMIO connections
  • Via EMIO GPIO

Best,

Herbert

-------------- Yes, I do this for fun!
Highlighted
Explorer
Explorer
1,984 Views
Registered: ‎07-17-2014

 

I recently got DMA working with Petalinux 2015.4

My DMA inclusions are:

#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>

 

Let me know if that helps.

0 Kudos
Highlighted
1,312 Views
Registered: ‎07-05-2018

Hi, recently I met the same problem I can't find those files

<linux/dma-mapping.h>

 Would you please give more details?

0 Kudos
Highlighted
Explorer
Explorer
1,293 Views
Registered: ‎07-17-2014

Can you tell us which version of petalinux you're using? (that matters)

Also, let us know how you're building your project. (I'm using the petalinux-build scripts)

I find the needed files in my build directory under:

<project-dir>/build/linux/u-boot/src/u-boot-plnx/arch/arm/include/asm/dma-mapping.h

0 Kudos
Highlighted
Explorer
Explorer
1,282 Views
Registered: ‎07-17-2014

I can't edit my last reply... so ...

It's also found in:

./components/linux-kernel/xlnx-4.0/arch/arc/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/microblaze/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/arm64/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/cris/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/parisc/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/metag/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/ia64/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/s390/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/sparc/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/xtensa/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/hexagon/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/tile/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/x86/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/powerpc/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/blackfin/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/frv/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/mn10300/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/openrisc/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/unicore32/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/nios2/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/sh/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/mips/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/m68k/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/alpha/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/c6x/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/avr32/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/arch/arm/include/asm/dma-mapping.h
./components/linux-kernel/xlnx-4.0/include/linux/dma-mapping.h
0 Kudos
Highlighted
1,262 Views
Registered: ‎07-05-2018

I'm using petalinux 2018.3, same as you I'm using the petalinux-build scripts

Did you do petalinux-build --sdk and petalinux-package --sysroot?

 

0 Kudos
Highlighted
1,257 Views
Registered: ‎07-05-2018

I was wondering how's your code will be like?

Did you generate sysroot and use it in sdk to cross compiler your code?

now I can find those linux/dmaxxxxx.h 

but I'm facing several asm/asm-generic file include error

0 Kudos
Highlighted
Explorer
Explorer
1,244 Views
Registered: ‎07-17-2014

Ahh... well, I'm not on 2018.3 -- I was compiling from 2015.4.. so that's different (and in a big way).

Can you list for us the errors you're seeing when the build errors out?

 -Ben

0 Kudos
Highlighted
1,233 Views
Registered: ‎07-05-2018

asm/asm-generic file include issue

So it's like you generate sysroot and include it in sdk, then call linux/dmaxxxx.h and it worked?

how many path did you include in sdk?

0 Kudos
Highlighted
1,229 Views
Registered: ‎07-05-2018

my issue now seems like, some file need asm/xxxx.h but it's actually in asm-generic/xxxx.h

0 Kudos
Highlighted
Explorer
Explorer
1,219 Views
Registered: ‎07-17-2014


eleicoto@outlook.com wrote:

asm/asm-generic file include issue

So it's like you generate sysroot and include it in sdk, then call linux/dmaxxxx.h and it worked?

how many path did you include in sdk?


Not using the SDK at all. Have always just compile projects straight from commandline using "petalinux-build".

 -Ben

0 Kudos
Highlighted
1,199 Views
Registered: ‎07-05-2018

The workflow I'm using is like this

generate sysroot in petalinux --> include sysroot in vivado sdk --> coding --> cross compiler --> copy xxx.elf to baord --> run xxx.elf

So what the worlflow will be like if I use petalinux to build my code?

0 Kudos
Highlighted
Visitor
Visitor
588 Views
Registered: ‎01-19-2020

Hello,

have you solved it please, i have the same problem

I'm using petalinux 2019.2

Thanks

0 Kudos
Highlighted
Explorer
Explorer
517 Views
Registered: ‎07-17-2014

Samokaad,

What problem are you having exactly? (multiple items are discussed in this thread)

0 Kudos
Highlighted
Visitor
Visitor
255 Views
Registered: ‎04-27-2020

Hi,
I also did not get the both of file in my petalinux 2020.1 whereas I built the petalinux as per the documentation of v2020.1.

I want to use DMA to transfer the data from my Custome IP to PL. but don't know what I am missing that I can not use it.
when I build the app using "petalinux-build -c myapp" command, myapp included

#include <linux/dma-mapping.h>

and main() function.

Some Error is:

ERROR: myapp-1.0-r0 do_compile: oe_runmake failed
ERROR: myapp-1.0-r0 do_compile: Execution of '/home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0/temp/run.do_compile.28048' failed with exit code 1:
aarch64-xilinx-linux-gcc -march=armv8-a+crc -mtune=cortex-a72.cortex-a53 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0=/usr/src/debug/myapp/1.0-r0 -fdebug-prefix-map=/home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0=/usr/src/debug/myapp/1.0-r0 -fdebug-prefix-map=/home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0/recipe-sysroot= -fdebug-prefix-map=/home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0/recipe-sysroot-native= -c -o myapp.o myapp.c
myapp.c:1:10: fatal error: linux/dma-mapping.h: No such file or directory
1 | #include <linux/dma-mapping.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: myapp.o] Error 1
WARNING: exit code 1 from a shell command.

ERROR: Logfile of failure stored in: /home/darpan/Downloads/Argon/project/ArastuSystemsOS/build/tmp/work/aarch64-xilinx-linux/myapp/1.0-r0/temp/log.do_compile.28048

please help me with this. Thank You So Much in Advance.

 

0 Kudos
Highlighted
229 Views
Registered: ‎02-24-2020

@sandippatel 

The Linux DMA API is not directly accessible from the userspace (i.e. your app). You would need to create a Linux driver to use the DMA API and then bridge this to your app via a standard userspace interface:

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Highlighted
Explorer
Explorer
200 Views
Registered: ‎07-17-2014

@sandippatel 

What @ksloatdesignlinx says.

This is what I did.

my DMA driver lives in my kernel driver and I use IOCTLs to control the behavior.

There is also a VM space (as the wiki link describes) where my user-space application can access the DMA buffer directly without the Kernel->user Copy using something like read().

It works fabulously.

0 Kudos