FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5892 Discussions

Altera PCI Express Development Kit: Linux DMA Driver

Altera_Forum
Honored Contributor II
6,856 Views

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 II
1,095 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/altpciechdma;h=ef7dd8fe0e082860742da72655892f12fb088114;hb=f3b8436ad9a8ad36b3c9fa1fe030c7f38e5d3d0b
0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

Thanks for the pointer

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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/altpciechdma;h=ef7dd8fe0e082860742da72655892f12fb088114;hb=f3b8436ad9a8ad36b3c9fa1fe030c7f38e5d3d0b 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.
0 Kudos
Altera_Forum
Honored Contributor II
1,095 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

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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
0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

I am able to load module and testing it now.

0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

It's probing now. Just ignore previous mail

0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.
0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
1,095 Views

TO_BE_DONE

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.

0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.
0 Kudos
Altera_Forum
Honored Contributor II
1,095 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.

0 Kudos
Altera_Forum
Honored Contributor II
958 Views

Just to update: My BAR configuration is as follows: 

 

static const unsigned long bar_min_len[APE_BAR_NUM] = 

{ 32768, 0, 256 };
0 Kudos
Reply