I bought a couple of PCI-CTR05 cards, to do hardware counting of an external clock signal for a project in my lab. I'm on a Linux machine running Ubuntu 10.10 (kernel version 2.6.35-30), so I couldn't use the driver software that shipped with the card. I followed a link on the manufacturer's page to some sources for a kernel module driver.
I followed the instructions (copied a rules file into /etc/udev/rules.d/ and did the udevadm --reload-rules), then make and make install - no errors.
Running lspci, I see the card:
greghale@jellyroll:~$ lspci | grep "CTR"
05:00.0 Unassigned class [ffff]: Measurement Computing PCI-CTR05 (rev 02)
On first run of modprobe I didn't see the module. But after running depmod, the module showed up
greghale@jellyroll:~$ modprobe -l | grep "ctr"
kernel/drivers/char/ctr05.ko
And by device shows up in /proc/modules, next to words that sound promising:
greghale@jellyroll:~$ cat /proc/modules | grep "ctr"
ctr05 453 0 - Live 0xf853c000 (P)
So things look good so far. But when I run the test program that comes with the driver, problems:
greghale@jellyroll:~/drivers/pci-ctr05$ ./test-ctr05
/dev/ctr05/dio0_0A: No such file or directory
error opening device /dev/ctr05/dio0_0A
And sure enough, there are no such /dev/ctr05 files in my /dev/ directory. Same situation after a restart.
Update - Clues?
Following sawdust's advice, I used mknod to create the char device nodes in /dev/. I tried this three ways; none of which worked.
1: A header file for the driver has a #define line that allows switching between dynamic and static major number allocation - the default is dynamic - I changed this to static number 5, , recompiled, used modprobe to load the newly compiled version, then mknod to build the files opened up by the test program. The test program happily opened those files for reading/writing on the PCI device, but none of the functionality worked. (test program was supposed to be able to set digital out pins, read digital in pins, and generate square waves - none of this worked at all as expected. After reading about major and minor numbers I found that my choice of '5' may be conflicting with some other devices. If I changed the major number of the device nodes (using mknod) to any other already-bound major number, I got the same behavior from the test program - running with no complaints but nonworking device.
2: I set the major number allocation option in the driver header file back to dynamic, recompiled, reinstalled. modprobe to load the module again. Then on the advice of the major/minor number page I had read, looked in /proc/devices to find the major number that the kernel had chosen for me. To my surprised there was no device there that seemed to correspond to my device. (I may be wrong about this? I copy off /proc/devices before and after doing rmmod and insmod; and see no changes).
3: The Makefile for the driver seemed to expect a major number of 242, so I went back to static allocation in the header file that allowed that option, choosing 242 this time. Recompile, reinstall. modprobe. Then I checked /proc/devices again, and again I see no representation for my device. But pushing ahead, use mknod to build my device nodes with the expected 242 major number. Now when I run the test program, very subtly different output from the first try:
greghale@jellyroll:~/drivers/pci-ctr05$ sudo ./test-ctr05
/dev/ctr05/dio0_0A: No such device or address
error opening device /dev/ctr05/dio0_0A
Does anyone have any guesses about what's going on? Any other tests I should do? Is there a branch of unix stuff I need to read but may not know by name yet? When I run lspci, I continue to get the same line as that above, regardless of whether the kernel module is loaded or not. Does the lspci line for the Measurement Computing card indicate that the major number is still 5, despite my attempts to install updated modules with dynamic major number allocation? I think I really expect /proc/devices to toggle a line for my device as I insert and remove the module - does the absence of this behavior means that there's something wrong with the install?