cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lm_atl
Explorer
Explorer
5,610 Views
Registered: ‎01-13-2016

Checking DMA from linux?

I am trying to figure out the DMAC IP core.

 

In Vivado, under 'Address Editor', with the DMAC connected to an HP port on my Zynq PS7 block, it shows up with an Offset Address at 0x7C400000 and a High Address at 0x7C40FFFF.

 

What would be a good way to access this DMA'd memory from userspace in Linux? The vendor that provided the example PL logic also provided an application that I'm using to verify that the DMAC is writing data, and that application is able to read it, but I would like to get the raw data from memory myself.

 

Googling around, I found the mmap function, which seemed like it would do the job. So I tried an mmap to /dev/mem, with an offset of 74C00000, and tried using that to write to a file while the vendor app was running(and therefore I knew the DMAC was writing). However, when I look at the file of my mmap, it's full of zeros, when I know that's not what the DMAC is writing.

 

Is there a better way for me to access that DMA'd data?

0 Kudos
8 Replies
jeffdaq
Explorer
Explorer
5,591 Views
Registered: ‎11-22-2015

You are mmaping in the register space of the DMAC.  Somebody is allocating memory and providing that address to the DMAC to write to.   Did you look at the sample app?  This is likely where memory is being allocated.

 

jeff

0 Kudos
lm_atl
Explorer
Explorer
5,582 Views
Registered: ‎01-13-2016

The sample app is a precompiled binary, I don't have the source code for it to look at.

 

I found the dma channel in /sys/class/dma/ though, is there any way for me to see where the channel is configured to write to from there?

0 Kudos
shabbirk
Moderator
Moderator
5,569 Views
Registered: ‎12-04-2016

Hi

 

Can you please check this link for example DMA app in Linux:

https://github.com/dhytxz/zynq-linux-dma

 

Regards,
Shabbir
----------------------------------------------------------------------------------------------
Kindly note- 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
lm_atl
Explorer
Explorer
5,532 Views
Registered: ‎01-13-2016

Hi Shabbirk,

 

Thanks for that link, I hadn't seen this example.

 

I guess I need to recompile my kernel with the XDMA module active, because I don't have that in /dev/.

 

Is there a configuration I can set in the Linux Config fileto activate that module, rather than through Petalinux? I see that I already have CONFIG_AXI_DMAC CONFIG_DMADEVICES and CONFIG_XILINX_DMA  set, but that isn't setting the xdma device to show up

0 Kudos
shabbirk
Moderator
Moderator
5,526 Views
Registered: ‎12-04-2016

Hi

 

Can you please follow this link:

https://github.com/bmartini/zynq-xdma

 

Basically Its a wrapper driver to configure xdma, and yes you can do this in non-petalinux flow.

 

 

Regards,
Shabbir
----------------------------------------------------------------------------------------------
Kindly note- 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
lm_atl
Explorer
Explorer
5,523 Views
Registered: ‎01-13-2016

I appreciate all the info.

 

However, I'm not sure this module is compatible with my kernel.

 

There's something in the documentation that mentions this is for 3.15, but I am using the update to 4.6 Linux kernel.

 

When I tried building the module, it failed because #include<linux/amba/xilnx_dma.h> isn't present. However, there IS a<linux/dma/xilinx_dma.h>, so I tried that, but it only led to more errors.

 

I'm not sure if this code is still valid in the newer kernel release.

0 Kudos
debrajr
Moderator
Moderator
5,468 Views
Registered: ‎04-17-2011

There was a previous discussion on this topic which you might not have searched for. Refer link: https://forums.xilinx.com/t5/Embedded-Linux/AXI-DMA-transfer-from-user-space/td-p/739954
Regards,
Debraj
----------------------------------------------------------------------------------------------
Kindly note- 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
jeffdaq
Explorer
Explorer
5,465 Views
Registered: ‎11-22-2015

  If you are able to run the pre-compile app then clearly your kernel already has the right stuff.   If you are trying to figure how the app is configuring the registers you can just use devmem to dump the registers of the DMAC before and after running the app.  devmem should be installed in your rootfs already.  

  this would give you some idea of what is happening but wouldn't tell you everything.

 

jeff

 

0 Kudos