Install a new kernel on Greenphone

From GreenphoneWiki

Jump to: navigation, search

Contents

[edit] Status

So far I managed compiling the kernel and the modules, but there are still a few things left.

[edit] Preparation

In order to compile the gcc version needed for crosscompiling, you probably need to downgrade your gcc-version, since the old version cannot be bootstrapped from new versions.

I installed gcc-3.4.4-r1 (compiled with gcc-4.1.1). As I read (I did not confirm that), you need to downgrade to a version prior to 3.5.x.

[edit] Create a cross-compiler

Get crosstool and unpack it to a directory of your choice. The create a directory /opt/crosstool and make sure your regular user can write to it. Also create a directory downloads under the crosstool source directory.

Edit demo-arm.sh so that it reads as:

#!/bin/bash
# This script has one line for each known working toolchain
# for this architecture.  Uncomment the one you want.
# Generated by generate-demo.pl from buildlogs/all.dats.txt

set -ex
TARBALLS_DIR=`pwd`/downloads
RESULT_TOP=/opt/crosstool
export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.
mkdir -p $RESULT_TOP

eval `cat arm.dat gcc-3.2.3-glibc-2.3.2.dat` sh all.sh --notest

echo Done.

Execute unset LD_LIBRARY_PATH followed by ./demo-arm.sh.

[edit] Extract the original initrd

First, extract the kernel sources to a directory of your choice. Then execute in that directory

tar xfz /opt/Qtopia/extras/images/qtopia-greenphone-flash zImage_Truly_Trolltech
dd if=zImage_Truly_Trolltech skip=11340 bs=1 | gzcat > Image
dd if=Image skip=50176 bs=1 of=initrd.bin
cp initrd.bin init/

This assumes, that you are using version 4.1.7 of the SDK. For other versions, the offsets could differ.

The Qtopia 4.2.1 opensource package has the code required to build the initrd.bin file (devices/greenphone/rootfs/initrd). There has been no changes to the initrd.bin file since 4.1.7 so it is safe to build initrd.bin from 4.2.1 and use it with the 4.1.7 kernel.

[edit] Prepare the kernel

Edit Makefile and change CROSS_COMPILE to

CROSS_COMPILE   = /opt/crosstool/gcc-3.2.3-glibc-2.3.2/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-

I also modified arch/arm/Makefile and replaced -mshort-load-bytes by -malignment-traps, but I am not sure, whether this is needed with gcc-3.2.3 (I first used another version).

[edit] Compiling the kernel

To actually compile the kernel, do the following:

make greenphone_config
make oldconfig
make dep
make zImage
make modules
mkdir modules
make modules_install INSTALL_MOD_PATH=`pwd`/modules

This creates the zImage in arch/arm/boot/ and the modules beneath modules.

[edit] Install the new Kernel

You need to create a file that usbflash can read. Prepare a flash.conf file as follows:

kernel:zImage:2:7c3149586cb17648031a5e334844ca56

The first field is a display name only. The second field is the name of the kernel file. The third field lets the bootloader know you're flashing a kernel and the last field is the md5sum of the kernel file.

Next you should tar up the flash.conf file and the kernel.

tar czf kernel.tgz flash.conf zImage.

Then flash it to your Greenphone.

./usbflash kernel.tgz

Note that there is only 1M of space (exactly 0x00100000 bytes) for the kernel on the Greenphone so if you want extra stuff you should try to build it as modules. If you flash a kernel that is too big it will be truncated.

There is no danger of permanent damage when you flash a new kernel. Obviously you may render the device unable to boot but you will be able to flash a new kernel.

If you enable new modules you'll need to ensure they're on the root filesystem.

[edit] Replace the splash screen

The splash screen is displayed from drivers/video/pxafb.c. It literally expects an array of bytes that it can memcpy() to the framebuffer.

IMHO the easiest way to produce a new image is to create a .gif file of the required size, run gifanim on the phone and then dd the framebuffer to a file.

$ telnet greenphone
# killall qpe
# /usr/local/bin/gifanim /mnt/sd/mylogo.gif
# dd if=/dev/fb0 of=/mnt/sd/bytes.raw
300+0 records in
300+0 records out

The following perl script will take the raw bytes and turn them into the structure the kernel source expects.

#!/usr/bin/perl
use strict;
use warnings;
my $file = shift(@ARGV) or die "Must specify a file";
open IN, $file or die "Can't read $file";
my @data = <IN>;
close IN;
my $data = join("", @data);
my $length = length($data);
if ( $length != 153600 ) {
    die "There must be 153600 bytes!";
}
print "const unsigned char gImage_logo[$length] = {\n";
my $loop = 0;
for ( my $i = 0; $i < $length; $i++ ) {
    my $byte = ord(substr($data, $i, 1)) & 255;
    printf("0X%02X,", $byte);
    if ( ++$loop == 16 ) {
        $loop = 0;
        print "\n";
    }
}
print "};\n";

Save the output to a .h file and include it from pxafb.c (instead of logo_trolltech.h). Note that the dependencies in the Makefile don't extend to the included header so if you change it you will need to manually touch pxafb.c or you won't get a new logo.

# update logo_mylogo.h
touch drivers/video/pxafb.c
make zImage

Rebuild the kernel, flash it and enjoy your new splash screen.

[edit] TODO

Be sure to include the other modules as well:

  • docparatable.o
  • hsav_detect.o
  • mmc_omega.o
  • omega_alarm.o
  • omega_bcm2121.o
  • omega_bt.o
  • omega_chgled.o
  • omega_kpbl.o
  • omega_pmu.o
  • omega_power.o
  • omega_poweroff.o
  • omega_rtcalarm.o
  • omega_spi.o
  • omega_vibrator.o
  • omega_wdadaemon.o
  • s1d19120.o

Also there are some interesting things in the test directory.

Personal tools