Kernel guide for maemo

Introduction

This document has been reviewed and updated for the maemo 3.x release.

This document describes how you can configure, compile and flash the Linux kernel for the Internet Tablet device. It also explains how to compile the cx3110x WLAN driver and how to figure out the size of the zImage kernel file inside a RX-34 FIASCO image.

The document is targeted for developers who want (or need to) compile their own custom kernels for the product.

Prerequisites

If you have not done so, first install the Scratchbox Apophis R4 and set up the maemo development environment as explained in the maemo Tutorial OR as explained in the INSTALL.txt file that is provided with some maemo releases (the INSTALL.txt file always overwrites the tutorial in this context). The required GCC- toolchain that is used to compile the kernel is included in the Scratchbox by default.

  • Start Scratchbox Apophis
    
    $ scratchbox 
    
    
  • Next, select the SDK_ARMEL target that was setup for you automatically by the installer scripts.
    
    [sbox-SDK_X86 ~] > sb-conf select SDK_ARMEL
    
    
  • Next, 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 then add them there.
    
    deb        http://repository.maemo.org/ bora free non-free
    deb-src    http://repository.maemo.org/ bora free non-free
    
    
  • Next, create a working directory (inside Scratchbox) where you will put the kernel sources.
    
    [sbox-SDK_ARMEL: ~] > mkdir ~/maemo_kernel
    
    

Your scratchbox environment should now be ready for kernel compilation.

Get the Kernel sources

You need to get the kernel sources from the repository. They are not included in the rootstraps. Follow these steps to get the sources:

  • Update the package database. This requires that the above mentioned sources.list file has correct content.
    
    [sbox-SDK_ARMEL: ~] > apt-get update
    ... output from apt-get ...
    
    
  • Go to the kernel compilation directory under your home directory in scratchbox
    
    [sbox-SDK_ARMEL: ~] > cd ~/maemo_kernel
    
    
  • Fetch the kernel sources for rx-34 kernel from the bora repository, give command:
    
    [sbox-SDK_ARMEL: ~/maemo_kernel ] > apt-get source kernel-source-rx-34 
    
    

You should now have the kernel sources in your local computer.

Configure and compile the kernel from sources

  • Next, go to the kernel sources directory
    
    [sbox-SDK_ARMEL: ~/maemo_kernel ] > cd kernel-source-rx-34-2.6.18/
    
    
  • Create the default config file for the kernel
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > make n800_defconfig
    # lots of output from make program...
    
    
  • Next, compile the actual kernel image
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > make zImage
    
    
  • Check that the zImage file was properly created.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > ls -l arch/arm/boot/zImage
    -rwxrwxr-x  1 user user 1313052 Nov 16 04:21 arch/arm/boot/zImage
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > 
    
    
    The date and time should be current.

Now that you have compiled a new zImage file you can flash your device with the new kernel using the flasher application. You must do this from outside scratchbox. See the chapter in the end of this document how to flash the kernel to device.

After flashing the kernel reboot the device.

Configuring the Kernel

This chapter explains how to change the kernel configuration.

  • First, run the command below.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > make n800_defconfig
    
    
  • Next, start the vi editor (you can also edit the file outside the scratchbox with your favorite editor of choice) and do the modifications to the .config file.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > vi .config
    
    

    In the .config file it says that don't edit the file but in this example it is OK to edit this file (note, that this is not the normal practice...).

  • Next, run make oldconfig so that the configurations become effective
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > make oldconfig
    
    
  • Now that you have changed the kernel configuration you can compile a new zImage kernel as explained in the previous chapter.

Compiling kernel modules

This chapter explains how to compile a kernel module for the Internet Tablet in the maemo environment. As an example we will first configure the NFS as a kernel module and then do the compilation.

  • First, go to the previously created maemo_kernel directory with the sources.
    
    [sbox-SDK_ARMEL:]> cd  ~/maemo_kernel/kernel-source-rx-34-2.6.18
    
    
  • Then edit the .config file so that you define that the NFS will be a kernel module.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > vi .config
    
    

    Find the location in the .config file that looks like this:

    
    #
    # Network File Systems
    #
    # CONFIG_NFS_FS is not set
    # CONFIG_NFSD is not set
    # CONFIG_SMB_FS is not set
    # CONFIG_CIFS is not set
    # CONFIG_NCP_FS is not set
    # CONFIG_CODA_FS is not set
    # CONFIG_AFS_FS is not set
    # CONFIG_9P_FS is not set
    
    

    And modify it so that it looks like this:

    
    #
    # Network File Systems
    #
    CONFIG_NFS_FS=m
    CONFIG_NFSD=m
    # CONFIG_SMB_FS is not set
    # CONFIG_CIFS is not set
    # CONFIG_NCP_FS is not set
    # CONFIG_CODA_FS is not set
    # CONFIG_AFS_FS is not set
    # CONFIG_9P_FS is not set
    
    
  • Now you have described in the .config file that NFS should be compiled as a kernel module. Next, compile the kernel.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > make oldconfig
    
    # ... lots of text to the screen, but eventually you should get:
    
    *
    * Network File System
    *
    NFS file system support (NFS_FS) [M/n/y/?] m
    Provide NFSv3 client support (NFS_V3) [N/y/?] (NEW) y
    Provide client support for the NFSv3 ACL protocol extension (NFS_V3_ACL) [N/y/?] (NEW) y
    Provide NFSv4 client support (EXPERIMENTAL) (NFS_V4) [N/y/?] (NEW) N
    Allow direct I/O on NFS files (EXPERIMENTAL) (NFS_DIRECTIO) [N/y/?] (NEW) N
    NFS server support (NFSD) [M/n/y/?] m
    Provide NFSv3 server support (NFSD_V3) [N/y/?] (NEW) y
    Provide server support for the NFSv3 ACL protocol extension (NFSD_V3_ACL) [N/y/?] (NEW) y
    Provide NFSv4 server support (EXPERIMENTAL) (NFSD_V4) [N/y/?] (NEW) N
    Provide NFS server over TCP support (NFSD_TCP) [Y/n/?] (NEW) Y
    Secure RPC: Kerberos V mechanism (EXPERIMENTAL) (RPCSEC_GSS_KRB5) [N/m/?] (NEW) N
    Secure RPC: SPKM3 mechanism (EXPERIMENTAL) (RPCSEC_GSS_SPKM3) [N/m/?] (NEW) N
    SMB file system support (to mount Windows shares etc.) (SMB_FS) [N/m/y/?] n
    CIFS support (advanced network filesystem for Samba, Window and other CIFS compliant servers) (CIFS) [N/m/y/?] n
    NCP file system support (to mount NetWare volumes) (NCP_FS) [N/m/y/?] n
    Coda file system support (advanced network fs) (CODA_FS) [N/m/y/?] n
    Andrew File System support (AFS) (Experimental) (AFS_FS) [N/m/y/?] n
    Plan 9 Resource Sharing Support (9P2000) (Experimental) (9P_FS) [N/m/y/?] n
    # and then finally ...
    #
    # configuration written to .config
    #
    
    

    Now you can compile the actual kernel modules by running the command make modules as shown below.

    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > make modules
    
    

    If there was no errors during the compilation you can check what kernel objects (.ko) files you now have. Run the find command as shown below.

    
    [sbox-SDK_ARMEL: ~/maemo_kernel/kernel-source-rx-34-2.6.18] > find . -name "*ko" -ls
    687528   32 -rw-rw-r--   1 user     user        31540 Nov 16 05:47 ./drivers/usb/gadget/g_ether.ko
    687532   32 -rw-rw-r--   1 user     user        31132 Nov 16 05:47 ./drivers/usb/gadget/g_file_storage.ko
    671071    8 -rw-rw-r--   1 user     user         5922 Nov 16 05:47 ./fs/exportfs/exportfs.ko
    687536   64 -rw-rw-r--   1 user     user        60811 Nov 16 05:47 ./fs/ext2/ext2.ko
    703836  132 -rw-rw-r--   1 user     user       128155 Nov 16 05:47 ./fs/ext3/ext3.ko
    656668   68 -rw-rw-r--   1 user     user        61628 Nov 16 05:47 ./fs/jbd/jbd.ko
    719198   76 -rw-rw-r--   1 user     user        72921 Nov 16 05:47 ./fs/lockd/lockd.ko
    182947  140 -rw-rw-r--   1 user     user       136302 Nov 16 05:47 ./fs/nfs/nfs.ko
    182951    8 -rw-rw-r--   1 user     user         4309 Nov 16 05:47 ./fs/nfs_common/nfs_acl.ko
    182955  120 -rw-rw-r--   1 user     user       118257 Nov 16 05:47 ./fs/nfsd/nfsd.ko
    671075   12 -rw-rw-r--   1 user     user         9159 Nov 16 05:47 ./fs/mbcache.ko
    774069  156 -rw-rw-r--   1 user     user       153963 Nov 16 05:47 ./net/sunrpc/sunrpc.ko
    
    

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

Now that you have the required .ko files you could copy these to the device and then in the device use the insmod command to add the modules to the running kernel.

Note, that if you are using the developer rootfs in the device you can copy the .ko files in the device to /lib/modules/2.6.18-omap1/ directory.

If you are planning to install the .ko kernel modules on a device that is running the official sales image (also known as product image) then the directory would be /mnt/initfs/lib/modules/2.6.18/ but it is not possible to write into this directory.

This is not a problem because you can just use the insmod command and add the .ko modules into the running kernel.

Compiling the WLAN cx3110x driver

If you want to compile the cx3110x WLAN driver from sources you have to first download AND compile the rx-34 kernel sourcesas explained above. After doing that follow these instructions:

  • Download the cx3110x source .tar.gz package from : garage.maemo.org
  • Copy the cx3110x-1.2.tar.gz inside the scratchbox under the maemo_kernel directory and extract it.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel] > tar xvzf cx3110x-1.2.tar.gz
    cx3110x-1.2/
    cx3110x-1.2/.gitignore
    cx3110x-1.2/COPYING
    cx3110x-1.2/Makefile
    cx3110x-1.2/src/
    cx3110x-1.2/src/Makefile
    ... etc ...
    
    [sbox-SDK_ARMEL: ~/maemo_kernel] > cd cx3110x-1.2
    [sbox-SDK_ARMEL: ~/maemo_kernel/cx3110x-1.2] >
    
    
  • Next, we assume that your RX-34 kernel sources are under the ~/maemo_kernel/kernel-source-rx-34-2.6.18 directory. Next you need to compile the cx3110x module like this:
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/cx3110x-1.2] > make KERNEL_SRC_DIR=~/maemo_kernel/kernel-source-rx-34-2.6.18/ modules
    
    

    The compilation output should be very similar to this (note, there might be small differences if the cx3110x module version is slightly different than what is used in this document (the word someuser will be your own user name in your system).

    
    make -C src/ modules CONFIG_CX3110X_PROD=m
    make[1]: Entering directory `/home/someuser/maemo_kernel/cx3110x-1.2/src'
    make -C /home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18/ SUBDIRS=/home/someuser/maemo_kernel/cx3110x-1.2/src modules
    make[2]: Entering directory `/home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18'
    
      WARNING: Symbol version dump /home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18/Module.symvers
               is missing; modules will have no dependencies and modversions.
    
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_spi_io.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_pda.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_sysfs.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_ioctl.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_spi.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_sysfs_mtum.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_ioctl_mtum.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/dummy_umac.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/cx3110x_mt.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/mtum.o
      Building modules, stage 2.
      MODPOST
      CC      /home/someuser/maemo_kernel/cx3110x-1.2/src/cx3110x_mt.mod.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/cx3110x_mt.ko
      CC      /home/someuser/maemo_kernel/cx3110x-1.2/src/mtum.mod.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/mtum.ko
    make[2]: Leaving directory `/home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18'
    strip -g *.ko
    make[1]: Leaving directory `/home/someuser/maemo_kernel/cx3110x-1.2/src'
    rm -f src/Modules.symvers
    make -C src/ modules CONFIG_CX3110X_STA=m
    make[1]: Entering directory `/home/someuser/maemo_kernel/cx3110x-1.2/src'
    make -C /home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18/ SUBDIRS=/home/someuser/maemo_kernel/cx3110x-1.2/src modules
    make[2]: Entering directory `/home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18'
    
      WARNING: Symbol version dump /home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18/Module.symvers
               is missing; modules will have no dependencies and modversions.
    
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_spi_io.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_pda.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_sysfs.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_ioctl.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_spi.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_sysfs_umac.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/sm_drv_ioctl_umac.o
      CC [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/dummy_umac.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/cx3110x.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/umac.o
      Building modules, stage 2.
      MODPOST
      CC      /home/someuser/maemo_kernel/cx3110x-1.2/src/cx3110x.mod.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/cx3110x.ko
      CC      /home/someuser/maemo_kernel/cx3110x-1.2/src/umac.mod.o
      LD [M]  /home/someuser/maemo_kernel/cx3110x-1.2/src/umac.ko
    make[2]: Leaving directory `/home/someuser/maemo_kernel/kernel-source-rx-34-2.6.18'
    strip -g *.ko
    make[1]: Leaving directory `/home/someuser/maemo_kernel/cx3110x-1.2/src'
    [sbox-SDK_ARMEL: ~/maemo_kernel/cx3110x-1.2] >
    
  • Check that you have got the .ko modules.
    
    [sbox-SDK_ARMEL: ~/maemo_kernel/cx3110x-1.2] > cd src
    [sbox-SDK_ARMEL: ~/maemo_kernel/cx3110x-1.2/src] > ls -l *.ko
    -rw-rw-r--  1 someuser someuser 61884 Jun 14 13:56 cx3110x.ko
    -rw-rw-r--  1 someuser someuser 61876 Jun 14 13:56 cx3110x_mt.ko
    -rw-rw-r--  1 someuser someuser  5816 Jun 14 13:56 mtum.ko
    -rw-rw-r--  1 someuser someuser  5816 Jun 14 13:56 umac.ko
    [sbox-SDK_ARMEL: ~/kernel/cx3110x-1.2/src] >
    
    

    Important: Note, that the produced umac.ko is a DUMMY kernel object file and it can not be used in the actual device. The Tablet Device has the real umac.ko file so do not overwrite the umac.ko in the device with the umac.ko that was produced in this compilation.

  • Copy the cx3110x.ko in the N800 Internet Tablet (use your preferred copy method).
  • In the device, login as root and insmod the cx3110x module the normal way:
    
    #N800-/home/user # id
    uid=0(root) gid=0(root)
    
    #N800-/home/user # lsmod
    ... snip ...
    cx3110x 49832 0 - Live 0xbf040000
    umac 256836 1 cx3110x, Live 0xbf000000
    ... snip ...
    
    #N800-/home/user # rmmod cx3110x
    #N800-/home/user # 
    
    #N800-/home/user # insmod /the/path/to/the/cx3110x-module/you/copied/cx3110x.ko
    #N800-/home/user # lsmod
    ... snip ...
    cx3110x 49832 0 - Live 0xbf040000
    umac 256836 1 cx3110x, Live 0xbf000000
    ... snip ...
    
    
  • After you have run the insmod cx3110x.ko commande you need to run wlan-cal like this:
    
    #N800-/home/someuser # chroot /mnt/initfs /usr/bin/wlan-cal 
    
    

    The output is similar to:

    
    Pushing default country...[OK]
    Pushing MAC address...[OK]
    Pushing IQ tuned values...[OK]
    Pushing TX tuned values...[OK]
    Pushing TX limits...[OK]
    Pushing RX tuned values...Using default values [OK]
    #N800-/home/someuser # 
    
    
  • Now you should be able to use the WLAN network with the cx3110x driver you compiled.

How to check the size of the zImage file inside a FIASCO image

In this chapter we show how you can check the size of the kernel zImage file in the FIASCO image.

  • First, download the same FIASCO image that you are running in your Internet Tablet. Let's assume the name of the FIASCO image is RX-34_2007SE_3.2007.10-7_PR_COMBINED_MR0_ARM.bin.

  • Use the flasher tool with the -u (--unpack) option like this:
    
    you@linuxpc:~/tmp$  flasher -F RX-34_2007SE_3.2007.10-7_PR_COMBINED_MR0_ARM.bin -u
    flasher v0.9.0 (Jan 19 2007)
    
    SW version in image: RX-34_2007SE_3.2007.10-7_PR_MR0
    Image 'kernel', size 1311104 bytes
            Version 2.6.18-200710osso2
    Image 'initfs', size 1689216 bytes
            Version 0.93-40
    Image 'rootfs', size 83886080 bytes
            Version RX-34_2007SE_3.2007.10-7_PR_MR0
    Image '2nd', size 8064 bytes
            Valid for RX-34: 1301, 1302
            Version 1.1.5-3
    Image 'xloader', size 9088 bytes
            Valid for RX-34: 1301, 1302
            Version 1.1.5-3
    Image 'secondary', size 95872 bytes
            Valid for RX-34: 1301, 1302
            Version 1.1.5-3
    Unpacking kernel image to file 'zImage'...
    Unpacking initfs image to file 'initfs.jffs2'...
    Unpacking rootfs image to file 'rootfs.jffs2'...
    Unpacking 2nd image to file '2nd.bin-RX-34:1301,1302'...
    Unpacking xloader image to file 'xloader.bin-RX-34:1301,1302'...
    Unpacking secondary image to file 'secondary.bin-RX-34:1301,1302'...
    
  • The size of the kernel is displayed in the output of the flasher but you can also just do:
    you@linuxpc:~/tmp$  ls -lh
    total 167M
    -rw-r--r-- 1 someuser someuser 7.9K 2007-06-15 11:05 2nd.bin-RX-34:1301,1302
    -rw-r--r-- 1 someuser someuser 1.7M 2007-06-15 11:05 initfs.jffs2
    -rw-r--r-- 1 someuser someuser  80M 2007-06-15 11:05 rootfs.jffs2
    -rw-r--r-- 1 someuser someuser  83M 2007-06-15 10:53 RX-34_2007SE_3.2007.10-7_PR_COMBINED_MR0_ARM.bin
    -rw-r--r-- 1 someuser someuser  94K 2007-06-15 11:05 secondary.bin-RX-34:1301,1302
    -rw-r--r-- 1 someuser someuser 8.9K 2007-06-15 11:05 xloader.bin-RX-34:1301,1302
    -rw-r--r-- 1 someuser someuser 1.3M 2007-06-15 11:05 zImage
    

    From the output you can see that the zImage kernel file size is about 1.3 Mb.

Flashing the Kernel to the device

After succesfully compiling a new kernel image you can flash it to the device. Run the following command outside the Scratchbox environment.

Note, that you need to use your real login name and replace the yourname tag in the command below.


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

Troubleshooting Tips and Tricks

It is possible to render the device unusable if the size of the kernel is too big. If this happens then you need to flash the smaller ready compiled kernel back to the device.

Run the command below from inside the scratchbox to get the ready compiled kernel image.


sbox-SDK_ARMEL: ] > apt-get install rx-34-kernel

After you run the command above you can flash the default kernel image from directory /usr/share/osso/kernels/. The kernel image name is zImage-rx-34-xxxxxx where xxxxxx is year and week timestamp.

You can now flash the kernel image to the device as explained above.



Improve this page