root/i2c/trunk/INSTALL @ 3375

Revision 3375, 9.7 KB (checked in by frodo, 14 years ago)

A new INSTALL file. Please read it and offer comments. I think it

is fairly clear and hopefully complete. If so, a slightly modified
version will be included in the lm_sensors package too.

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