Jump to content
  • 0

[Neso Artix 7] How to transmit more than 1 BD in DMA Scatter Gather mode


Bui Cuong

Question

I am learning to use DMA in Scatter Gather mode. So i use example code ("xaxidma_example_sg_poll.c"). Using "xil_printf" function to see value, I am done with this but it only transmit 1 BD, and i want more. I edit "SendData" function like this to transmit 2 BDs.

// i edit this code to transmit more than 1 BD 
static int SendPacket(XAxiDma * AxiDmaInstPtr)
{
	XAxiDma_BdRing *TxRingPtr;
	u8 *TxPacket;
	u8 Value;
	XAxiDma_Bd *BdPtr;
	int Status;
	int Index;

	TxRingPtr = XAxiDma_GetTxRing(AxiDmaInstPtr);

	/* Create pattern in the packet to transmit */
	TxPacket = (u8 *) Packet;

	Value = TEST_START_VALUE;

	for(Index = 0; Index < 2*MAX_PKT_LEN; Index ++) {
		TxPacket[Index] = Value;
		xil_printf ("TX addr: %x  and value: %x\n\r", (unsigned int)(TxPacket+Index),(unsigned int)*(TxPacket+Index));
		Value = (Value + 1) & 0xFF;
	}

	/* Allocate 2 BD */
	Status = XAxiDma_BdRingAlloc(TxRingPtr, 2, &BdPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	for (Index = 0; Index < 2;Index ++){
	/* Set up the BD using the information of the packet to transmit */
	Status = XAxiDma_BdSetBufAddr(BdPtr, (UINTPTR) Packet);
	if (Status != XST_SUCCESS) {
		xil_printf("Tx set buffer addr %x on BD %x failed %d\r\n",
		    (UINTPTR)Packet, (UINTPTR)BdPtr, Status);

		return XST_FAILURE;
	}

	Status = XAxiDma_BdSetLength(BdPtr, MAX_PKT_LEN,
				TxRingPtr->MaxTransferLen);
	if (Status != XST_SUCCESS) {
		xil_printf("Tx set length %d on BD %x failed %d\r\n",
		    MAX_PKT_LEN, (UINTPTR)BdPtr, Status);

		return XST_FAILURE;
	}
	xil_printf ("TX BD addr: %x  and value: %x\n\r", BdPtr,TxPacket);

	/* For single packet, both SOF and EOF are to be set
	 */
	XAxiDma_BdSetCtrl(BdPtr, XAXIDMA_BD_CTRL_TXEOF_MASK |
						XAXIDMA_BD_CTRL_TXSOF_MASK);

	XAxiDma_BdSetId(BdPtr, (UINTPTR)Packet);

	TxPacket += MAX_PKT_LEN;
	BdPtr = (XAxiDma_Bd *)XAxiDma_BdRingNext(TxRingPtr, BdPtr);
	}
	/* Give the BD to DMA to kick off the transmission. */
	Status = XAxiDma_BdRingToHw(TxRingPtr, 2, BdPtr);
	if (Status != XST_SUCCESS) {
		xil_printf("to hw failed %d\r\n", Status);
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}

And error appear from "XAxiDma_BdRingToHw()" function
image.png.673d0f337483947e58c3d7bb5ed0df22.png

Any suggestion for me ? Thank 

P.S: xaxidma_example_sg_poll.c : full code file

       I will post my project file soon. 

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

Thank @jpeyron, this is my Linker Script. 

image.png.73249183f0b6369104f667abcea523a7.png
but i think my problem in my code like in this post https://forums.xilinx.com/t5/7-Series-FPGAs/Artix-7-How-to-config-DMA-to-transmit-more-than-one-BD-in/td-p/903680

It means how to config in TX channel to transmit more than one packet: XAxiDma_BdSetCtrl().
This is my project: https://drive.google.com/open?id=16PBdsWDXbVUHlbFP7fXQ--xB0nVR_B33

 

Link to comment
Share on other sites

Hi @Bui Cuong,

I have not altered the DMA code to allow more packets to be transferred. Looking at the xaxidma_example_sg_poll.c code from your project below:

#define TX_BD_SPACE_BASE    (MEM_BASE_ADDR)
#define TX_BD_SPACE_HIGH    (MEM_BASE_ADDR + 0x00000FFF)
#define RX_BD_SPACE_BASE    (MEM_BASE_ADDR + 0x00001000)
#define RX_BD_SPACE_HIGH    (MEM_BASE_ADDR + 0x00001FFF)
#define TX_BUFFER_BASE        (MEM_BASE_ADDR + 0x00100000)
#define RX_BUFFER_BASE        (MEM_BASE_ADDR + 0x00300000)
#define RX_BUFFER_HIGH        (MEM_BASE_ADDR + 0x004FFFFF)


#define MAX_PKT_LEN        0x08

 

I believe you will need to expand the memory allocated for each of the above #defines.

cheers,

Jon

Link to comment
Share on other sites

Hi @Bui Cuong,

We at digilent have a limited knowledge of the AXI DMA IP Core compared to the creators Xilinx. You might be better off reaching out to xilinx for this issue.  With that being said when researching the  hw failed 526 i see memory issues like in the comments of the Using the AXI DMA in Vivado article where the person solved their hw failed 526 issue by setting the right DDR_BASE_ADDR.

cheers,

Jon

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...