The OLPC kernel
The OLPC kernel is maintained in git:
Current maintainers: Chris Ball, Daniel Drake, Paul Fox
We work on specific git branches, which vary by hardware and operating system release.
|operating system release||git branches|
|13.2.0 13.1.0 ARM XO-4||arm-3.5|
|13.2.0 13.1.0 12.1.0 i386||x86-3.3|
|13.2.0 13.1.0 12.1.0 11.3.1 ARM XO-1.75||arm-3.0-wip|
Or looking at git history may identify which branches we are actively working on, and looking at the version of each branch compared to the kernel shipped in each release will help you identify which branch corresponds to which release(s).
OLPC-specific configurations can be found at arch/x86/configs/ and arch/arm/configs/, these are what we use for automated builds and official releases. This configuration is also installed in /boot in our software releases.
Questions and contributions should be sent to the devel mailing list.
Installing kernel RPMs
The following section only applies to pre-13.2 OS releases. On 13.2.0 and newer, installing a new kernel RPM on an XO will automatically activate it on the boot partition as well.
Due to OLPC's versioned filesystem layout, installing a new kernel RPM is not enough for it to become active on reboot. This is explained in detail in /boot/README. To summarise, after installing a kernel you must copy it to a special place:
If running a software release that uses partitions, first check to ensure that /bootpart is mounted (it should have several directories in it). If it isn't, mount it:
mount /dev/mmcblk0p1 /bootpart
rsync --delete-before -av /boot/ /bootpart/boot/
If running a software release that does not use partitions:
cp -a /boot/* /versions/boot/current/boot/
Building an OLPC kernel
If starting from an OLPC build, first install general development packages needed for kernel compiling: git rpmdevtools gcc make ncurses-devel m4 redhat-rpm-config
- Install build prerequisites: unifdef, lzop, dracut-modules-olpc (be careful with this last one.)
- Clone the git repository: git clone git://dev.laptop.org/olpc-kernel (you will need at least 1.5 GBytes free)
- Checkout the appropriate branch: git checkout olpc-2.6.35 (XO-1.5, for example)
- Run make clean distclean
- Make your changes (updating the configs under arch/x86/configs/ if changes are needed)
- Commit all your changes
- Run make xo_1-kernel-rpm for XO-1, or make xo_1_5-kernel-rpm for XO-1.5, ./olpc/buildrpm 1.75 for XO-1.75, or ./olpc/buildrpm 4 for XO-4
RPM files will be output (in olpc/RPMS/) which you can install on an XO (with the above versioned filesystem layout issues in mind).
Note on kernel configuration
When using the kernel rpm build tools, the kernel configuration used is specified by the rpm spec file (in olpc/SPECS). That is the file you must change, as any .config file in the top level directory will be ignored. Well, not quite, as its absence is noted. You will get the following error message which can be ignored:
*** You have not yet configured your kernel! *** (missing kernel config file ".config") *** *** Please run some configurator (e.g. "make oldconfig" or *** "make menuconfig" or "make xconfig").
Compiling ARM kernels on ARM is sloooow. It's very easy to cross-compile from a faster box.
Another option (a little more tricky) would be to use crosstool-ng to build and install a cross-compiler.
On Fedora 16 or later, you can install an ARM cross compiler with:
yum install gcc-arm-linux-gnu binutils-arm-linux-gnu
To build the kernel, set these environment variables:
export ARCH=arm export CROSS_COMPILE=armv7-linux-gnu-
On Ubuntu 13.04 or later, you can install an ARM cross compiler with:
apt-get install gcc-arm-linux-gnueabi
To build the kernel, set these environment variables:
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabi-
Now you can compile kernels in the normal way. Here is a recipe:
mkdir -p /tmp/xo/lib/modules mkdir -p /tmp/xo/bootpart/boot cp arch/arm/configs/xo*fig .config make oldconfig zImage make modules INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=/tmp/xo make modules_install cp arch/arm/boot/zImage /tmp/xo/bootpart/boot/ (cd /tmp/xo/bootpart/boot/ && ln -sf zImage vmlinuz)
After this, /tmp/xo can be tar'd up and extracted on the XO, on USB media, or on an NFS mount point.
Automatic RPM generation
Some branches are automatically built every 30 minutes (but only when there are new changes), the results are published at http://dev.laptop.org/~kernels/
The directories you see there are also linked to RPM dropboxes, therefore are automatically published for inclusion in development builds. In other words, to get your kernel changes included in the current software release development efforts, you simply have to push your changes to the correct branch.
The utility behind this magic is olpc-kernel-builder:
- Maintainer: Chris Ball
Running development kernels
Starting with 13.1.0 development builds, the /boot (or /bootpart/boot) area of the OS images has changed layout slightly. The kernel and initramfs are now only shipped in zip files, in order to reduce duplication for signed builds, and to remove duplication of firmware code in the olpc.fth boot script.
Dropping your own vmlinuz in place (or booting one from USB as described below, pointing at the internal disk for the initrd.img initramfs) will no longer work as standard, since this will cause the system to start looking for an unzipped initramfs too. The story is similar for initramfs development - if you drop a "raw" initramfs in place, you will need to ensure that an unzipped kernel is also installed. Just run, once, as root:
This will unzip the initramfs from the zip file and save it as initrd.img, and similarly it will unzip the kernel from its zip file and save it as vmlinuz. In both cases, if an existing initrd.img/vmlinuz file is present, it will not be overwritten.
Now drop your files in place as you have done so before, and the system will pick up the "unzipped" partner initramfs/kernel file.
One more detail to be aware of: if you put "unzipped" initramfs/kernel files in place using this method, you will no longer receive automatic firmware updates from bootfw.zip. This should only affect cases where you drop your own development kernel/initramfs in place, then upgrade the olpc-firmware RPM package, and expect that firmware upgrade to be automatically installed.
For more details, read the original proposal: Removing duplication in /boot - affects kernel development.
Running vanilla kernels
In late 2010, OLPC started a focused effort to upstream its kernel patches so that unmodified "vanilla" kernels run with complete functionality on the XO-1 and XO-1.5.
As of Linux-3.5 these efforts are mostly concluded - OLPC only carries a small number of patches, which will be upstreamed as time permits.
You may have to hunt around a bit to satisfy the configuration options so that the relevant drivers get built. If in doubt, feel free to ask on the devel mailing list for someone's recent .config file.
Boot your development kernel from USB
When doing kernel development, it is time consuming to commit each small change, make an RPM, install RPM on the XO, reboot, and test. Instead, you can follow this procedure:
On your development system, prepare a USB disk as follows:
- /boot/olpc.fth (download from here)
- /boot/zImage (your kernel that you want to test)
XO-1.5 and XO-1
- /boot/olpc.fth (download for XO-1 or XO-1.5, be sure to rename to olpc.fth)
- /boot/irfs.img (download here - this is a hacked OLPC initramfs which doesn't require /ofw support)
- /boot/bzImage (your kernel that you want to test)
Now plug this disk into your XO, turn it on, and the system will load the kernel from USB while booting the rest of the system as normal. If your new kernel crashes badly, just unplug the USB disk and boot the system again - it will revert to booting the "good" kernel from local disk.
Note: for XO-1 this only works with JFFS2. (small tweaks to olpc.fth or the hacked initramfs would be needed for ubifs).