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