Kernel Guide for Maemo

Introduction

This document has been reviewed for maemo 4.0.

This document describes how to configure, compile and flash the Linux kernel for the Internet Tablet device. The document is targeted for developers wishing to compile their own custom kernels for the device.

Prerequisites

Before starting, the maemo 4.0 Chinook environment should be set up as explained in the maemo Tutorial. The required GCC toolchain that is used to compile the kernel is included in the Scratchbox by default.

It is not mandatory to set up a separate target for kernel compilation, but this example does it in case the default armel target has been modified in some special way.

  • Start Scratchbox
    $ scratchbox
  • Create a new target called MaemoKernel with qemu-arm CPU transparency. The second command installs the armel rootstraps to the target. The last command installs the C-library, /etc, devkits and fakeroot.
    [sbox-CHINOOK_ARMEL: ~] > sb-conf setup MaemoKernel -c cs2005q3.2-glibc2.5-arm -t /scratchbox/devkits/cputransp/bin/qemu-arm-0.8.2-sb2
    [sbox-CHINOOK_ARMEL: ~] > sb-conf select MaemoKernel
    [sbox-CHINOOK_ARMEL: ~] > sb-conf rs MaemoKernel /home/username/maemo-sdk-rootstrap_4.0_armel.tar.gz
    [sbox-CHINOOK_ARMEL: ~] > sb-conf in MaemoKernel -e -d -F
    
    N.B.
    The username above refers to your login name in your environment. If you have used the maemo installer, the rootstraps are under your home directory. If you have performed a manual installation, the rootstrap is under /scratchbox/packages directory. This should be paid attention to, when running the sb-conf command above.
  • Verify that your sources.list file inside the scratchbox environment is correct. If the below lines are not in the /etc/apt/sources.list file, add them there.
    deb        http://repository.maemo.org/ chinook free non-free
    deb-src    http://repository.maemo.org/ chinook free non-free
    
  • Create a working directory (inside Scratchbox) for the kernel sources.
    [sbox-MaemoKernel: ~] > mkdir ~/maemo_kernel
    

The Scratchbox environment is now ready for compiling the kernel

Getting Kernel Sources

Kernel sources are not included in the rootstrap, and therefore need to be downloaded from the repository.

  • Select the kernel compilation target if not selected already.
    [sbox-armel: ~] > sb-conf select MaemoKernel
    
  • Update the package database. This requires the earlier modifications in the sources.list file.
    [sbox-MaemoKernel: ~] > apt-get update
    
  • Go to the working directory and fetch the sources.
    [sbox-MaemoKernel: ~] > cd ~/maemo_kernel
    [sbox-MaemoKernel: ~/maemo_kernel ] > apt-get source kernel-source-rx-34
    

Kernel sources should now be fetched and ready to be compiled.

Configuring Source Tree and Compiling Kernel

  • There is a source subdirectory. Enter the directory and create the default configuration.
    [sbox-MaemoKernel: ~/maemo_kernel ] > cd kernel-source-rx-34-2.6.21.0/
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > make nokia_2420_defconfig
    # lots of output from make program...
    
  • Compile the kernel image, and check the image file timestamp to ensure that it is properly created.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > make bzImage
    # compilation output...
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > ls -l arch/arm/boot/zImage
    -rwxrwxr-x  1 maemo maemo 1530180 Nov  2 13:40 arch/arm/boot/zImage
    

Now the device can be flashed with the new kernel image using the Flasher tool. This should be performed outside Scratchbox. See the section in the end of this document for short flashing instructions.

Changing Default Kernel Configuration

The following steps describe how to change the default kernel configuration.

  • Restore the original default configuration, just in case it has been changed.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > make nokia_2420_defconfig
    
  • Edit the configuration file with your editor of choice. It is all right to edit the file, even though there is a warning against changing the one included.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > vi .config
    
  • Include your changes for compilation.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > make oldconfig
    

Now a kernel image with modified configuration can be recompiled as described in the previous section.

Configuring and Compiling Kernel Modules

This section explains how to configure and compile additional kernel modules for the Internet Tablet in the maemo environment. NFS is used as an example.

  • Go to your working directory with kernel sources.
    [sbox-MaemoKernel:]> cd  ~/maemo_kernel/kernel-source-rx-34-2.6.21.0
    
  • Edit the configuration file and define that the NFS will be a kernel module.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > vi .config
    

    Find the location of the NFS configuration.

    #
    # Network File Systems
    #
    # CONFIG_NFS_FS is not set
    # CONFIG_NFSD is not set
    

    Enable NFS support as modules:

    #
    # Network File Systems
    #
    CONFIG_NFS_FS=m
    CONFIG_NFSD=m
    
  • As described in previous sections, refresh the configuration and build new modules.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > make oldconfig
    # lots of output here. Answer Y to NFSv3, default to others.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > make modules
    
  • Check with the find command to see what kernel object files (extension .ko) there now are.
    [sbox-MaemoKernel: ~/maemo_kernel/kernel-source-rx-34-2.6.21.0] > find . -name "*.ko" -ls
    1219535   20 -rw-rw-r--   1 maemo    maemo       19452 Nov  2 13:48 ./arch/arm/mach-omap2/observability.ko
    1219539   12 -rw-rw-r--   1 maemo    maemo        8304 Nov  2 13:48 ./arch/arm/mach-omap2/peeknpoke.ko
    1219543    8 -rw-rw-r--   1 maemo    maemo        5928 Nov  2 13:48 ./arch/arm/mach-omap2/snapshot.ko
    2967668  168 -rw-rw-r--   1 maemo    maemo      167603 Nov  2 13:48 ./net/sunrpc/sunrpc.ko
    2710063   32 -rw-rw-r--   1 maemo    maemo       31503 Nov  2 13:48 ./drivers/usb/gadget/g_ether.ko
    2710071   24 -rw-rw-r--   1 maemo    maemo       22481 Nov  2 13:48 ./drivers/usb/gadget/gadgetfs.ko
    2710067   36 -rw-rw-r--   1 maemo    maemo       36142 Nov  2 13:48 ./drivers/usb/gadget/g_file_storage.ko
    2890706  128 -rw-rw-r--   1 maemo    maemo      124939 Nov  2 13:48 ./fs/ext3/ext3.ko
    1219547   12 -rw-rw-r--   1 maemo    maemo        9159 Nov  2 13:48 ./fs/mbcache.ko
    2890698    8 -rw-rw-r--   1 maemo    maemo        5922 Nov  2 13:48 ./fs/exportfs/exportfs.ko
    2890702   64 -rw-rw-r--   1 maemo    maemo       60734 Nov  2 13:48 ./fs/ext2/ext2.ko
    2890710   68 -rw-rw-r--   1 maemo    maemo       61687 Nov  2 13:48 ./fs/jbd/jbd.ko
    2890718  144 -rw-rw-r--   1 maemo    maemo      142363 Nov  2 13:48 ./fs/nfs/nfs.ko
    2890722  112 -rw-rw-r--   1 maemo    maemo      109711 Nov  2 13:48 ./fs/nfsd/nfsd.ko
    2890714   80 -rw-rw-r--   1 maemo    maemo       75526 Nov  2 13:48 ./fs/lockd/lockd.ko
    

    The list of .ko files might differ from the list above, depending whether some additional changes were made to the .config file. The important files are sunrpc.ko, nfs.ko and lockd.ko. Check that you have those.

The kernel modules are kept in /mnt/initfs/lib/modules/2.6.21-omap1/. However, it is write protected. This is not a problem, because the insmod command can be used to load the modules into the running kernel from any directory where they have been saved to.

Flashing Kernel

The custom kernel can be flashed from outside the Scratchbox with the flasher tool.

# flasher -f -k /scratchbox/users/<yourname>/home/<yourname>/maemo_kernel/kernel-source-rx-34-2.6.21.0/arch/arm/boot/zImage


Improve this page