Installing the Comedi Module for the Linux Kernel


Comedi is a set of Linux device drivers for data acquisition hardware. Comedi has device drivers for around 200 cards from different manufacturers. Comedi is broken into two parts.

In Linux, only the kernel can directly act upon a piece of hardware. Therefor we need to add the Comedi module to the kernel. There are a few different steps.

  1. Add some info so monitoring programs recoginze your card.
  2. Making sure that the Linux Kernal source is right. Since the Comedi module will be complied against the kernal source it is important that the source is complete. When Linux is installed pre-complied (as is normal) the source may not be complete.
  3. Compile the Comedi Module. We are using version comedi-0.7.66
  4. Install comedilib
  5. Starting up the Comedi Module.
In the next page we will discuss the API (Application Programming Interface): version comedilib-0.7.19
Finding out about what is on you PCI bus

A conveient utility for seeing what is on you pci bus is /sbin/lspci[man lspci]. If I have just put in a new card there is a good chance it will not be recognived (see "Unknown device 2a70" below):
[he3]$ /sbin/lspci 
00:00.0 Host bridge: Intel Corp. 440FX - 82441FX PMC [Natoma] (rev 02)
00:07.0 ISA bridge: Intel Corp. 82371SB PIIX3 ISA [Natoma/Triton II] (rev 01)
00:07.1 IDE interface: Intel Corp. 82371SB PIIX3 IDE [Natoma/Triton II]
00:0b.0 VGA compatible controller: Matrox Graphics, Inc. MGA 2064W [Millennium] (rev 01)
00:0f.0 Class ff00: National Instruments: Unknown device 2a70
00:11.0 Ethernet controller: 3Com Corporation 3c900 Combo [Boomerang]

I need to update the file /usr/share/hwdata/pci.ids [download].
Now:
[he3]$ /sbin/lspci
00:00.0 Host bridge: Intel Corp. 440FX - 82441FX PMC [Natoma] (rev 02)
00:07.0 ISA bridge: Intel Corp. 82371SB PIIX3 ISA [Natoma/Triton II] (rev 01)
00:07.1 IDE interface: Intel Corp. 82371SB PIIX3 IDE [Natoma/Triton II]
00:0b.0 VGA compatible controller: Matrox Graphics, Inc. MGA 2064W [Millennium] (rev 01)
00:0f.0 Class ff00: National Instruments PCI-6024E
00:11.0 Ethernet controller: 3Com Corporation 3c900 Combo [Boomerang]

This just means that it knows the name of the card - but still nothing about using it.


Making sure that the Linux Kernel source is right

Since the Comedi module will be complied against the kernal source it is important that the source is complete. When Linux is installed pre-complied (as is normal) the source may not be complete.

So at this stage you will go through the early stages of compiling the kernel - without actually compiling and installing a new kernel (yes - you could do that if you wanted to - but you do not need to).

You need to go through the configure and make dependences steps.

The following instructions are for location /usr/src/linux-2.4.18-27.7.x (or what ever version of Linux you have). If you perform these in that area you need to be root. You can do this in user-space and not as root, but you will need to be root later anyhow to install comedi.


Compile the Comedi Module

Next we compile the comedi module. By defalt it will drive four cards. We includ the instructions to add more cards.


Installing Comedi Lib

You will want to install comedilib at this point. Most of comedilib is needed for AIPs (future pages). But it also contains the startup program.


Starting up the Comedi Module - and Monitoring it

As root:

and that is it.

Some notes about comedi_config [man comedi_config]

Two useful options

Some general Linux module monitoring tools

You can see all the modules runing with the tool:

/sbin/modprobe [man modprobe]

in short - to just see comedi, try:


/sbin/modprobe  -c | grep comedi
alias char-major-98 comedi
post-install cimio /usr/sbin/comedi_config /dev/comedi0 ni_pcimio 0,15
post-install ni_pcimio /scratch/comedilib/comedi_calibrate/comedi_calibrate -f /dev/comedi0

You can also remove a loaded module with:

/sbin/rmmod [man rmmod]