Editing Documentation/Maemo 5 Developer Guide/Kernel and Debugging Guide/Maemo Kernel Guide

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
 +
= Kernel Guide =
 +
This chapter describes how to configure, compile and flash the Linux kernel for the Internet Tablet device. The chapter is targeted at developers wishing to compile their own custom kernels for the device.
This chapter describes how to configure, compile and flash the Linux kernel for the Internet Tablet device. The chapter is targeted at developers wishing to compile their own custom kernels for the device.
== Prerequisites ==
== Prerequisites ==
-
Before starting, set up the Maemo environment. The required GCC toolchain that is used to compile the kernel is included in Scratchbox by default.
+
Before starting, set up the Maemo environment. The required GCC toolchain that is used to compile the kernel is included in the Scratchbox by default.
Setting up a separate target for kernel compilation is not mandatory, but this example does it in case the default armel target has been modified in some way.
Setting up a separate target for kernel compilation is not mandatory, but this example does it in case the default armel target has been modified in some way.
 +
<ul>
<ul>
Line 24: Line 27:
[sbox-FREMANTLE_ARMEL: ~] > sb-conf select MaemoKernel
[sbox-FREMANTLE_ARMEL: ~] > sb-conf select MaemoKernel
[sbox-MaemoKernel: ~] > sb-conf rs MaemoKernel \
[sbox-MaemoKernel: ~] > sb-conf rs MaemoKernel \
-
/home/&lt;username&gt;/maemo-sdk-rootstrap_5.0_armel.tgz
+
/home/&lt;username&gt;/maemo-sdk-rootstrap_5.0beta_armel.tgz
[sbox-MaemoKernel: ~] > sb-conf in MaemoKernel -edFL
[sbox-MaemoKernel: ~] > sb-conf in MaemoKernel -edFL
</pre></li>
</pre></li>
Line 30: Line 33:
{{ambox|text=The <username> above refers to your login name in the 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 the /scratchbox/packages directory. Keep this in mind when running the sb-conf command above.}}
{{ambox|text=The <username> above refers to your login name in the 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 the /scratchbox/packages directory. Keep this in mind when running the sb-conf command above.}}
 +
<ul>
<ul>
Line 86: Line 90:
<li><pre>
<li><pre>
[sbox-MaemoKernel: ~/maemo_kernel ] > cd kernel-2.6.28
[sbox-MaemoKernel: ~/maemo_kernel ] > cd kernel-2.6.28
-
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-omap1 rx51_defconfig
+
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-maemo2 rx51_defconfig
  # lots of output from make program...
  # lots of output from make program...
</pre></li>
</pre></li>
Line 93: Line 97:
<li><pre>
<li><pre>
-
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] &gt; make EXTRAVERSION=-omap1 bzImage
+
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] &gt; make EXTRAVERSION=-maemo2 bzImage
# compilation output...
# compilation output...
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] &gt; ls -l arch/arm/boot/zImage
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] &gt; ls -l arch/arm/boot/zImage
Line 100: Line 104:
</ul>
</ul>
-
{{ambox|text=The kernel is very strict on versions. <code>EXTRAVERSION=-omap1</code> sets the version to match the default installation. Instead of always supplying it to the <code>make</code> command, as done in this chapter, it is possible to modify the kernel <code>Makefile</code>. Another alternative is to avoid using <code>make</code> directly and use <code>dpkg-buildpackage -rfakeroot -b</code> to compile the kernel.}}
+
 
 +
{{ambox|text=The kernel is very strict on versions. <code>EXTRAVERSION=-maemo2</code> sets the version to match the default installation. Instead of always supplying it to the <code>make</code> command, as done in this chapter, it is possible to modify the kernel <code>Makefile</code>. Another alternative is to avoid using <code>make</code> directly and use <code>dpkg-buildpackage -rfakeroot -b</code> to compile the kernel.}}
Line 113: Line 118:
   
   
<li><pre>
<li><pre>
-
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-omap1 \
+
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-maemo2 \
rx51_defconfig
rx51_defconfig
</pre></li>
</pre></li>
Line 126: Line 131:
<li><pre>
<li><pre>
-
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-omap1 oldconfig
+
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-maemo2 oldconfig
</pre></li>
</pre></li>
</ul>
</ul>
Line 132: Line 137:
Now a kernel image with modified configuration can be recompiled.
Now a kernel image with modified configuration can be recompiled.
-
 
-
If you have a local repository, by default extra information will be appended to the kernel version. This will stop the kernel version from matching the default install.  To keep it from doing so, change scripts/setlocalversion to add "exit" to the beginning:
 
-
<source lang="bash">
 
-
#!/bin/sh
 
-
# Print additional version information for non-release trees.
 
-
exit
 
-
</source>
 
== Compiling External Kernel Modules ==
== Compiling External Kernel Modules ==
Line 150: Line 148:
<li> Download the example files from the Maemo svn.
<li> Download the example files from the Maemo svn.
<pre>
<pre>
-
[sbox-MaemoKernel: ~/maemo_kernel] > svn export https://vcs.maemo.org/svn/\
+
[sbox-MaemoKernel: ~/maemo_kernel] > svn export https://garage.maemo.org/svn/\
-
maemoexamples/tags/maemo_5.0/hello-module/
+
maemoexamples/trunk/hello-module/
[sbox-MaemoKernel: ~/maemo_kernel] > cd hello-module
[sbox-MaemoKernel: ~/maemo_kernel] > cd hello-module
Line 188: Line 186:
module_exit(hello_exit);
module_exit(hello_exit);
</pre>
</pre>
-
 
+
Compiling kernel modules differs from compiling  
-
Compiling kernel modules differs from compiling normal programs. That is reflected in the <code>Makefile</code>:
+
normal programs. That is reflected in the <code>Makefile</code>:
-
 
+
<pre>
<pre>
[sbox-MaemoKernel: ~/maemo_kernel/hello-module] > cat Makefile
[sbox-MaemoKernel: ~/maemo_kernel/hello-module] > cat Makefile
Line 201: Line 198:
# default build target (uses kernel build (kbuild) system)
# default build target (uses kernel build (kbuild) system)
all:
all:
-
$(MAKE) -C $(KERNELDIR) M=`pwd` EXTRAVERSION=-omap1 modules
+
$(MAKE) -C $(KERNELDIR) M=`pwd` EXTRAVERSION=-maemo2 modules
# target for cleaning up
# target for cleaning up
Line 208: Line 205:
$(RM) -R .tmp_versions
$(RM) -R .tmp_versions
</pre>
</pre>
-
 
The <code>all:</code> target compiles the module, not using this <code>Makefile</code>,
The <code>all:</code> target compiles the module, not using this <code>Makefile</code>,
but a <code>Makefile</code> in the kernel headers folder set in variable  
but a <code>Makefile</code> in the kernel headers folder set in variable  
Line 214: Line 210:
</li>
</li>
-
<li>Compile the module.
+
<li> Compile the module.
<pre>
<pre>
[sbox-MaemoKernel: ~/maemo_kernel/hello-module] &gt; make
[sbox-MaemoKernel: ~/maemo_kernel/hello-module] &gt; make
Line 242: Line 238:
</ol>
</ol>
-
File <code>hello.ko</code> is the new module. Install it by copying it to the device and running it (as root)
+
 
 +
File <code>hello.ko</code> is the new module. You can install it by copying it to the device and running it (as root)
  Nokia-NXX-31-10:/home/user# insmod hello.ko
  Nokia-NXX-31-10:/home/user# insmod hello.ko
-
and remove it by calling  
+
and removed by calling  
  Nokia-NXX-31-10:/home/user# rmmod hello.ko
  Nokia-NXX-31-10:/home/user# rmmod hello.ko
 +
Check that the module worked properly by examining the kernel ring buffer:
Check that the module worked properly by examining the kernel ring buffer:
Line 254: Line 252:
  [11928.357696] Goodbye, world
  [11928.357696] Goodbye, world
-
If there is a slight version mismatch between SDK's kernel headers and the running kernel on device, <code>insmod</code> refuses to install the module with the error message <code>insmod: error inserting '<module>': -1 Invalid module format</code>. In this case, install the module by stripping version info from it before installation:
+
If there is a slight version mismatch between SDK's kernel headers and the running kernel on device, <code>insmod</code> refuses to install the module. In this case, install the module by stripping version info from it before installation:
   
   
  [sbox-FREMANTLE_ARMEL: ~/maemo_kernel/hello-module] &gt; objcopy --strip-debug \  
  [sbox-FREMANTLE_ARMEL: ~/maemo_kernel/hello-module] &gt; objcopy --strip-debug \  
  -R .modinfo -R __versions hello.ko
  -R .modinfo -R __versions hello.ko
-
For more information on kernel modules, see the following:
+
For additional reading on kernel modules, see, e.g.:
* [http://www.tldp.org/LDP/lkmpg/2.6/html/index.html The Linux Kernel Module Programming Guide]
* [http://www.tldp.org/LDP/lkmpg/2.6/html/index.html The Linux Kernel Module Programming Guide]
Line 267: Line 265:
This section explains how to configure and compile additional kernel modules included in the kernel source tree for the Internet Tablet in the Maemo environment. The NFSD module is used as an example. In this section, the modules are compiled against the full kernel source tree, not the kernel headers package. This example compiles all configured modules at once.
This section explains how to configure and compile additional kernel modules included in the kernel source tree for the Internet Tablet in the Maemo environment. The NFSD module is used as an example. In this section, the modules are compiled against the full kernel source tree, not the kernel headers package. This example compiles all configured modules at once.
 +
<ul>
<ul>
Line 296: Line 295:
<li><pre>
<li><pre>
-
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-omap1 oldconfig
+
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-maemo2 oldconfig
# lots of output here. Answer Y to NFSD_V3, default to others.
# lots of output here. Answer Y to NFSD_V3, default to others.
-
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-omap1 modules
+
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-maemo2 modules
</pre></li>
</pre></li>
Line 317: Line 316:
</ul>
</ul>
-
The list of .ko files is quite long, depending on whether or not some additional changes were made to the .config file. Module <code>nfsd.ko</code> is the one just added.
+
The list of .ko files is quite long, depending on whether or not some additional changes were made to the .config file. Module nfsd.ko is the one just added.
The kernel modules are kept under <code>/lib/modules/</code>. However, the <code>insmod</code> command can be used to load the modules into the running kernel from any directory they have been saved in.
The kernel modules are kept under <code>/lib/modules/</code>. However, the <code>insmod</code> command can be used to load the modules into the running kernel from any directory they have been saved in.
-
 
-
== Using make menuconfig ==
 
-
 
-
'make menuconfig' fails to autodetect the ncurses library available in Scratchbox and exits with an error.  If you want to use 'make menuconfig', first edit <code>scripts/kconfig/lxdialog/check-lxdialog.sh</code> and change
 
-
 
-
<pre>
 
-
# What library to link
 
-
ldflags()
 
-
{
 
-
for ext in so a dylib ; do
 
-
</pre>
 
-
 
-
to
 
-
 
-
<pre>
 
-
# What library to link
 
-
ldflags()
 
-
{
 
-
# XXX autodetection fails in scratchbox
 
-
echo -lncurses
 
-
exit
 
-
for ext in so a dylib ; do
 
-
</pre>
 
== Flashing Kernel ==
== Flashing Kernel ==
-
You can flash the custom kernel from outside Scratchbox with the flasher tool using USB.
+
The custom kernel can be flashed from outside the Scratchbox with the flasher tool using USB.
-
  # flasher-3.5 -f -k /scratchbox/users/&lt;username&gt;/home/&lt;username&gt;/\
+
  # flasher -f -k /scratchbox/users/&lt;username&gt;/home/&lt;username&gt;/\
  maemo_kernel/kernel-2.6.28/arch/arm/boot/zImage
  maemo_kernel/kernel-2.6.28/arch/arm/boot/zImage
-
 
-
== Testing kernel ==
 
-
 
-
It is possible to try the custom kernel without flashing it by temporarily changing arch/arm/plat-omap/bootreason.c as follows:
 
-
 
-
<pre>
 
-
// len += sprintf(page + len, "%s\n", boot_reason);
 
-
len += sprintf(page + len, "pwr_key\n");
 
-
</pre>
 
-
 
-
For the flasher tool, use
 
-
 
-
# flasher-3.5 -l -b -k /scratchbox/users/&lt;username&gt;/home/&lt;username&gt;/\
 
-
maemo_kernel/kernel-2.6.28/arch/arm/boot/zImage
 
-
 
-
[[Category:Development]]
 
-
[[Category:Documentation]]
 
-
[[Category:Fremantle]]
 

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: