Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
4,881 Views

Altera PCI Express Development Kit: Linux DMA Driver

Hi, 

 

I am a newbie to FPGA design and implementation. While installing the PCI express board on LINUX machine, I don't see Demo application driver for DMA read and write for LINUX (Manual talks about windows installation).  

 

I want to generate DMA read and write in Linux box. Does anyone have pointer to a sample application, driver or sof file for the same. 

 

Let me know if I am wrong in understanding. 

 

Thanks in advance. 

 

 

-Vineet
0 Kudos
64 Replies
Altera_Forum
Honored Contributor I
247 Views

Hello Vineet, 

 

Another forum member and I wrote a Linux Device Driver for the scatter gather design that is generated with the Altera PCI Express core wizard. 

 

It is now in the kernel tree, in the drivers/staging/ area: 

 

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree;f=drivers/staging/altpciechd...
Altera_Forum
Honored Contributor I
247 Views

Thanks for the pointer

Altera_Forum
Honored Contributor I
247 Views

 

--- Quote Start ---  

Hello Vineet, 

 

Another forum member and I wrote a Linux Device Driver for the scatter gather design that is generated with the Altera PCI Express core wizard. 

 

It is now in the kernel tree, in the drivers/staging/ area: 

 

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree;f=drivers/staging/altpciechd... 

--- Quote End ---  

 

Do you have a README or test application to test this driver ? Also, it would be good if you can exactly specify which kernel version it has been tested on. 

 

Thanks
Altera_Forum
Honored Contributor I
247 Views

According to the .c file, the kernel has been tested by the authors on 2.6.20 and 2.6.24. I've compiled it on 2.6.27 and 2.6.28, and now on 2.6.18 (Red Hat 5), but I had to comment out the cdev.h# include. The authors also state that the file is primarily for testing designs. Linux modules are kind of different from normal c programming and compiling, but good references are LDD3 <http://lwn.net/Kernel/LDD3/> and <http://dirac.org/linux/writing/lkmpg/2.6/lkmpg-2.6.0.html>. The Authors frequently refer to LDD3, but I found the 2nd site's compiling instructions to be more useful. 

 

So you compile the module using make, insert the module using insmod, and then if the driver and board work then you can view the results by issuing the dmesg command. The driver includes a test function that is ran automatically at insmod, when the driver "probes" the device. If it doesn't work, make sure the BAR array defined in the C file matches the BARs defined in your megafunction. In my case, I'm using an Arria GX Design Example that does not use BAR 4, which is non zero in the unmodified driver code. Easy fix though.
Altera_Forum
Honored Contributor I
247 Views

Thanks for the reply. I was able to insmod and rmmod the module. I was trying in latest kernel 2.6.29. I will check with 2.6.24. Thanks for pointers. I also refer to LDD3. Update you if I succeed in running the driver. Thanks again

Altera_Forum
Honored Contributor I
247 Views

I have tried to insmod into kernel 2.6.24.1 . It gives me "'altpciechdma.ko' : -1 Invalid module format". I assume 2.6.24 means it should work with sub branches of this kernel. 

 

Thanks for help
Altera_Forum
Honored Contributor I
247 Views

I am able to load module and testing it now.

Altera_Forum
Honored Contributor I
247 Views

Probably you just had to remake the module using the new kernel. Glad to hear you got it working.

Altera_Forum
Honored Contributor I
247 Views

Well, I am able to register my driver successfully but probe function is not invoked. Lspci gives me unkown altera device. Help.

Altera_Forum
Honored Contributor I
247 Views

It's probing now. Just ignore previous mail

Altera_Forum
Honored Contributor I
247 Views

Sorry, I haven't been monitoring the forums well.

Altera_Forum
Honored Contributor I
247 Views

Well, In probe function , I am getting "Could not request IRQ# 246, error -38" and its disabling the ACPI interrupts. Any help would be appreciated.

Altera_Forum
Honored Contributor I
247 Views

Check the bar_min_len array in the driver C file. Is each number <= to the actual BAR size of your core? I remember I had to set BAR 4 to 0 in the array, because the board example .pof doesn't define it.

Altera_Forum
Honored Contributor I
247 Views

 

--- Quote Start ---  

Check the bar_min_len array in the driver C file. Is each number <= to the actual BAR size of your core? I remember I had to set BAR 4 to 0 in the array, because the board example .pof doesn't define it. 

--- Quote End ---  

 

 

Thanks Robb. 

Acually, I should have updated that I Fixed it I have Bar[0]-Bar[2] in my setup. I am getting DMA loopback test failed though.
Altera_Forum
Honored Contributor I
247 Views

I don't know. Can you post your dmesg output?

Altera_Forum
Honored Contributor I
247 Views

TO_BE_DONE

Altera_Forum
Honored Contributor I
247 Views

Actually, it looks like the read is causing problems. EPLAST increments about 10-12 every iteration, but then freezes at 253. This is one less than 254, which is required to exit the loop that waits for the completion. The write look ok, since EPLAST = n = 254 at the last iteration. I don't know... maybe Likewise can help you better here, but I feel like it's firmware if you haven't modified the driver, other than the bar_min_len array. Are you still using 7.2? Try 9.0... the driver authors report problems depending on different Quartus compilation versions.

Altera_Forum
Honored Contributor I
247 Views

 

--- Quote Start ---  

Actually, it looks like the read is causing problems. EPLAST increments about 10-12 every iteration, but then freezes at 253. This is one less than 254, which is required to exit the loop that waits for the completion. The write look ok, since EPLAST = n = 254 at the last iteration. I don't know... maybe Likewise can help you better here, but I feel like it's firmware if you haven't modified the driver, other than the bar_min_len array. Are you still using 7.2? Try 9.0... the driver authors report problems depending on different Quartus compilation versions. 

--- Quote End ---  

 

 

Thanks Rob. I haven't modified much except some debugging statements ( which i have disabled when collecting above log). I am using Quartus II Version 8.0 and PCIE compiler version 8.0.  

I have tried windows driver. That works fine in windows.  

Likewise: Help please.
Altera_Forum
Honored Contributor I
247 Views

Well I have tried with Quartus II version 8.1. It gives the same error (or log). I used 8.1 as it is specified in driver file as tested. Kindly help me to debug the problem.

Altera_Forum
Honored Contributor I
110 Views

Just to update: My BAR configuration is as follows: 

 

static const unsigned long bar_min_len[APE_BAR_NUM] = 

{ 32768, 0, 256 };
Reply