make KBUILD_BASENAME and KBUILD_MODNAME hacks more robust
[comedi.git] / INSTALL
1
2 * Linux source:
3
4 In order to compile the Comedi modules, you will need to have
5 a correctly configured Linux kernel source tree.  The best
6 way to get one is to download a tarball from kernel.org and
7 compile your own kernel.  Comedi should work with most 2.2 and
8 2.4 Linux kernels.  Support for 2.0.3x is not actively maintained,
9 but it should work and bugs will be fixed as they are reported.
10
11 You can also prepare a kernel source tree that matches
12 the kernel you are currently running if you have its config file (in
13 the Debian distibution the config files for the kernel-image packages
14 are installed into the /boot directory).  The following steps will
15 (almost) set up your kernel sources correctly.  You will also need
16 write permission to the kernel source directory the first time you
17 run comedi's configure script, so you might want to unpack the kernel
18 source into a directory you own.
19
20 1) Get a copy of the kernel source that matches the kernel you are
21         running.  Unpack it and copy your kernel config file to '.config'
22         in the top directory of your kernel source.
23 2) You might need to edit the file 'Makefile' in the kernel source.
24         At the top of the Makefile, the variable EXTRAVERSION is defined.
25         If necessary, change it to match your kernel (for example, if the command
26         'uname -r' produces "2.4.16-386" then your EXTRAVERSION should be
27         set as 'EXTRAVERSION=-386'.
28 3) Run 'make oldconfig' in your kernel source directory.
29 4) Run 'make dep' (or 'make prepare' for 2.6 kernels) in the kernel
30         source directory and you are done.
31
32 Red Hat users note: Kernel sources that are distributed with Red
33 Hat Linux are not supported, because they are too heavily
34 modified.  However, there is some information in
35 Documentation/comedi/redhat-notes on how to use Red Hat kernels.
36
37 * RTAI support:
38
39 If you want to use the real-time capabilities of Comedi with
40 RTAI, you need to compile and install RTAI first.  It is
41 necessary to use the rthal patch instead of the "copyto"
42 scripts.  Known working versions are RTAI-1.6, and RTAI-24.1.4.
43 * RTLinux support:
44
45 If you want to use the real-time capabilities of Comedi with
46 RTLinux, you need to compile RTLinux (both the kernel and the
47 modules) first.  Known working versions are 2.x and 3.0.
48
49 * Configuration:
50
51 Configure with './configure'.  './configure --help' will give the
52 configuration options.  If the configure script does not exist
53 (if you checked comedi out from cvs for example), it can
54 be generated by running './autogen.sh'.  The autoconf, automake,
55 autoheader, etc. tools are required to generate the configure
56 script (automake version >= 1.7 recommended).  The --with-linuxdir
57 option is particularly useful, as it allows you to specify
58 the location of your Linux kernel source directory.  If
59 you are using an RT-patched kernel, the --with-rtaidir or
60 --with-rtlinuxdir options allow you to specify
61 the location of your RTAI or RTLinux source directory.
62
63 * Compiling:
64
65 Compile using 'make'.  If this fails for some reason, send the
66 _entire_ build log to the mailing list.  Without the build
67 log, it is impossible to find problems.
68
69 * Installation:
70
71 Install using 'make install' as root.  This installs the files:
72
73   /lib/modules/<<kernel version>>/misc/comedi.o
74   /lib/modules/<<kernel version>>/misc/kcomedilib.o
75   /lib/modules/<<kernel version>>/misc/<<driver files>>.o
76
77 You need to create device files to access the hardware from a
78 user process.  These can be created using 'make dev'.  The following
79 special files will be created:
80
81   /dev/comedi0
82   /dev/comedi1
83   /dev/comedi2
84   /dev/comedi3
85
86 * Comedilib:
87
88 Now would be a good time to compile and install Comedilib.  Comedi
89 and Comedilib are completely independent, so it doesn't matter
90 which is installed first.
91
92 * Running Comedi:
93
94 To use comedi, the driver module and the core Comedi modules must
95 be loaded into the kernel.  This is done by a command similar to
96
97   /sbin/modprobe <<driver>>
98
99 If your module dependencies are set up correctly, this will load
100 both comedi.o and your driver.  If you get unresolved symbols, check
101 the FAQ or the mailing list archives.  Also look at the man pages
102 for modprobe and insmod.
103
104 In order to configure a driver module to use a particular device
105 file (/dev/comediN) and a particular device, you need to use the
106 command 'comedi_config', which is part of the comedilib
107 distribution.  Comedi_config is invoked using
108
109   comedi_config /dev/comedi0 <device name> <option list>
110
111 The device name may or may not be the same as the module name.  In
112 general, if the device type can be autoprobed (as with ISA PnP or
113 PCI devices), the device name will be the same as the module name.
114 Otherwise, you will need to check Documentation/comedi/drivers.txt
115 for information about what device name is appropriate for your
116 hardware.  The option list is to supply additional information,
117 such as I/O address, IRQ, DMA channels, and other jumper settings.
118 Information about option lists appropriate for a driver is in
119 drivers.txt.  The following commands are examples:
120
121   comedi_config /dev/comedi0 dt2821 0x240,3
122   comedi_config /dev/comedi1 ni_atmio 0x260,4
123   comedi_config /dev/comedi2 dt2817 0x228
124   comedi_config /dev/comedi3 ni_pcimio
125
126 Try a 'man comedi_config' for information on how to use
127 this utility.  Scripts have been written for a few of the drivers
128 with very complicated option lists -- these are found in the etc
129 directory.
130
131 * Module Autoloading:
132
133 If you like to autoload your modules, put the following lines
134 into /etc/modules.conf (this does not apply for PCMCIA cards):
135
136   alias char-major-98 comedi
137   alias char-major-98-0 your_driver
138   post-install your_driver PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH;comedi_config /dev/comedi0 board_name <<options>>
139
140 Alternatively, for complicated option lists, the scripts in etc
141 are designed to be copied into /etc, so that you could put the
142 following lines into /etc/conf.modules:
143
144   alias char-major-98-0 dt282x
145   post-install dt282x /etc/dt282x.conf
146
147 If you have a National Instruments AT-MIO or PCI-MIO board, you probably
148 will want to run comedi_calibrate, an autocalibration tool that is part
149 of comedilib in a bootup script.
150
151 * PCMCIA:
152
153 Linux-2.4 kernels are recommended for PCMCIA drivers, since 2.2
154 kernel require the separate PCMCIA package.  It is possible to
155 use 2.2 kernels with PCMCIA, although it is necessary to modify
156 the top level Makefile.
157
158 Comedi works with several PCMCIA cards, and the driver modules can
159 be loaded and unloaded upon insertion and removal of the card.
160 The necessary configuration files are in the Comedilib source
161 package.  Copy the files in etc/pcmcia/ to /etc/pcmcia and restart
162 card services.  The pcmcia script provided is very simple -- it only
163 uses /dev/comedi0 for devices, which is a limitation if you have
164 other Comedi devices in your system.
165
166 * Upgrading:
167
168 From versions prior to 0.6.0, you will need to edit and recompile
169 all programs that use comedi or comedilib, since the names of
170 functions and ioctls have changed.
171
172 From versions prior to 0.5.0, you will need to recompile all programs
173 that use comedi or comedilib, since the interface to both of these has
174 changed.  No changes should need to be made to the source of the
175 programs.  The format for parameters of comedi_config has changed.
176
177 From versions prior to 0.4.0, you will need to run 'make dev' again
178 to recreate /dev/comedi*, since the major number has changed.
179