ModifyCasper

Background

As part of the blueprint mobile-lucid-une-casper-speedup Casper had to be changed to enable time stamping information. To do this one needs to change the initramfs but the steps to do so are not that well documented for ARM based devices. Below you will find a method to recreate the initramfs and flash the kernel so our target device, a Freescale iMX51 board, can be booted with the new initramfs.

Adding binaries to the Initramfs

One reason a new initramfs may be needed is if a binary needs to be added. If you need to use a binary early on in the boot process but it isn't one of the very limited ones shipped with the Initramfs image, you will need to add it. This is because the binaries in the initramfs are just there to get the early stage boot going. After that a squashfs is used populate the image with the more commonly components.

Casper Hooks

To add a binary to the initramfs a hook needs to be created in the /usr/share/initramfs-tools/hooks. This will copy the binary into the initramfs when you recreate it in a later step. In this example we will copy the 'date' command to our initramfs to facilitate timestamping.

The contents of the /usr/share/initramfs-tools/hooks/copy_date hook are:

(no space between the hash and exclamation mark on the first line, the wiki doesn't like this for some reason and I can't figure it out yet)

# ! /bin/sh
# Hook to copy /bin/date to the initramfs
set -e

PREREQ=

prereqs () {
        echo "$PREREQ"
}

case $1 in
        prereqs)
                prereqs
                exit 0
                ;;
esac

. /usr/share/initramfs-tools/hook-functions

copy_exec /bin/date /bin

copy_date needs to made executable with the following command.

sudo chmod +x /usr/share/initramfs-tools/hooks/copy_date

Create and use the new Initramfs

There are a number of steps that are needed to create the initramfs and make it work on your board. For the impatient, you can download a small script and edit the top two variables to do all this. This can be found at http://people.canonical.com/~jamiebennett/scripts/update_initramfs. A more complete explanation of the steps are as follows. Please note that the examples below use the kernel version 2.6.31-105-imx51. Your live-cd image may use a different version. Just substitute the version number and the steps should still work.

Create the Initramfs

As the initramfs has been changed we need to recreate it in the live-cd session. To do this:

sudo update-initramfs.distrib -u

This command updates the initramfs and copies it into the /boot directory.

Flash the kernel image

The next step is to reflash the kernel on the device but to do this you first need a copy of the kernel as its not including in the /boot directory of the live-cd. Fortunately it is mounted under /cdrom.

sudo cp /cdrom/casper/vmlinuz /boot/vmlinuz2.6.31-105-imx51

Another step that is needed before the kernel can be flashed is to setup a config file to tell flash-kernel important device and address information.

Create the file /etc/flash-kernel.conf containing:

fis_dev=/dev/mmcblk0
fis_offset_hex=0x40000
fis_size_hex=0x1F000

Now the kernel can be flashed.

sudo flash-kernel

Booting the live-cd compact flash in the target device should now boot the new initramfs.

ARM/ModifyCasper (last edited 2010-02-01 20:51:53 by unassigned)