Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
notro edited this page May 2, 2014 · 27 revisions

rpi-source installs the kernel source used to build rpi-update kernels and the kernel on the Raspian image.
This makes it possible to build loadable kernel modules.
It is not possible to build modules that depend on missing parts that need to be built into the kernel proper (bool in Kconfig).

Examples on how to build various modules

Install

sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source

Run

rpi-source

gcc version check

ERROR:
gcc version check: mismatch between gcc (4.6.3) and /proc/version (4.7.2)
Skip this check with --skip-gcc

rpi-source complains if the major.minor version of gcc differs from the one used to build the kernel.

Version used to build the kernel

$ cat /proc/version
Linux version 3.10.32+ (pi@raspi2) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #2 PREEMPT Fri Mar 7 01:33:27 CET 2014

Current gcc version

$ gcc --version | grep gcc
gcc (Debian 4.6.3-14+rpi1) 4.6.3

Install 4.7

$ sudo apt-get install gcc-4.7 g++-4.7

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7

Choose 4.7

$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-4.6   60        auto mode
  1            /usr/bin/gcc-4.6   60        manual mode
  2            /usr/bin/gcc-4.7   40        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gcc-4.7 to provide /usr/bin/gcc (gcc) in manual mode

Current gcc version

$ gcc --version | grep gcc
gcc (Debian 4.7.2-5+rpi1) 4.7.2

link

ncurses-devel

This library is needed when running 'make menuconfig'

 *** ncurses-devel is NOT installed. Needed by 'make menuconfig'. On Debian: apt-get install ncurses-dev

Install prerequisites

$ sudo apt-get install libncurses5-dev

Misc

Always run 'make prepare' after changing the kernel config

Show kernel config diff between current and previous config

$ scripts/diffconfig
 ENC28J60 n -> m
+ENC28J60_WRITEVERIFY n

Show config diff against the running kernel

$ cd linux
$ zcat /proc/config.gz > .config.running
$ scripts/diffconfig .config.running .config
Clone this wiki locally