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