Kernel Building: Difference between revisions

From OLPC
Jump to navigation Jump to search
(suggesting merge with Kernel page)
No edit summary
Line 5: Line 5:
== Building an OLPC kernel ==
== 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 6 machine:
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):


make oldconfig
make
make modules_install # as root
tar zcvf kern.tar.gz arch/i386/boot/bzImage System.map /lib/modules/$VERS


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):
;Warning!:this needs root and will trash your /lib/modules, if you happen to already have same version. Use "make INSTALL_MOD_PATH=/somewhere modules_install" if you want to avoid using root).

;Note: for current olpc-2.6/master (2.6.26-rcX) <tt>x86</tt> must be used instead of <tt>i386</tt> in these instructions.
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.
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):
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.
cd /
mkdir /tmp/newkern ; cd /tmp/newkernel
tar zxvf .../kern.tar.gz
# Now copy kern.tar.gz to /tmp/newkernel
mv System.map /versions/boot/current/boot/System.map-$VERS
tar zxvf kern.tar.gz
mv arch/i386/boot/bzImage /versions/boot/current/boot/vmlinuz-$VERS
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
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:
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/X ; cd /tmp/X
mkdir /tmp/newrdimg ; cd /tmp/newrdimg
# zcat /versions/boot/current/boot/olpcrd.img | cpio -i
zcat /versions/boot/current/boot/olpcrd.img | cpio -i
# rm -r lib/modules
cp -r /lib/modules/$VERS lib/modules/
find . -print | cpio -H newc -o | gzip -9 > /versions/boot/current/boot/olpcrd.img-$VERS
# cp -r /lib/modules lib/
# find . -print | cpio -H newc -o | gzip -9 > /versions/boot/current/boot/olpcrd.img
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



[[Category:Developers]]
[[Category:Developers]]

Revision as of 17:27, 11 May 2009

Merge-arrows.gif
It has been suggested that this article or section be merged with Kernel. (Discuss)


Note
it is recommended that you build an RPM (Rebuilding OLPC kernel) unless you are already familiar with kernel development!

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/newkern ; cd /tmp/newkernel
# Now copy 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