The difference between Linux 3.6.11 and 3.6.11+ is that 3.6.11+
has additional commits on top of 3.6.11 (the tag).
If you want to compile the full kernel image and modules, see http://elinux.org/RPi_Kernel_Compilation. However, it seems that you want to compile a single kernel module instead (a driver for your wireless USB stick?). In that case, you can save a lot of time, bytes and CPU time by compiling only the module you need.
Requirements
- Kernel headers and
Makefile
s. On Arch Linux, this is the linux-headers-raspberrypi
package, for Raspbian it's probably one of the linux-headers-(version)
packages.
- If you are not using headers produced during the kernel build, but the source code (e.g. from git/tarball), then you will also need the kernel configuration file
.config
. This is required to produce modules that match the features enabled in the kernel.
- The kernel symbols file
Module.symvers
. Without this file, you will certainly get symbol mismatch errors.
- Kernel module source and Makefile for a module (the Makefile usually contains something like
obj-$(CONFIG_MODNAME) = modname.o
or obj-m = modname.o
.)
Compiling
There are basically two ways to build the kernel module:
- Compiling on the Pi. This is slow, but if you have just a single source file, then installation of the dependencies will probably be easier.
- Cross-compilation, this method makes you build the module on a faster device than your Pi (your Ubuntu installation on the laptop/desktop). It requires a suitable toolchain.
Compiling on Pi
When compiling directly on the Raspberry Pi, you would run something like this:
cd path/to/your/module/sources
make -C /lib/modules/$(uname -r)/build M=$PWD modules -j2
If everything went well, you should now have a .ko
file (e.g. 8192cu.ko
).
Cross-compilation
If you want to cross-compile the module, you will need a suitable toolchain. By suitable, I mean that you have to use exactly the same toolchain as was used for building the kernel. A discrepancy between the toolchain used for the kernel and module may lead to the most non-obvious errors at runtime. Getting this toolchain is out of the scope of this answer. See http://elinux.org/RPi_Kernel_Compilation#2._Cross_compiling_from_Linux for some more details. I built one a few months ago, see https://lekensteyn.nl/files/rpi/toolchains/ for instructions and a tarball.
(In the following section, replace -j8
by -j(number of cores times two)
.)
First, you need to set-up your build environment (adjust the prefix to something suitable for your toolchain):
export CROSS_COMPILE=/absolute/path/to/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-
# Alternatively:
export PATH=/absolute/path/to/arm-unknown-linux-gnueabi/bin:$PATH
export CROSS_COMPILE=arm-unknown-linux-gnueabi-
Prepare kernel sources:
# (tar xf linux-3.6.11.tar.gz or git clone whatever)
cd linux-3.6.11 # or something
gunzip < path/to/config.gz > .config
make -j8 prepare scripts
Proceed with the actual module compilation process:
cd path/to/your/module/sources
# Copy Module.symvers to current directory:
cp path/to/Module.symvers .
make -C path/to/kernel/sources M=$PWD modules -j8 ARCH=arm
If all went well, you should now have a module.ko
file.