[Asus Transformer TF700] cogano:
ASUS TF700t multi-boot Linux and Android - step by step for kexec w/ explanatory info

EDIT: While some of the linked host kexec blob, guest os kernels and installers are obsolete now, the background information remains valid. For most up-to-date links (rootfs, installer) check out the original post in this thread.

===

I have spent some time gathering and trying to understand the info, it might be usefull for others. At the moment, I do not plan to keep it updated and therefore I do not open a new thread. However, should there be anything wrong or misleading, I will be glad to correct it.

=== Steps for Stock ROM (or Cromi-X v3.x or 4.x or 5.x) ===

Steps 2 to 4 are to be done on your computer (preferably in Linux OS). It is assumed that you can do some basic stuff like creating partitions and file systems, mounting them, using command line interface and man pages, boot your tablet to Recovery, etc. The links in the square brackets refer to files for download. The text in curly brackets refers to the device name (partition) - depending on your setup, the partitions may be mounted in different places in the file system - hence that's your task to identify the actual mount point.

Plug-in the microSD card and create a Linux partition (of cca 5 GB or more) and format it as ext4. Mount the partition (lets say to /media/microsd).

[ http://www.lugotfl.org/tf700t/rootfs-lubuntu-tf700t-8-22-2013.tar.lzma ] Unpack rootfs-lubuntu-tf700t-8-22-2013.tar.lzma to the partition on microSD card:

# tar -xvf rootfs-lubuntu-tf700t-8-22-2013.tar.lzma -C /media/microsd

[ https://www.dropbox.com/sh/32aupv891apenlc/u4GJelDNQ3 ] Extract contents of _that-linux-kexec.zip (zImage and initrd.img) to /media/microsd/boot.

Now unmount the microSD card and plug it in TF700t. The following steps are to be done on the tablet.

[ https://www.dropbox.com/s/0q01ijw1vkbokw1/installerV6.8.zip ] From Recovery, run "Installer V6.8". See == Installer == section for more info. During the installation, skip creating rootfs.img file to save some time. Then, reboot to Android.

[ https://www.dropbox.com/sh/32aupv891apenlc/u4GJelDNQ3 ] Extract _that-android-kexec.zip (zImage and initrd.img) to {/dev/block/mmcblk0p1}/system/boot (create the directory boot if it does not exist).

Create and edit multiboot config file in {/dev/block/mmcblk0p5}/multiboot/boot.cfg to include existing OSes (see == mutliboot/boot.cfg == section below).

[ https://www.dropbox.com/sh/32aupv891apenlc/u4GJelDNQ3 ] Flash host/blob (compressed kexec-boot-from kernel and ramdisk) to the tablet's staging partition:

# dd if=host/blob of=/dev/block/mmcblk0p4

Reboot: the kexec kernel spits typical Linux messages during boot and eventually﻿ you should see a list of systems to boot from (as per multiboot/boot.cfg).

Later, you can just do the steps 7, 8 and 9 quite independently (e.g. to test various kernels, ramdisks or Linux distributions).

If you happen to re-flash a new Android ROM, chances are that the host kexec kernel and guest kexec Android kernel will be overwritten and multiboot disabled. In such a case, run the "Installer" again and redo the later steps, too.

== Installer ==

Responsible for unpacking the linux rootfs image to a virtual container (img file) and setting up kernel (+ initrd) to the update staging partition /dev/block/mmcblk0p4 and possibly some other stuff. Takes care also about setting up "multiboot" environment. [?? I am not really sure what extra stuff is done by the Installer - is that really neccessary for kexecboot ??]

Note that after the first reboot, the contents of the staging partition (mmcblk0p4) is copied by bootloader to the hidden boot area on the internal emmc storage. (The boot area has no entry in GPT - hence it is not a typical disk partition per se. For more details regarding the staging partition and how the binary blobs are to be prepared, see _that's explanation here). With the help of a patched kernel, the hidden boot area may be listed as mmcblk0p10 partition.

The currently available versions (up to V 6.8) are not aware of kexecboot and will overwrite whatever kernel and ramdisk exists for the Android ROM with a simple init.d kernel. This installer requires rootfs.tar.lzma to be placed at /data/media (in Android) - at least for the Cromi-X 5.x Android I use.

If you want to boot Linux rootfs from a directory (as per above tutorial), you can skip the unpacking of the tar.lzma file by the Installer and do it later manually on your PC (it is way faster to untar the tar.lzma directly to the micro SD card on your computer than doing so in Android in multiple steps, i.e. unpacking to rootfs.img, mounting it on a loopback and copying over to micro SD card).

== Kexecboot for TF700t ==

There are multiple implementation of multiboot for Asus TF700t, the kexecboot being the most flexible, though more difficult to setup.

The booting process is as follows:

the bootloader loads kernel (zImage) and ramdisk (initrd.img) from the hidden boot area on emmc;

the ramdisk includes a kexecboot binary, which looks for configuration file at {mmcblk0p5}/multiboot/boot.cfg;

this configuration file tells the kexecboot binary some basic information about available operating systems (Android, Linux) - where to find kernel, initrd, rootfs. The boot.cfg has to be created manually;

once the user makes his choice, kexecboot loads the new kernel and after "soft-boot" continues with loading ramdisk and eventually the booting process continues as usual.

Both host (kexec-boot-from) and guest (kexec-boot-to) kernels must support kexec. Some kernels are universal and provide both functions.

The binary blob used as a host kexec kernel ("boot image") cannot be easily mounted and special tools must be used to exctract the kernel and ramdisk so that they can be replaced and then re-compressed again to the boot image.

Some kernels may be used both for host kexec or guest kexec, just make sure to keep the original ramdisk (initrd.img) for the host kexec, which includes the kexecboot binary.

== mutliboot/boot.cfg ==

In the multiboot kexec environment, the list of available operating systems for soft-booting is placed at {/dev/block/mmcblk0p5}/multiboot/boot.cfg:

LABEL=Android

BOOT=3

DEVICE=/dev/mmcblk0p1

DIR=/

KERNEL=/boot/zImage

INITRD=/boot/initrd.img

PRIORITY=100

LABEL=Lubuntu 13.04

BOOT=3

DEVICE=/dev/mmcblk1p1

DIR=/

KERNEL=/boot/zImage

INITRD=/boot/initrd.img

PRIORITY=50

# Example of booting from rootfs container

#LABEL=Ubuntu

#BOOT=7

#DEVICE=/dev/mmcblk0p8

#IMAGE=/linux/ubuntu.img

#KERNEL=/boot/zImage

#INITRD=/boot/initrd.img

#PRIORITY=40

where

BOOT=3 is magic number for booting from a directory and BOOT=7 is magic number for booting from rootfs container;

DEVICE is path to the partition, on which the rootfs exists; the path uses notation of Linux kernel (/dev/block_device) and not Android kernel (/dev/block/block_device);

IMAGE is absolute path to the rootfs container on the given DEVICE;

DIR is absolute path on the given DEVICE to the "root" of the extracted rootfs;

KERNEL and INITRD are absolute paths to kernel and ramdisk (from the view point of mounted rootfs);

PRIORITY sets the order of the list (higher the number, higher on the list).

Note that once Android is booted, the /boot directory is actually mounted to /system/boot. This is because mmcblk0p1 is mounted to /system in Android and not to / (root).

== Partition layout related to this tutorial==

mmcblk0p1 is an ext4 formatted partition (500 MB) for Android ROM (/system);

mmcblk0p4 is a staging partition for boot or recovery updates;

mmcblk0p5 is a vfat formatted partition (5 MB) used for device configuration files etc (/misc);

mmcblk0p8 is an ext4 partition used to store user data etc (/data);

mmcblk1p1 is the first partition of external microSD card inserted to the slot on tablet. In this tutorial, this is where the linux root file system is extracted to.

For a complete layout of partitions and other data on the internal emmc storage, see this post.

== end ==

Thanks to all the devs for the hard work and contributions.