How to use the Xilinx VDMA core on the ZYNQ device
THIS POST GETS COMPLETED GRADUALLY ! I DON’T HAVE ALL OF THE INFORMATION RIGHT NOW !
In this post, I go through the procedure of adding a Video DMA to your ZYNQ PL in Vivado environment and then to program it.
Camera : First you need the camera to be connected to your ZED Board. For this, there is a very nice reference design that you can use: ZEDBOARD OV7670
The source design is also provided so you can make sure that your camera is working and the data is being received by the PL correctly. If you don’t have the camera, then a nice choice is to use the Xilinx Video Test Pattern Generator. This is what I do for now.
Vivado: Then you can create your Vivado project and add the instances for the ZYNQ PS, the VDMA engine and also the link for reading data from the Camera, or the Xilinx video test pattern generator. If you have the logic for receiving the data from the camera, then you need to update it and add an AXI Stream Master plug to it so that later it can be easily connected to the VDMA engine. If you are wondering how you can do that, watch my educational videos on ZYNQ.
Here is a simple block diagram , showing the Video DMA connected to the ZYNQ PS. In this block diagram we have the TPG, the VDMA and the PS. and also two AXI Interconnects. Again if you are wondering what do all of these things mean, refer to my educational zynq training videos.
In this block diagram, I have intentionally deleted all of the clock and reset nets so that only the main AXI connections remain and the block diagram can be understood better.
As we see, we have the GP0 port of the ZYNQ device connected to the Slave ports of both of the AXI_VDMA and also V_TPG modules. Indeed the GP0 port, goes to processing_system_7_0_axi_periph AXI Interconnect, and from there, the two outputs go first to the AXI_VDMA and then to the V_TPG unit.
Then as we see, we have the video_out port of the V_TPG (which is an AXI Stream Master) connected to the S_AXIS_S2MM port of the AXI_VDMA which is an AXI Stream Slave. On the other side, for the ZYNQ PS, we have enabled the HP0 port and we have the M_AXI_S2MM port of the AXI_VDMA connected to HP0 port of the ZYNQ through an AXI interconnect called axi_mem_intercon. If you lilke to know more about conversion from AXI stream to AXI memory mapped, you can refer to my educational videos on ZYNQ.
Software: Now we need to develop drivers and software running on the ZYNQ side to manage the TPG and VDMA units. First we need to allocate memory in the DRAM connected to PS for the incoming image frames. So you need a call to malloc routine. If you are running every thing in bare metal mode (no Linux is running there) then the MMU is not active and the output of malloc is a physical address. If you are running Linux then the returned address is virtual and you need to obtain the equivalent physical. For this, inside our Linuc Kernel level driver, we run dma_alloc_coherent which returns us both the virtual and physical address for the allocated memory.The virtual address, we will use inside the driver at the Linux side. The physical address we will pass it through the GP0 port to the AXI VDMA unit so that it knows to which location in the physical DRAM memory (connected to HP0) it should write the incoming image frames.
Now we program the VDMA with the obtained physical address for image buffers and rest of the necessary configurations.
If you are running bare metal, you just perform the set of required write/reads to the registers of VDMA and TPG. Here is the address map of the design shown in the block diagram above:
As we can see the base address for AXI_VDMA is 0x43000000 and for V_TPG is 0x43c00000. We use these two addresses to access the configuration registers of each these two units.
For complete description of each of the registers of these two units and their role, refer to AXI VDMA Product Guide, and AXI TPG Product Guide. (I am not sure if the links I put here are the latest version of this document. Search in Xilinx web site for that).
Now if we are running our software in bare metal then, we can just directly access the registers at specified address by the document. If we are running under linux, then we update our driver to first allocate memory regions for these two units inside the virtual address space and then we use the ioremap function to create the mapping between the physical address of the unit (shown above) and the virtual address.
Now we go to the details of how we configure the important registers for each of these two guys: VDMA and TPG.
(That is it for now, I will complete this post later).
It is really useful ,especially for me.I am just wondering if you have already finished this implementation. Cauz I am studying VDMA now and eager to know how to make it work.
Hi. Yeah with TPG, I tested it on the zed board, and works. but so far, it is all i have done.
I am trying to do this project as well. I am using the OV5642 but I am experiencing problems with the camera and getting the VDMA to work. I would like to work with you if possible.
Hello,
Have you continued to work on this example?
We want to create a block that generates video signals in an AXI Stream fashion and we need to understand how AXI VDMA works. To do that, we are using the Test Pattern Generator IP.
One question we have is how to tell the VDMA the memory address to write the data coming from the video generating block and draw and image in specific pixels of the screen.
If you can help us to get more information about this, we would really appreciate it.
Thank you very much.
Hi. Yes. I have continued working on that example and turning it into an almost complete design. your CPU can configure the vdma and provide it with the physical address to which the data transfer should happen.
Hi
Please share some knowledge of SDK / Linux for this post. I can able to understand the hardware but could not able to complete it properly.
Please complete this tutorial like you did in others zynq training .
Eagerly waiting to complete this post
Thanks
Hello Dr.Sadri,
I have been following your tutorials and they have been very informative and I thank you for the same.
Currently I’m working on setting up a VDMA for image processing pipeline. I want to control the VDMA from linux side. I have been looking for reference applications but was not able to find any. It would be great if you can share more info (if possible reference code) on setting up VDMA and reading and writing data from the memory. I would really appreciate if you can share this information.
Thank you !
Hi sir,Please i need some more help on this session ,i am facing problems to storing the video frames data to memories so that it can further processed by PS&PL ,Please help me out on this issue ,please share your training video on this topic or please inform us where we can get to know about this,Thanks.
sir, I am working this project only ,need help to write sdk bare metal code for this design.I tried to write application code but giving error .please help me ,if you have all ready done bare metal sdk for this design than please share with me.it is very helpful for me.
Hi,
I’m working on a project and I want to know how can I send an Image with SDK bare metal code throw Axi VDMA and read the result image back. Do you have any template C code that you can share with me for Axi VDMA transfer by SDK?
Thanks a lot
Thanks Mohammad for this explanation.
Can we design video output without using VDMA block? Output of TPG(master) is directly given to video stream to AXIS to video out block.
Yes. I don’t see any issue with that. should work. Just please note that then, if you are going to send this data to a screen (e.g. HDMI or DP or …) you should convert this video stream into signals with suitable format. For this purpose, you usually use the additional interface chip which is already available on your board.
Thank you for writing this post Dr. Sadri !
I am currently working on an image processing application, Could you please include an explanation about how to connect the ov7670 camera through an AXI interface
Looking forward to your reply !!
Hi All,
I am also working on AXI VDMA. I would like to change the source of incoming video frames.Do i need to change source address??How to change the source address from where VDMA received video frames.
Thanks & Regards,
Krishna
In AXI VDMA, you program the ip with the physical addresses of the buffer through which the vdma should circulate.
re-writing these address values will obviously change the physical source of the input frames in the next round of circulation.
does that solve your issue?
Dear Sir
I am beginner to this subject.
I am doing project which capture hdmi-video in frame and send to VGA
For I have taken demo project from Digilent. which build and work fine.
Now I want to add time stamp in display frame.
How can we implement this via PS
Will help in this regard
thanks and regard
raj
raj, write me.
sir, I am also working this project,need help to write vdma driver on linux of zcu102 for this design.I tried to vdmatest.c test driver but not obtain data .it is difficult to write the vdma driver with respect to the specific hardware,please help me.
Looking forward to your reply !
Hi Devin. write me an email.