root/i2c/trunk/INSTALL @ 3723

Revision 3723, 10.1 KB (checked in by khali, 11 years ago)

Take kernel source location from /lib/modules/x.x.x/build

Installation documentation updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1These are the installation instructions for the i2c package.
2
3There are three ways in which you can compile and install this package. Each
4has its own strong points. They are:
5
6 1. Complete separate from kernel compilation
7    This will generate a set of modules which can be inserted and removed
8    as needed; nothing will be written into the kernel tree;
9
10 2. Semi-integrated into the kernel
11    This will add some files to your kernel tree, but has the advantage
12    that module symbols are supported; the end result is functionally very
13    like the previous way;
14
15 3. Patching of the kernel
16    This will patch your kernel source tree. You must recompile your kernel
17    to take advantage of this. But it makes it possible to compile drivers
18    into the kernel itself, instead of having to add them as modules.
19
20Each of these ways will be described below in detail.
21We recommend using either method 1 or 3;
22method 2 is less well maintained.
23
24NOTE: SUPPORT FOR 2.0 AND 2.1 KERNELS HAS BEEN DROPPED!
25NOTE: METHOD 3 ONLY WORKS FOR 2.2 KERNELS AND 2.4 KERNELS (2.4.0 OR LATER)
26
27
28Having a proper kernel tree (compilation options 1 and 2)
29=========================================================
30
31Usually, if you compile a user-space application, you can get away with
32having a different version of the kernel running than the version of the
33kernel header files against which you compiled it. But a perfect match
34is needed for the first two compilation options above.
35
36Let's say you want to use the i2c modules with the kernel 2.1.12 you
37are running now. What you need, is the original tree in which you
38compiled that 2.1.12 kernel. A freshly unpacked 2.1.12 kernel will not
39cut it, because `make *config dep' creates some files that are needed.
40And even then, you will run into trouble, because you may not have
41selected the exact same configuration variables. Plain advise: if you
42do not have your original kernel tree anymore, recompile your kernel
43first.
44
45Your I2C support must NOT be built-in your kernel already!
46It must either be disabled or enabled as modules.
47Look in Character Devices -> I2C Support in the kernel
48configuration system to verify.
49
50Note that there is no need for a perfect match at compilation time, just
51at run-time. This means you can cross-compile against a different kernel
52version, and the Makefile does not check for this.
53
54Usually problems if the match is imperfect, is that either this package
55won't compile at all (because it was a freshly unpacked tree without
56some files generated by `make *config dep'), or that you can't insert
57modules because of either a `kernel-module version mismatch' or because
58of `unresolved kernel symbols'. If you get either of these messages,
59check your kernel tree!
60
61Note that some distributions are notably bad at this. To offset this
62somewhat, not the files in /usr/include/{linux,asm} are used, but instead
63those in /usr/src/linux/include/{linux,asm}. It is also possible to
64tell the Makefile the kernel is somewhere else than at /usr/src/linux.
65
66To keep problems to a minimum, please use a 'vanilla' kernel tree,
67as distributed on ftp://ftp.kernel/org/pub/linux/kernel, and not one
68patched by your distribution.
69
70
71Separate from kernel compilation (compilation option 1)
72=======================================================
73
74This will compile and install the complete i2c package. Though nothing is
75written to your kernel tree, a proper tree is still needed for this. See
76earlier for what a proper kernel tree is.
77
78At the top of the Makefile are a couple of configuration variables that
79you may want to change. As far as possible, the Makefile tries to figure
80out by itself their settings, but it is possible to overrule them. A list
81is found below. Most important are the variables that determine where
82your kernel is located (LINUX=/lib/modules/KERNELVERSION/build, usually
83links to /usr/src/linux or something similar) and where you want to
84install your modules (MODDIR=/lib/modules/KERNELVERSION) and header files
85(LINUX_INCLUDE_DIR=/usr/local/include/linux). You can see that the
86installation locations are choosen in such a way that they are separate
87from the true kernel.
88
89Compilation is done by `make all'; `make install' installs the package.
90You will get a lot of warnings about files which are not found, all
91ending on `.d'. You can safely ignore this; they contain dependency
92information, which is regenerated on the spot.
93
94Please continue reading this file before you start compiling.
95
96
97Semi-integrated into the kernel compilation (compilation option 2)
98==================================================================
99
100Please reconsider first whether you truly want to use this compilation
101option. Often, it is better to use the previous compilation technique.
102
103This will compile and install the complete i2c package, by using the
104kernel build system. Some file will be written to your kernel tree
105for this.
106
107At the top of the Makefile are a couple of configuration variables that
108you may want to change. Not all of those variables are used if you
109use this compilation option, though. A list of them is found below.
110
111Compilation is done by `make all'; `make install' installs the package.
112
113Please continue reading this file before you start compiling.
114
115
116Makefile configuration variables (compilation options 1 and 2)
117==============================================================
118
119BUILD_SYSTEM (both) (default: lm_sensors)
120  The build system which is used. lm_sensors corresponds with compilation
121  option 1; i2c with compilatin option 2.
122SHELL (both) (default: /bin/sh)
123  You may have to specify the full path to Bash here, if /bin/sh is some
124  other shell. There have been conflicting reports on whether this is
125  needed.
126KERNELVERSION (both)
127  The version of the currently running kernel.
128LINUX (both) (default: /lib/modules/$(KERNELVERSION)/build)
129  The location of your kernel tree.
130COMPILE_KERNEL (both) (default: 1)
131  Determine whether you want to consider the kernel modules for compilation
132  at all. By default, compilation option 1 will only compile and install
133  those modules which are not built into the kernel; compilation option 2
134  will compile and install all of them. 
135  If some modules are built into your kernel, and this package is much
136  newer, you may find you can not insert the newly compiled modules.
137  Sorry.
138  You may want to set this to 0 if you have just patched and compiled
139  your kernel using the same version of this package, and just want to
140  compile the user-space tools.
141SMP (compilation option 1 only)
142  This must be set to 1 for a SMP kernel. The magic invocation should
143  determine this automatically, so you should not have to bother with
144  this.
145MODVER (compilation option 1 only)
146  This must be set to 1 if CONFIG_MODVERSIONS is defined. The magic
147  invocation should determine this automatically, so you should not
148  have to bother with this.
149MODDIR (both) (default: /lib/modules/$(KERNELVERSION))
150  The location where the kernel modules will be installed.
151LINUX_INCLUDE_DIR (compilation option 1 only) (default: /usr/local/include/linux)
152  The location where the i2c header files will be installed.
153WARN (compilation option 1 only) (default: 0)
154  Generate additional compilation warnings; mainly interesting for
155  developers.
156
157
158Handling the modules (compilation option 2)
159===========================================
160
161Run `depmod -a' to have new modules them recognised. Most
162distributions run this command when you boot, so if you were cross-
163compiling, you can skip this step.
164
165
166Patching the kernel (compilation option 3)
167==========================================
168
169There is a special script which should be able to generate diffs against
170any 2.2 and 2.4 kernel (2.4.0 and later). Note that 2.3 kernels are no
171longer supported.
172Please report any problems to our mailinglist. Note that it may fail,
173and probably silently, if you have applied other patches to your kernel
174tree, or for very new kernels.  It *is* safe to run it if your kernel
175already has the i2c drivers, or if it was patched with the lm_sensors drivers.
176
177The kernel diffs are generated by the program `mkpatch.pl' in the mkpatch
178subdirectory. It needs two arguments: the first one is the root of the
179i2c package, the second one is the root of the kernel tree against
180which the diffs will be generated. For example:
181  cd /tmp/i2c-2.0.3
182  mkpatch/mkpatch.pl . /usr/src/linux > /tmp/i2c-patch
183You can apply the diffs as usual:
184  cd /usr/src/linux
185  patch -p1 -E < /tmp/i2c-patch
186Genearation and application can easily be done in one step:
187  mkpatch/mkpatch.pl . /usr/src/linux | patch -p1 -E -d /usr/src/linux
188The generated diffs are of course only valid for the kernel version
189against which mkpatch.pl was run.
190
191Once you have applied the patches, you can configure and compile your
192kernel as usual. You will see the I2C configuration screen under the
193`Character Devices' menu in menuconfig.
194
195
196Using the I2C package
197=====================
198
199You can now load the modules by using `modprobe'. For example,
200`modprobe i2c-elv' will load the i2c-elv modules, and all i2c modules
201on which it depends.
202
203You can not use demand-loading; you will have to issue explicit modprobe
204instructions. The one exception is the `i2c-dev' module. You can
205automatically load it by adding the following line to etc/conf.modules or
206/etc/modules.conf (use the one that exists):
207    alias char-major-89 i2c-dev
208
209Note that there are no client drivers in this package; you will have to
210get them from somewhere else (for example, download the lm_sensors
211package at http://www.lm-sensors.nu). Without additional drivers and
212programs, this package is of very limited use to you.
213
214
215Old and new I2C drivers
216=======================
217
218In the current 2.2 and older 2.3 kernels, there are already I2C drivers, but
219they are not the same ones as in this package. They are much older, and
220have a very limited functionality compared with the drivers included
221here. Fortunately, they can co-exist peacefully, so you should not worry
222about it. Except for one thing: `#include <linux/i2c.h>' can cause the
223wrong header file to be included. If you patched the kernel (compilation
224option 3), you will have to use `#include <linux/i2c-old.h>' to include
225the old ones; in all other cases, including the old ones will probably
226be impossible without copying them explicitly to some place that will
227be checked first.
Note: See TracBrowser for help on using the browser.