On my Raspberry Pi uname -r gives me 3.6.11+ but in the 3.6.y sources the make file has:


I am trying to compile a module. I (skipping some small steps):

  • made a fresh SD card with 2013-09-25-wheezy-raspbian.img
  • downloaded linux-rpi-3.6.y.tar.gz from github
  • downloaded tools-master.tar.gz from github
  • copied config.gz from Rpi to Ubuntu
  • compiled the kernel without changing .config
  • compiled my module with the compiled kernel above

But when I tried to insmod I got "disagrees about version of symbol module_layout". At this point I am assuming it is because the source I got is 3.6.11 but my Rpi is running 3.6.11+.

How do I get the sources for 3.6.11+? Is there a Raspbian image that has just 3.6.11?


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.


  • Kernel headers and Makefiles. 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.)


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).


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.


Possible solution to rebuild the kernel from source (RPi Kernel Copliation) and extract relevant header files (Extract kernel headers)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.