Compiling the kernel
This is an article from the old midgard wiki that hasn't yet been fully updated for this wiki, please update it. Please see the talk page for discussion. |
NOTE : THIS ARTICLE IS ONLY PARTLY UPDATED - DON'T EXPECT IT TO WORK.
This document describes how a 3rd party developer can compile, modify, and deploy the Linux kernel if (s)he really wants to. However, the first thing to consider is whether a custom kernel is really needed. Most additional functionality can be provided with modules dynamically loaded into the original kernel provided by Nokia. Modules may be both easier for you to create and easier for users to install on their devices. It is only if your change conflicts with the original Nokia configuration, or if the new feature cannot be compiled as a module, that a new kernel is needed.
First see: http://maemo.org/maemo_release_documentation/maemo4.1.x/node12.html
If you choose to compile only additional modules, then use the original Nokia configuration as a base and enable new functionality as modules. Make sure you use a compiler compatible with the one used for the original kernel (currently GCC 3.4), otherwise your modules may produce errors when inserted into the kernel. The best method may be to use exactly the same GCC version. See /proc/version on your device for this. Alternatively, use the GCC version suggested in Section 2.
If you choose to make a new kernel, Section 2 describes the compilation procedure, Section 3 the modification procedure, and Section 4 the deployment procedure. The final section of this document lists issues that should be taken into account when working with the kernel and Maemo.
Contents |
[edit] Modifying Default Kernel Configuration
In order to modify the default kernel configuration, a few things need to be done. Assuming that the kernel has been built at least once, perform the following procedure to build a modified kernel for Maemo:
1. Edit ~/maemo-kernel/kernel-source-diablo-2.6.21/debian/rules so that modifications may be done.
Make sure the following two lines are commented out or removed completely:
- build-stamp section: tar jxf /usr/src/kernel-source-$(SOURCE_VERSION).tar.bz2
- clean section: rm -rf kernel-source-$(SOURCE_VERSION)
2. Change file permissions for default config file.
$ chmod a+w ~/maemo-kernel/kernel-source-diablo-2.6.21/kernel-source/arch/arm/configs/n770_defconfig
3. Make your modifications to ~/maemo_kernel/kernel-source-diablo-2.6.21/kernel-source/arch/arm/configs/n770_defconfig
4. Recompile the kernel image:
$ cd $ dpkg-buildpackage -rfakeroot -uc -us -sa -d
5. Install the kernel image in Scratchbox target
$ fakeroot dpkg -i ../su-18-kernel_*.deb
[edit] Menuconfig
to
make menuconfig
you need to edit kernel-source/scripts/kconfig/lxdialog/check-lxdialog.sh and in the ldflags() function add these lines:
ldflags() { + echo '-lncurses' + exit $cc -print-file-name=libncursesw.so | grep -q / if [ $? -eq 0 ]; then
[edit] Things to Remember When Working with Linux Kernel and Maemo
Below is a list of things that should be taken into consideration when working with the Linux kernel and Maemo.
[edit] Modules and Initfs
Your kernel image must be compatible with the modules in the initfs image on the device. If you flash a custom kernel image that is incompatible with the modules in initfs, you may see constants reboots. This can be fixed either by making the kernel compatible (use same or very similar gcc compiler and kernel configuration) or by rebuilding the initfs image with your version of modules. For a list of essential modules see: /lib/modules/current in the initfs image or /mnt/initfs/lib/modules/current directly on the device. Also, if you enabled some additional functionality as modules, you may need to copy them manually to the initfs on the device (if there is free space) or put them somewhere in the root filesystem of the device.
[edit] Kernel Partition Size
The size of the kernel partition on the device is limited. When enabling additional features to be compiled directly into kernel the image may quite easily exceed the size of the partition and thus flashing an oversized image to the kernel partition may render the device useless. It is advised to use modules as much as possible to keep kernel size down and prevent this from happening. If this happens, see next item.
[edit] What To Do When Flashing Breaks the Device
For example, flashing an oversized kernel image renders the device useless. In order to get the device working again, select one of the following two options.
[edit] Flash Kernel Image from maemo.org
You can install a fully working kernel image by installing the su-18-kernel image available on maemo.org. Issue the following command in Scratchbox:
$ apt-get install su-18-kernel
After this, flash the kernel image as instructed in Section 4.
[edit] Flash from Fiasco Image
The other way around the problem is to install the latest Fiasco image available from Nokia Support or maemo.org downloads. Please see this How To Flash from Linux How To for more information how to do this. You can use flasher to unpack firmware *.bin image and flash only kernel or initfs or both.
[edit] Serial Console
When hacking the kernel, you may need the serial console. You may have noticed an 11 pins conector (pad) in the battery compartment of the device:
1-2-3-4-5-6 -7-8-9-A-B-
Pin 9 is RxD (Nokia receive input) and pin A is TxD (Nokia transmit output). Pin 8 and 3 are the ground. The outputs are evidently 3.3v - Some used a USB-mobile phone cable as described in and to connect to the device.
On the N800 this connector contains only 7 pins and it located near the battery. Pin 7 is RxD (Nokia receive input) and pin 6 is TxD (Nokia transmit output). Pin 3 and 4 are the ground. It looks like pin 5 is connected to the battery over current indicator.
1 5 2 6 3 7 4
There is another 4 Pin connector nearby, on both the n800 and n810. those are related to usb.(we did get some bus reset signals when playing with them)
1 2 3-4
Once your done with your cable, enable the R&D mode and set the serial console flag and connect via 8N1,115200.
$sudo ./flasher --enable-rd-mode --set-rd-flags=serial-console Password: Suitable USB device not found, waiting USB device found found at bus 002, device address 011 Found board Nokia 770 (F5) NOLO version 0.9.0 The device is now in R&D mode Set R&D flags: 0010
- This page was last modified on 16 February 2016, at 17:06.
- This page has been accessed 63,077 times.