Rebuilding OLPC kernel: Difference between revisions

From OLPC
Jump to navigation Jump to search
(Describe the merged build system used for 2.6.30 and 2.6.31)
(Redirected page to Kernel)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
#REDIRECT [[Kernel]]
{{OLPC}}
[[Category:Developers]]
[[Category:Software]]
{{Merge | Kernel}}

This document describes building an OLPC kernel from the olpc-2.6 git repository or SRPM. You will want to do this on a Fedora Core 6 machine. These instructions do not work for FC8, but reportedly work on FC7.

== The OLPC kernel sources ==

The first step involves grabbing the kernel sources; either do a 'git clone' of the kernel git repository, or install the kernel SRPM. Both steps are described on the [[Kernel]] page.

Installing the SRPM will place the sources in /usr/src/redhat/SOURCES/olpc-2.6.tar.bz2

== Building the RPM (the easy way) ==

The simplest way to build the kernel RPM involves downloading the SRPM, installing it, and then running the rpmbuild command. The "dist", "olpc", and "head" macros should be defined when building:

* rpm -ivh kernel-2.6.*-20061026_dc5079fafb767e4olpc1.src.rpm
* rpmbuild -ba --define "dist olpc1" --define "olpc 1" --define "head dc5079fafb767e4" --target=i586 /usr/src/redhat/SPECS/olpc-2.6.spec

After the build finishes, the newly built RPMs will be in /usr/src/redhat/RPMS, and the build tree that was used will be in /usr/src/redhat/BUILD. To make quick changes to the source, for example you can:

<pre>
# cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i586
# vi drivers/video/geode/gxfb_dcon.c
# make
# scp drivers/video/geode/gxfb_dcon.ko testboard:
# ssh testboard "rmmod gxfb_dcon; insmod ./gxfb_dcon.ko"
</pre>

== Building the RPM (from scratch) ==

This is the way that the official kernel RPMs are built. Note that this allows you to build within a subdirectory somewhere (rather than using /usr/src/redhat).

First, grab the kernel sources:

git clone --quiet git://dev.laptop.org/olpc-2.6 linux-2.6.22

Note that the name of the directory these sources are cloned into is important. It must start with <tt>linux.2.6.</tt>, followed by two numbers identifying the sublevel. These must match the sublevel defined in <tt>olpc-2.6/Makefile</tt>.
Optionally check out a particular branch using:

git checkout origin/stable

Now construct the build directory structure:

BASE=`pwd`/build; CUR=0
git clone --quiet git://dev.laptop.org/users/dilinger/olpc-2.6-rpm $BASE
(cd $BASE && mkdir -p BUILD RPMS SOURCES SPECS SRPMS)
tar -jc --exclude=.git -f $BASE/SOURCES/olpc-2.6.tar.bz2 linux-2.6.22

You need to build a config file for the kernel. This is done in the source directory checked out using git:

make ARCH=i386 -C linux-2.6.22 olpc_defconfig
cp linux-2.6.22/.config $BASE/SOURCES/kernel-olpc-custom.config

If building for a school server, make <tt>xs_defconfig</tt> instead:

make ARCH=i386 -C linux-2.6.22 xs_defconfig
cp linux-2.6.22/.config $BASE/SOURCES/kernel-olpc-custom.config

Now you can actually build the kernel and package it into an RPM:

rpmbuild -ba --define "dist 1.olpc" --define "olpc 1" --define "head `echo $CUR|cut -b1-15`" --target=i586 --define "_topdir $BASE" $BASE/SPECS/olpc-2.6.spec

The git://dev.laptop.org/users/dilinger/olpc-2.6-rpm repository contains the RPM SPEC file and other things necessary to bootstrap the RPM. When complete, the RPMs will be in build/RPMS/i586/.

===Upgrading your kernel build===

You will first need to pull down the newest kernel sources, and tar them up:

BASE=`pwd`/build; CUR=0
pushd linux-2.6.22; git pull ; popd
tar -jc --exclude=.git -f $BASE/SOURCES/olpc-2.6.tar.bz2 linux-2.6.22

You need to build a new config file for the kernel. This is done in the source directory checked out using git:

make ARCH=i386 -C linux-2.6.22 olpc_defconfig
cp linux-2.6.22/.config $BASE/SOURCES/kernel-olpc-custom.config

Don't forget to delete the directory from a previous build!

rm -r $BASE/BUILD/*

Now you can actually build the kernel and package it into an RPM:

rpmbuild -ba --define "dist 1.olpc" --define "olpc 1" --define "head `echo $CUR|cut -b1-15`" --target=i586 --define "_topdir $BASE" $BASE/SPECS/olpc-2.6.spec

=== Newer versions ===

The olpc-2.6.30 and olpc-2.6.32 branches have an improved build system by Deepak Saxena (see http://lists.laptop.org/pipermail/devel/2009-July/024939.html for the announcement). In these versions, the RPM support files are included in the kernel checkout. The default configurations for XO-1 or XO_1.5 can be loaded using

make xo_1_defconfig : configure kernel for OLPC XO-1
make xo_1.5_defconfig : configure kernel for OLPC XO-1.5

And RPMs can be built using built-in makefile targets:

make xo_1-kernel-rpm : build XO-1 kernel RPM
make xo_1_5-kernel-rpm : build XO-1.5 kernel RPM
make olpc-kernel-rpm : build both XO-1 and XO-1.5 kernel RPMs

== Building a kernel module ==
: ''From [http://lists.laptop.org/pipermail/devel/2009-August/025532.html Problems compiling bluetooth module] e-mail thread''
Some hardware requires kernel support, such as a [[Adding USB SVGA|USB display]] or USB Bluetooth adapter.
This may only involve adding a kernel module.

It's easiest to recompile the entire kernel and then use only the module you need from the build.

=== Steps ===
* determine the kernel your XO is using, for example if you are using kernel 2.6.25-20090223.1.olpc.69098d87d56945c, get the corresponding src.rpm from http://dev.laptop.org/~dilinger/testing/
* install kernel support packages and tools such as kernel-devel, kernel-headers, gcc, glibc, glibc-devel, glibc-headers and make.
* at the top level directory, run <tt>make menuconfig</tt>.
* enable what you need, for example navigate to Network > Bluetooth and Network > Bluetooth > Bluetooth Drivers.
** when in doubt, turn it on &mdash; you don't have to put the module on your XO, but if you need it, you'd rather not build again.
* after saving your new config, type "make".

=== Sample commands ===
make ARCH=i386 INSTALL_MOD_STRIP=1 olpc_defconfig
make ARCH=i386 INSTALL_MOD_STRIP=1 menuconfig
''activate bluetooth''
make ARCH=i386 INSTALL_MOD_STRIP=1 modules
make ARCH=i386 INSTALL_MOD_STRIP=1 modules_install

See also the forum post [http://www.olpcnews.com/forum/index.php?topic=4623.msg Inserting a kernel module - the "easy way" HowTo]

[[Category:Software development]]
[[Category:Developers]]
[[Category:OS]]
[[Category:Build system]]

Latest revision as of 14:52, 21 February 2011

Redirect to: