cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jspangar
Observer
Observer
14,317 Views
Registered: ‎12-26-2013

how to create pci device file in linux for KC705

Jump to solution

I have a KC705 board design with PCIe interface and want to know how to correctly create the device file in the linux /dev file system.

 

lspci shows the card is found:

 

01:00.0 RAM memory: Xilinx Corporation Device 202b
 Subsystem: Xilinx Corporation Device 202b
 Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
 Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
 Latency: 0, Cache Line Size: 64 bytes
 Interrupt: pin A routed to IRQ 11
 Region 0: Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
 Capabilities: <access denied>
 Kernel modules: windrvr6

 

 

The PCIe MET driver endpoint example uses this script to create the file which I modified to suit my dev name.

 

 

#!/bin/bash
rm -rf /dev/wavepci0
mknod /dev/wavepci0 c 240 1
chown root /dev/wavepci0
chmod 0644 /dev/wavepci0
ls -al /dev/wavepci0

 

But the last fields "240 1" are just the default major and minor device and I am not sure if these values suit my design.

 

Checking that I created the file correctly:

 

 

[justin@lab3 run]$ ls -l /dev/wavepci0
crwxrwxrwx 1 root root 240, 1 Dec  3 00:23 /dev/wavepci0
[justin@lab3 run]$

 

But my custom C program (which we have used on a previous project OK) to open the PCIe device file fails to open the file.

 

I can't quite figure out what the major and minor device values should be and if there is anything else required to make the device file know what it is supposed to be pointing to. Can anyone help?

0 Kudos
1 Solution

Accepted Solutions
jspangar
Observer
Observer
18,752 Views
Registered: ‎12-26-2013

Hi KR,

 

Thanks that is an excellent reference.

 

My problem is fixed. For the benefit of readers, there was in fact a custom driver program that I did not know about that we wrote previously. This driver program is not required to actually run the interface in my work, but does take care of dynamically setting up the /dev device for me whenever it needs to be accessed. It is installed using dkms. This means I (thankfully) don't have to do any manual setup of the device file as I had assumed. One little trick was that I have to chmod the device file to 777 after a reboot, but that is neither here nor there.

 

Thanks for the help. Please feel free to close this discussion.

JS.

 

View solution in original post

0 Kudos
10 Replies
umamahe
Xilinx Employee
Xilinx Employee
14,304 Views
Registered: ‎08-01-2012

Please refer PCI related documents in the below KC705 board link. They may help to get some clues. 

http://www.xilinx.com/products/boards-and-kits/ek-k7-kc705-g.html#documentation  

________________________________________________

Please mark this post as an "Accept as solution" in case if it helped to resolve your query. So that it will help to other forum users to directly refer to the answer.

Give kudos to this post in case if you think the information is useful and reply oriented.

0 Kudos
jspangar
Observer
Observer
14,286 Views
Registered: ‎12-26-2013

Hi,

 

Thanks. There seems to be nothing specific in there.

 

What I would like to know is given that I know my vendor ID and Device ID (these are set in the verilog) how do these numbers translate into major and minor device IDs for mknod?

 

I can see the device with lspci:

 

[justin@lab3 debug_pci_cluster]$ lspci -xxxx -d 0x10EE:0x202b
01:00.0 RAM memory: Xilinx Corporation Device 202b
00: ee 10 2b 20 07 00 10 00 00 00 00 05 10 00 00 00
10: 00 00 00 f6 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 ee 10 2b 20
30: 00 00 00 00 40 00 00 00 00 00 00 00 0b 01 00 00

 

 

The vendor ID is 0x10EE and the device ID is 0x202b

 

I tried setting this

mknod /dev/wavepci0 c 0x10ee 0x202b

 

but it does not like the vendor ID:

 

[root@lab3 hostpc]# mknod /dev/wavepci0 c 0x10ee 0x202b
mknod: `/dev/wavepci0': Invalid argument

 

(works when I use 240 instead of 0x10ee but that is not what I wanted)

 

Thanks, Justin

0 Kudos
markcurry
Scholar
Scholar
14,274 Views
Registered: ‎09-16-2009

 

Who's writing your kernel driver?  From your lspci, there's a driver attached called "windrvr6".  All the details that you need are in there.

 

If you look at /proc/devices you should see the "windrvr6" driver.  The major/minor device ID's info will be there.

 

--Mark

 

(Note: this is from a HW guy who knows JUST enough about linux drivers to get himself in trouble.  So take with a grain of salt).

0 Kudos
jspangar
Observer
Observer
14,267 Views
Registered: ‎12-26-2013

Hi Mark,

 

Thanks, yes I was just looking at /proc/devices. This is the entry for the KC705 card. I know that the Vendor and Device IDs are as per the RTL, so this will be it for sure.

 

0100 10ee202b b         f6000000                0                0                0                0                0                0          1000000                0                0                0                0                0                0 

 

Do you happen to know which fields are the major/minor device IDs? 0x100, 0x0 would be my best guess. Or maybe 0x100 0xb? Or 0x01 0x00 (from 0100)?

 

It looks like windrv6 in an Impact driver. I don't know why it is being associated with the PCI interface - perhaps it just picks up the Vendor ID and loads. See:

 

http://fcns.eu/2012/05/11/module-windrvr6-is-not-loaded-please-reinstall-the-cable-drivers-see-answer-record-22648-digilent-atlys-on-centos-64-bit-xilinx-ise-13-2/

 

I am writing a C function to simply open the file /dev/wavepci0 and then have other C functions to read and write. These functions are called from a Verilog simulation via the DPI interface so effectively the driver is a verilog simulation.

 

0 Kudos
markcurry
Scholar
Scholar
14,261 Views
Registered: ‎09-16-2009

Justin,

 

That /proc/devices looks NOTHING like mine:

 

% cat /proc/devices 
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  5 ttyprintk
  6 lp
  7 vcs
 10 misc
 13 input
 21 sg
 29 fb
 99 ppdev
108 ppp
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
195 nvidia-frontend
216 rfcomm
226 drm
247 pcan
248 pcie-isi
...

That "pcie-isi" is my kc705 board.  So its major number is 248

 

I'm really confused why the Xilinx Impact driver is being associated with your PCIE device.  Something's really weird there.

 

Inside my device driver - which we wrote, is all the stuff that associates the probed PCIE vendor ID, etc, with the name of the driver (that we define), which in term shows up as the entry in /proc/devices - and eventually the file in /dev/.

 

Is your kernel module from some Xilinx demo?  What are you actually insmod'ing?

 

Sorry, can't offer much more.

 

That Verilog DPI to real device driver connect sounds like a neat project.  Hadn't thought of doing something like that.  Interesting...

 

Regards,

 

Mark

 

0 Kudos
jspangar
Observer
Observer
14,253 Views
Registered: ‎12-26-2013

Oops, that line was actually out of  /proc/bus/pci/devices which I had open in an emacs buffer. THIS is my /proc/devices :

 

Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  7 vcs
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 99 ppdev
116 alsa
128 ptm
136 pts
162 raw
180 usb
189 usb_device
202 cpu/msr
203 cpu/cpuid
226 drm
246 xpc4drvr
247 macvtap
248 windrvr6
249 hidraw
250 usbmon
251 bsg
252 pcmcia
253 watchdog
254 rtc

 

Block devices:
  1 ramdisk
259 blkext
  7 loop
  8 sd
  9 md
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp

 

So this line:

248 windrvr6

seems to indicate that (I presume) major ID 248 (which is F8 hex) is associated with windrvr6? What would the minor ID be?

 

But then the only entry that has f8 in it in /proc/bus/pci/devices is this entry which is for an intel device:

 

00f8 80861c5c 0                0                0                0                0                0                0                0                0                0                0                0                0                0                0 

 

So the first entry in the line of this file can't be the major ID. Which only confuses me more.

 

Then there is also the xpc4drvr - ISE impact driver listed in /proc/devices. I don't have any impact interfaces connected to this machine (other than via the PCI). What's with that?

 

I don't need Vivado on this machine so I might just uinstall all that junk and see what happens. Do I have to uninstall the drivers explicitly?

 

You might be doing some kind of dynamic device creation, which is why all the IDs are embedded in your driver file. In my case, I want to manually set up a dev file with mknod and then use my C function to point to that file.

 

There is no kernel module per se. I am not really insmod'ing  (inserting module) anything. I guess the simulator kernel is the thing that talks to the OS and the driver functionality executes within the simulator, if that makes sense.

 

I had all of this working in the past (so I know it will work the way I want it to), but unfortunately just lost track of how to configure the machine.

 

I am a little surprised that this is not more straightforward or better spelled out. I assumed that people out there who develop their own PCIe stuff with custom drivers would want to configure linux devices all the time. Or am I just looking in the wrong places?

 

 

0 Kudos
kotir
Scholar
Scholar
14,241 Views
Registered: ‎02-03-2010

Hi

 

I think you need to look at /dev to know those numbers.

 

Check th elink below

http://stackoverflow.com/questions/1823743/knowing-a-device-special-file-major-and-minor-numbers-in-linux

 

I hope this helps.

 

Regards,

KR

--------------------------------------------------​--------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful.
--------------------------------------------------​-------------------------------------------
0 Kudos
jspangar
Observer
Observer
14,237 Views
Registered: ‎12-26-2013

Thanks,

Yeah that tells me the major/minor numbers that were used by someone or something to CREATE the file after the fact, but what I really want to know is what numbers should I use to create the dev file in the first place to reach my hardware.

Justin

0 Kudos
kotir
Scholar
Scholar
14,233 Views
Registered: ‎02-03-2010

hi,

 

Have a looka t the below link.

 

http://www.makelinux.net/ldd3/chp-3-sect-2

 

Regards,

KR

--------------------------------------------------​--------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful.
--------------------------------------------------​-------------------------------------------
0 Kudos
jspangar
Observer
Observer
18,753 Views
Registered: ‎12-26-2013

Hi KR,

 

Thanks that is an excellent reference.

 

My problem is fixed. For the benefit of readers, there was in fact a custom driver program that I did not know about that we wrote previously. This driver program is not required to actually run the interface in my work, but does take care of dynamically setting up the /dev device for me whenever it needs to be accessed. It is installed using dkms. This means I (thankfully) don't have to do any manual setup of the device file as I had assumed. One little trick was that I have to chmod the device file to 777 after a reboot, but that is neither here nor there.

 

Thanks for the help. Please feel free to close this discussion.

JS.

 

View solution in original post

0 Kudos