Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

LWIP, LAN91C111, and DMA

Altera_Forum
Honored Contributor II
1,229 Views

I've searched the forums and cannot find anything that tells exactly how to modify the data transfer to use DMA. From what I can tell, this is correct (it is writing to the SMSC chip), but it plain doesn't work. 

 

The low_level_output function in altera_avalon_lan91c111.c has some special code so it can do 32-bit data transfers. I've modified this to use bytes for simplicity purposes and to make it simple to match the DMA mode. 

 

So, the modified non-DMA transfer using bytes is as follows (this works 100%): 

  for (i=0;i<q->len;i++) {       IOWR_ALTERA_AVALON_LAN91C111_DATA_BYTE( dev->base_addr,                                         *(alt_u8*)(q->payload+i));        } 

 

My DMA implementation of the same is: 

  IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_BASE, ALTERA_AVALON_DMA_CONTROL_BYTE_MSK +                                            ALTERA_AVALON_DMA_CONTROL_LEEN_MSK +                                            ALTERA_AVALON_DMA_CONTROL_WCON_MSK);   IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_BASE, (int)(q->payload));   IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_BASE, (int)IOADDR_ALTERA_AVALON_LAN91C111_DATA(dev->base_addr));   IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_BASE, q->len);   alt_dcache_flush_all();   // Flush the cache to ensure the DMA transaction gets the latest data   IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_BASE, ALTERA_AVALON_DMA_CONTROL_BYTE_MSK +                                            ALTERA_AVALON_DMA_CONTROL_LEEN_MSK +                                            ALTERA_AVALON_DMA_CONTROL_WCON_MSK +                                            ALTERA_AVALON_DMA_CONTROL_GO_MSK);   while (IORD_ALTERA_AVALON_DMA_STATUS(DMA_BASE) & ALTERA_AVALON_DMA_STATUS_BUSY_MSK);     

 

So, the DMA transaction does occur and complete, but the Ethernet functions fail.  

 

I&#39;ve checked that the DMA does transfer the number of bytes (well I&#39;ve checked short transactions, but haven&#39;t counted the 500 or so bytes that are normally sent). 

 

Any ideas? Thanks in advance... 

0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
499 Views

up!

0 Kudos
Reply