cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hcuongvn
Observer
Observer
1,702 Views
Registered: ‎12-21-2011

Seftest failed with two DMA masters (xps_central_dma) on Microblaze and DDR2

I builded 2 xps_central_dma on my system (Microblaze and DDR2). MPMC was connected to both PLB and XCL. I used xps_central_dma selftest to transfer data from DDR2 to another location in DDR2. The first xps_central_dma succeed to transfer data from DDR2 to DDR2, but the second one was failed. It finished transferring data, but failed to verify source data and dest data.


My code:

   {
   	  XDmaCentral dma1;
        XStatus Status;
      
        XDmaCentral_CfgInitialize(&dma1, XDmaCentral_LookupConfig(XPAR_XPS_CENTRAL_DMA_1_DEVICE_ID), XPAR_XPS_CENTRAL_DMA_1_DEVICE_ID);

        print("\r\n Running DMA 1 Test  for XDmaCentral_SelfTest...\r\n");
      
        Status = XDmaCentral_SelfTest(&dma1);
	
        if (Status == 0) {
           print("DMA 1 Test PASSED\r\n");
        } 
        else {
           print("DMA 1 Test FAILED\r\n");
        }
	}
   {
   	  XDmaCentral dma0;
        XStatus Status;
      
        XDmaCentral_CfgInitialize(&dma0, XDmaCentral_LookupConfig(XPAR_XPS_CENTRAL_DMA_0_DEVICE_ID), XPAR_XPS_CENTRAL_DMA_0_DEVICE_ID);

        print("\r\n Running DMA 0 Test  for XDmaCentral_SelfTest...\r\n");
      
        Status = XDmaCentral_SelfTest(&dma0);
	
        if (Status == 0) {
           print("DMA 0 Test PASSED\r\n");
        } 
        else {
           print("DMA 0 Test FAILED\r\n");
        }
	}

 

 

 Central DMA selftest:

int XDmaCentral_SelfTest(XDmaCentral * InstancePtr)
{
	u32 Index;
	u32 RegValue;
	u8 *SrcPtr;
	u8 *DestPtr;

	/*
	 * Assert the argument
	 */
	XASSERT_NONVOID(InstancePtr != NULL);
	XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);

	/*
	 * Initialize the source buffer bytes with a pattern and the
	 * the destination buffer bytes to zero.
	 */
	SrcPtr = (u8 *) SrcBuffer;
	DestPtr = (u8 *) DestBuffer;

	for (Index = 0; Index < XDMC_SELFTEST_BUFSIZE; Index++) {
		SrcPtr[Index] = Index;
		DestPtr[Index] = 0;
	}

	/*
	 * Reset the device to get it back to its default state
	 */
	XDmaCentral_Reset(InstancePtr);

	/* Setup the DMA Control register to be:
	 *	- Source address incrementing
	 *	- Destination address incrementing
	 */
	XDmaCentral_SetControl(InstancePtr,
				XDMC_DMACR_SOURCE_INCR_MASK |
				XDMC_DMACR_DEST_INCR_MASK);

	/*
	 * Flush the Data Cache in the case the Data Cache is enabled.
	 */
	XCACHE_FLUSH_DCACHE_RANGE(&SrcBuffer,  XDMC_SELFTEST_BUFSIZE);
	XCACHE_FLUSH_DCACHE_RANGE(&DestBuffer, XDMC_SELFTEST_BUFSIZE);

	/*
	 * Start the DMA transfer.
	 */
	XDmaCentral_Transfer(InstancePtr, (void *) SrcBuffer,
			     (void *) DestBuffer, XDMC_SELFTEST_BUFSIZE);

	/*
	 * Wait until the DMA transfer is done
	 */
	do {
		/*
		 * Poll DMA status register
		 */
		RegValue = XDmaCentral_GetStatus(InstancePtr);
	}
	while ((RegValue & XDMC_DMASR_BUSY_MASK) == XDMC_DMASR_BUSY_MASK);


	/*
	 * If Bus error occurs, reset the device and return the error code.
	 */
	if (RegValue & XDMC_DMASR_BUS_ERROR_MASK) {
		XDmaCentral_Reset(InstancePtr);
		return XST_FAILURE;
	}

	/*
	 * DMA transfer is completely successful, check the destination buffer.
	 */
	for (Index = 0; Index < XDMC_SELFTEST_BUFSIZE; Index++) {
		if (DestPtr[Index] != SrcPtr[Index]) {
			/*
			 * Destination buffer's contents are different from the
			 * source buffer. Reset the device again and return
			 * error code.
			 */
			XDmaCentral_Reset(InstancePtr);
			return XST_FAILURE;
		}
	}

	/*
	 * Destination buffer's contents are the same as the source buffer
	 * Reset the device again and return success code.
	 */
	XDmaCentral_Reset(InstancePtr);

	return XST_SUCCESS;
}

 

Just help me!

0 Kudos
0 Replies