Skip to content

Install kernel sources

notro edited this page Jan 19, 2013 · 6 revisions

This step by step guide is for installing on the Raspberry Pi using the Raspian "wheesy" distro.

The kernel used for this guide:

uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux

This guide assumes everything is done as root

# the [-] minus will give an evironment as if logged in as root
sudo su  -

Long running commands are timed with the ''time'' command.

make zinstall preperation

''make zinstall'' won't work out of the box. One piece is missing.
/sbin/installkernel needs to find a script.

This is a simple solution with the caveat that ''make install'' will actually do ''zinstall''

Create directory

mkdir -p /etc/kernel/postinst.d/

Create file ''/etc/kernel/postinst.d/kernel_img''

#!/bin/sh

ver="$1"
img="$2"

exec </dev/null >&2

# backup current kernel
mv /boot/kernel.img /boot/kernel_last.img

# fat doesn't support symlinks
mv $img /boot/kernel.img

Make the file execuable

chmod +x /etc/kernel/postinst.d/kernel_img

It is also possible to override /sbin/installkernel with INSTALLKERNEL. See kbuild.txt

# This is an example on how 'make zinstall' will call the script /sbin/installkernel
/sbin/installkernel 3.2.27+ arch/arm/boot/zImage System.map "/boot"

Install programs

apt-get update
apt-get -y install git libncurses5-dev

Get kernel sources

We don't download the complete git history (--depth 1) to speed things up.

cd /usr/src
time git clone --depth 1 git://github.com/raspberrypi/linux.git
9 minutes
Clone this wiki locally