Kernel Building

From OLPC
Revision as of 13:37, 19 August 2009 by Martinlanghoff (talk | contribs)
Jump to navigation Jump to search
Merge-arrows.gif
It has been suggested that this article or section be merged with Kernel. (Discuss)


Note
the procedure in this page is only recommended for those already familiar with kernel development. Others may want to rebuild an RPM (see Rebuilding OLPC kernel) to add or enable a module.

Building an OLPC kernel

After obtaining the OLPC source (and if desired, making changes), the following steps can be taken to build a kernel on any Fedora Core machine (Fedora 10 tested):


Go to the directory where the kernel source is copied (On my machine it is under /home/plug/workspace/olpc/kernel/source) and issue the following commands (issue the command "make help" for details):

make $PARAM distclean        # Required only when doing a clean build from scratch i.e. all the previous configuration and binary files in this directory will be deleted.
make $PARAM olpc_defconfig   # The default configuration file for OLPC. Required if building the kernel for the first time.
make $PARAM menuconfig       # Provides a graphical interface for verifying and/or modifying the default configuration file.
make $PARAM                  # Build the kernel and modules.
make $PARAM modules_install  # Root access is not required as the $OUTPUTDIR is a user(developer) accessible directory.
make $PARAM install          # Root access is not required as the $OUTPUTDIR is a user(developer) accessible directory.
make $PARAM headers_install  # Required only for development platforms.

In the above commands replace $PARAM with the following (refer $KERNEL_SRC_DIR/README and $KERNEL_SRC_DIR/Documentation/kbuild/makefiles.txt for details):

0=$OUTPUTDIR ARCH=i386 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$OUTPUTDIR INSTALL_PATH=$OUTPUTDIR INSTALL_HDR_PATH=$OUTPUTDIR

here $OUTPUTDIR is the directory where you want the kernel binary to be copied, e.g. On my build machine it is /home/plug/workspace/olpc/kernel/install. The advantage of having a custom install directory is that you do not require root access and avoid accidentally overwriting the kernel on your build machine.

After installing the kernel, go to $OUTPUTDIR and archive the kernel and the modules as follows:

tar zcvf kern.tar.gz vmlinuz-$VERS System.map-$VERS lib/modules/$VERS

Replace $VERS above with the proper kernel version that has been built.

Assuming everything builds correctly, you will be left with kern.tar.gz. This can be copied over to an XO laptop, and the following steps will install the kernel (again, replacing $VERS with the kernel version). Open the terminal activity on the XO and issue the following commands:

su    # Change to root.
mkdir /tmp/newkernel ; cd /tmp/newkernel
# Issue following commands after copying kern.tar.gz to /tmp/newkernel
tar zxvf kern.tar.gz
cp System.map-$VERS /versions/boot/current/boot/
cp vmlinuz-$VERS /versions/boot/current/boot/
ln -sf /versions/boot/current/boot/vmlinuz-$VERS /versions/boot/current/boot/vmlinuz
cp -r lib/modules/$VERS /lib/modules/

If not booting off NAND, you'll probably want to skip the /versions/boot/current/ prefix on the paths above. A limited number of kernel modules are required by the ramdisk during the boot process; if you need to update the ramdisk, these additional steps are also necessary:

mkdir /tmp/newrdimg ; cd /tmp/newrdimg
zcat /versions/boot/current/boot/olpcrd.img | cpio -i
cp -r /lib/modules/$VERS lib/modules/
find . -print | cpio -H newc -o | gzip -9 > /versions/boot/current/boot/olpcrd.img-$VERS
ln -sf /versions/boot/current/boot/olpcrd.img-$VERS /versions/boot/current/boot/olpcrd.img


Reboot the XO. Open the terminal activity and issue the following command to verify that the XO is running the $VERS kernel:

uname -r