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++
12748 Discussions

Problem with DMA in new NIOS

Altera_Forum
Honored Contributor II
2,087 Views

Hello! 

 

I've made design for my custom board and I run it does work, 

but when I added to my design DMA it doesn't work.  

Then I remove dma from design it again does work. 

In old version of NIOS 2 (1.1) it does work with DMA. 

 

What is the problem? 

 

Thx.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
746 Views

Hello Camelot, 

 

Did you read the errata „errata.htm“? I had the same problem (http://www.niosforum.com/forum/index.php?act=st&f=17&t=1630) and found the solution there. 

 

 

DMA HAL routine results in illegal bus condition (SPR 176819) 

The Nios II DMA HAL routine results in illegal bus condition if: 

- the bursting DMA is connected to slaves wider than 32-bits or 

- the "word" checkbox on the Advanced tab in the GUI is unchecked or 

- the DMA master is connected only to slaves of data width less than or equal to 16 bits 

Workaround: Use a "freestanding" Nios II application to avoid using the HAL, and don't call the DMA init routine for the DMA in question.
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

A few days ago, when I tried Q5 and N5 to see what's new, I found one thing should be paid attention to, it's the DMA. 

In N5, the DMA has a new option: the burst ...... In my design, there were 4 DMA worked parallely, and it selected the "burst ....." option, and the length I filled was 512. Then the compilation pained me extremely, it took me more than 5 hours to finish the Analysis & Synthesis process, not to mention the Fitter process. (In Q4.2,N1.1, at most 30min needed for the full compilation).  

When I turn off the "burst..." option in the 4 DMAs, the compilation seemed to be normal, 40Min was needed, a slightly longer than the pervious release. 

 

I do not know what's wrong with my first trial, but you should use the "burst...." option carefully. Maybe there are too many DMAs in my design or the 512 is too many.
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

But if I have design with 16 bits SDRAM memory and 16 bits some device and 

I send by DMA data from memory to the device. In this case I should add to DMA  

something device with 32 bits data bus else? 

 

So, in my case I've added this 32bits device, program does work, but when I'm trying to 

send data from my 16 bits memory to my 16 bits device by dma, the dma doesn't work. 

 

My source code: 

 

***************** 

volatile unsigned short* dma_draw; 

int ScrWidth=800,ScrHeight=600; 

 

int ready=0; 

unsigned short* p1 =(unsigned short*) SDRAM_V1_BASE; //16 bits slave 

unsigned short* p2 =(unsigned short*) SDRAM_V2_BASE; //16 bits slave 

 

//Video DMA //16 bits slave 

void * pdma = (void*) VGA_DMA_BASE; 

void isr_dma(void* context, alt_u32 id); 

 

int main(void)  

unsigned int i,j; 

unsigned short* scr2; 

 

alt_irq_register(VGA_DMA_IRQ, pdma, isr_dma); 

 

scr2= p1; 

scr2+=ScrWidth*ScrHeight; 

for(i=ScrHeight+1;--i;) 

for(j=ScrWidth+1;--j;) 

*--scr2=i*j; 

 

scr2= p2; 

scr2+=ScrWidth*ScrHeight; 

for(i=ScrHeight+1;--i;) 

for(j=ScrWidth+1;--j;) 

*--scr2=i*j;  

 

dma_draw = p1; 

 

IOWR_ALTERA_AVALON_DMA_CONTROL(VGA_DMA_BASE,0); 

IOWR_ALTERA_AVALON_DMA_STATUS(VGA_DMA_BASE, 0); 

IOWR_ALTERA_AVALON_DMA_RADDRESS(VGA_DMA_BASE, (int)dma_draw); 

IOWR_ALTERA_AVALON_DMA_LENGTH(VGA_DMA_BASE, 800*600*2); 

IOWR_ALTERA_AVALON_DMA_WADDRESS(VGA_DMA_BASE, VGA_BASE); 

IOWR_ALTERA_AVALON_DMA_CONTROL(VGA_DMA_BASE,ALTERA_AVALON_DMA_CONTROL_GO_MSK | 

ALTERA_AVALON_DMA_CONTROL_I_EN_MSK| 

ALTERA_AVALON_DMA_CONTROL_HW_MSK| 

ALTERA_AVALON_DMA_CONTROL_WEEN_MSK| 

ALTERA_AVALON_DMA_CONTROL_WCON_MSK| 

ALTERA_AVALON_DMA_CONTROL_LEEN_MSK);  

 

 

******** 

 

Program continue works, data aren&#39;t transmiting http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif  

 

Why? 

Thx.
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

Camelot, since you never mentioned bursting, I&#39;ll assume your DMA is not burst-enabled. (From what you&#39;ve said about your system, you&#39;d get no advantage from enabling DMA bursts.) 

 

Your program runs, so you&#39;ve managed to avoid the problem mentioned in SPR 176819.  

 

Question: is your DMA write master connected to your VGA component (vga) in SOPC Builder?
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

RemyMartin, what advantage are you hoping to gain by enabling DMA bursting? 

 

Can you doublecheck your DMA parameters? If you have DMA enabled, but you&#39;ve set the DMA to use registers for its FIFO, you&#39;ll use a large amount of device resources (the burst-enabled DMA has a larger FIFO than the non-burst DMA). Try setting the DMA FIFO to use embedded memories.
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

Answer: Yes, DMA write master connected to VGA component. 

I disabled burst mode and it start work but works very strange. 

A few second dma is transmiting data, after 30 second doesn&#39;t transmit. 

And that always repeating.
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

Camelot, 

Right, enabling your DMA for bursting is not helpful in your system - in fact, it prevents it from working. Reason: the DMA sets its data width to the width of the maximum slave data width, in your case 32. Burst DMAs (and burst masters in general) can only do bursts at their data width. If you attempt to do a burst DMA transaction at narrow data width, nothing happens. 

 

I don&#39;t understand why your system behaves the way it does when you&#39;ve disabled bursting. I&#39;ve requested a zip file of your system in email.
0 Kudos
Reply