Kernel: Difference between revisions
Line 59: | Line 59: | ||
RPM files will be output (in olpc/RPMS/) which you can install on an XO (with the above versioned filesystem layout issues in mind). |
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 <tt>.config</tt> 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"). |
|||
=== Cross compiling === |
=== Cross compiling === |
Revision as of 16:17, 2 March 2012
The OLPC kernel
OLPC OS Releases use our OLPC-modified version of the Linux kernel.
The OLPC kernel is maintained in git:
Current maintainers: Chris Ball, Daniel Drake, Paul Fox
We work on specific git branches for each operating system release.
operating system release | git branches |
---|---|
11.3.1 ARM | arm-3.0-ramp |
11.2.0 i386 | olpc-2.6.35 |
10.1.3 i386 | olpc-2.6.31 |
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/, 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
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
Then:
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, or ./olpc/buildrpm 1.75 for XO-1.75
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").
Cross compiling
Compiling ARM kernels on ARM is sloooow. It's very easy to cross-compile from a faster box. Install an ARM cross compiler (using e.g. crosstool-ng) then adjust your environment so that your cross compiler is included in your PATH, set the CROSS_COMPILE variable to the architecture prefix, and set ARCH=arm. For example:
export PATH=/opt/xcc/gcc-4.6.0/bin:$PATH export ARCH=arm export CROSS_COMPILE=armv7-unknown-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 of olpc-2.6.
The utility behind this magic is olpc-kernel-builder:
- http://dev.laptop.org/git/projects/olpc-kernel-builder/
- git://dev.laptop.org/projects/olpc-kernel-builder
- Maintainer: Chris Ball
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.
As of 2.6.38 this is coming along nicely, and these efforts will continue til everything is upstream. Unmodified kernels run reasonably well with most functionality available.
You may have to hunt around a bit to satisfy the configuration options so that the relevant drivers get built, and the XO-1.5 needs some special kernel parameters to boot (you can find them in a recent olpc-2.6 branch in the XO-1.5 defconfig as CONFIG_CMDLINE). 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:
XO-1.75:
- /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).