# Trying to do a simple DMA loopback (Memory A-\> DMA -\>Memory B) in a PYNQ z-1 board (I know you guys would redirect me to xilinx forum but I just wanted your opinion). Anybody has any leads on how to do it with C programming?

**URL:** <https://discuss.pynq.io/t/trying-to-do-a-simple-dma-loopback-memory-a-dma-memory-b-in-a-pynq-z-1-board-i-know-you-guys-would-redirect-me-to-xilinx-forum-but-i-just-wanted-your-opinion-anybody-has-any-leads-on-how-to-do-it-with-c-programming/6411>\
**Category:** Support\
**Created:** [December 7, 2023, 10:20am UTC](https://discuss.pynq.io/t/trying-to-do-a-simple-dma-loopback-memory-a-dma-memory-b-in-a-pynq-z-1-board-i-know-you-guys-would-redirect-me-to-xilinx-forum-but-i-just-wanted-your-opinion-anybody-has-any-leads-on-how-to-do-it-with-c-programming/6411 "2023-12-07T10:20:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pranav\_Chaitanya](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/pranav_chaitanya/32/5193_2.png) [@Pranav\_Chaitanya](https://discuss.pynq.io/u/Pranav_Chaitanya)\
**Post date:** [December 7, 2023, 10:20am UTC](https://discuss.pynq.io/t/trying-to-do-a-simple-dma-loopback-memory-a-dma-memory-b-in-a-pynq-z-1-board-i-know-you-guys-would-redirect-me-to-xilinx-forum-but-i-just-wanted-your-opinion-anybody-has-any-leads-on-how-to-do-it-with-c-programming/6411/1 "2023-12-07T10:20:35Z")

</div>

Using -PYNQ Z-1 board. Petalinux 2021.1

---

<div class="post-metadata">

**Author:** ![joshgoldsmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/joshgoldsmith/32/5347_2.png) [@joshgoldsmith](https://discuss.pynq.io/u/joshgoldsmith)\
**Post date:** [December 7, 2023, 12:21pm UTC](https://discuss.pynq.io/t/trying-to-do-a-simple-dma-loopback-memory-a-dma-memory-b-in-a-pynq-z-1-board-i-know-you-guys-would-redirect-me-to-xilinx-forum-but-i-just-wanted-your-opinion-anybody-has-any-leads-on-how-to-do-it-with-c-programming/6411/2 "2023-12-07T12:21:09Z")

</div>

Hi Pranav,

The Xilinx Linux kernel repo has some example code using the DMA in C. Maybe this would be a good place to start. You can find that, along with the drivers, [here](https://github.com/Xilinx/linux-xlnx/tree/master/drivers/dma/xilinx).

Other than that, I’d have a good read of [PG021](https://docs.xilinx.com/r/en-US/pg021_axi_dma) as there are some quirks with the DMA IP that can trip you up.

If you want to use Scatter Gather then it gets a bit more complicated. It might be worth looking at the PYNQ implementation of the [DMA driver](https://docs.xilinx.com/r/en-US/pg021_axi_dma), as it’s written in pure Python, and is a bit easier to read than the C driver. It makes a good reference when comparing descriptions of the SG functionality in PG021 and how it’s implemented in the driver.

Josh

---

<div class="post-metadata">

**Author:** ![Pranav\_Chaitanya](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/pranav_chaitanya/32/5193_2.png) [@Pranav\_Chaitanya](https://discuss.pynq.io/u/Pranav_Chaitanya)\
**Post date:** [December 7, 2023, 1:13pm UTC](https://discuss.pynq.io/t/trying-to-do-a-simple-dma-loopback-memory-a-dma-memory-b-in-a-pynq-z-1-board-i-know-you-guys-would-redirect-me-to-xilinx-forum-but-i-just-wanted-your-opinion-anybody-has-any-leads-on-how-to-do-it-with-c-programming/6411/3 "2023-12-07T13:13:26Z")

</div>

Thank you soo much Josh. This will help me a lot.
