cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
centos_79
Visitor
Visitor
490 Views
Registered: ‎07-29-2020

XAxiDma_SimpleTransfer transfering images

I'm trying to creating an image processing pipieline that takes images from ethernet and send it to dma in order to create an image processing ip block over the axiStream of vdma.
Now i've just connected the MM2S with the S2MM of the dma in order to have an "echo" of the photograms without any kind of processing.
Starting from simple_poll dma example (which works) i managed to pass the photograms that i want to analyze but the situation is that just some portions of the received image are updated.
I attached a picture of the readed picture from the DMA after a sending of complete BLACK picture: you can see that some portion of the buffer have been correctly written by the DMA but other parts hadn't been written and the color that you are seeing is likely a mix of the previous sent photograms.
Analyzing the image it seems that correctly written and uncorrectly written blocks are grouped in stripes of 32 pixels ... I think this is not a coincidence.

I'm working with resolution of 512*512

The code i'm trying to get it working is this:

void process_photogram(u8 imageToProcess[]){
    u8 *TxBufferPtr;
    u8 *RxBufferPtr;
    int Status;

    TxBufferPtr = (u8 *)TX_BUFFER_BASE;  //is 0x02000000
    RxBufferPtr = (u8 *)RX_BUFFER_BASE; //is 0x04000000

 

    //imageSize is 512*512

    memcpy(TxBufferPtr, imageToProcess, imageSize);

    Status = XAxiDma_SimpleTransfer(&myDma,(UINTPTR) RxBufferPtr,
    imageSize, XAXIDMA_DEVICE_TO_DMA);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    Status = XAxiDma_SimpleTransfer(&myDma,(UINTPTR) TxBufferPtr,
    imageSize, XAXIDMA_DMA_TO_DEVICE);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }


    while ((XAxiDma_Busy(&myDma,XAXIDMA_DEVICE_TO_DMA)) ||
    (XAxiDma_Busy(&myDma,XAXIDMA_DMA_TO_DEVICE))) {
        //Wait
    }
    memcpy(processedImage, RxBufferPtr, imageSize);

/*HERE THE processedImage DOESN'T CONTAINS THE ImageToProcess BUT CORRECT PARTS OF THE imageToProcess GROUPED IN STRIPES OF 32PIXELS (bytes)*/

    print("finished, now processedImage should contain imageToProcess after the DMA write and read");

}

Tags (1)
example.png
0 Kudos
3 Replies
florentw
Moderator
Moderator
391 Views
Registered: ‎11-09-2015

Hi @centos_79 

My first guess is that it might be a cache issue. Make sure you are writing/reading directly to the memory and not in the cache memory. You might want to disable the cache memory.

Then, this is not the issue but why using the AXI DMA and not the AXI VDMA?

Or are you using the AXI VDMA with the AXI DMA driver. This might be an issue


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
centos_79
Visitor
Visitor
274 Views
Registered: ‎07-29-2020

you were right, resolved with:

Xil_DCacheFlushRange((UINTPTR)RxBufferPtr, imageSize);

No particular reason for using DMA instead of VDMA...i should use VDMA? why?

0 Kudos
florentw
Moderator
Moderator
267 Views
Registered: ‎11-09-2015

Hi @centos_79 

I am just asking because the AXI VDMA is adapted for Video. But this would be more if you are connecting it with other XIlinx Video IPs (video processing subsystem, Video Mixer...) as this is taking care of some video specific signals as Start of frame or end of line


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**