15

The default kernel version of Raspbian is 3.1.9+. When I try to compile an extra kernel module I have lots of error messages since the kernel header files are missing. I've checked the Raspbian repository, but I was unable to find the 3.1.9+ kernel headers and kernel source.

If I search for 3.2.0 I can install the new kernel ( linux-image-3.2.0-3-rpi ), the headers ( linux-headers-3.2.0-3-rpi ), and the source ( linux-source-3.2 ) and I can compile the extra module. Unfortunately kernel 3.2 is very unstable for me, so this upgrade is not an option.

asalamon74
  • 4,048
  • 4
  • 29
  • 31

4 Answers4

10

It seems to me, there is no kernel 3.1.9+ source deb package in Raspbian repository. According to Alex Bradbury (asb) they built the Raspbian kernel based on https://github.com/raspberrypi/linux. Based on this kernel compilation documentation I did the following (as root):

cd /usr/src
git clone --depth 1 https://github.com/raspberrypi/linux.git
ln -s linux linux-3.1.9+
cd linux
zcat /proc/config.gz > .config
ln -s /usr/src/linux /lib/modules/3.1.9+/build

After that I was able to recompile the external module.

A few notes:

  • I've cloned the latest version of the kernel source, which is newer than the Raspbian kernel image. If you really need the exact same kernel version then this older version might be better.

  • I've also recompiled the whole kernel just to be sure. Don't do that if you only need to compile an external module, since it takes hours.

  • I had to modify the Makefile of the external module ( 8192cu ) a bit ( setting ARCH to arm instead of armv6l ).
Steve Robillard
  • 34,687
  • 17
  • 103
  • 109
asalamon74
  • 4,048
  • 4
  • 29
  • 31
4

You can use rpi-source to automatically find and install kernel sources for your running kernel.

Also see cross compiling from Linux, to avoid waiting for hours to compile your new kernel.

Mauro Lacy
  • 141
  • 3
1

Stange how that is so difficult...All I can find is this package in the sources list:

Package: linux-libc-dev
Source: linux
Version: 3.2.21-1+rpi1
Architecture: armhf
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Installed-Size: 2790
Conflicts: linux-kernel-headers
Replaces: linux-kernel-headers
Provides: linux-kernel-headers
Multi-Arch: same
Priority: optional
Section: devel
Filename: pool/main/l/linux/linux-libc-dev_3.2.21-1+rpi1_armhf.deb
Size: 764146
SHA256: b75b35ccf8e7fbac582ad08af9579a23095f9dbbc9e7369430e43d584afc48fd
SHA1: e8c3bb2a30483c51ee39b525becd6e213ae9c2c7
MD5sum: 840e28237198aa137dfcdb558ef1cbf5
Description: Linux support headers for userspace development
 This package provides userspaces headers from the Linux kernel.  These
 headers are used by the installed headers for GNU glibc and other system
 libraries.

It seems to provide the tools you need, but I have no idea why there isn't a package called linux-kernel-headers.

However, if you look in the package archive you can find this:

http://archive.raspbian.org/raspbian/pool/main/l/linux-latest/

Perhaps one of the headers packages in that directory will be for the kernel you need.

Unfortunately that is all the information I can currently offer, as I have not yet installed Raspbian myself, although it is on my TODO list.

Jivings
  • 22,538
  • 11
  • 90
  • 139
  • On second thoughts, this is still the wrong version to the one you want isn't it? – Jivings Jul 25 '12 at 19:51
  • This is also for kernel 3.2. The version number ( 3.2.21-1+rpi1 ) is the same for the packages I've mentioned in the question ( e.g. linux-headers-3.2.0-3-all_3.2.21-1+rpi1_armhf.deb ) – asalamon74 Jul 26 '12 at 05:32
-1

If you just need the kernel headers (for compiling modules, etc.), you can now also do this:

sudo apt-get install raspberrypi-kernel-headers

Source: https://www.raspberrypi.org/documentation/linux/kernel/headers.md

Dave
  • 99
  • 1