Android Booting

The bootup of an Android system consists of several phases, which are outlined here.

Bootloader
The first program which runs on any Android system is the bootloader. Technically, the bootloader is outside the realm of Android itself, and is used to do very low-level system initialization, before loading the Linux kernel. The kernel then does the bulk of hardware, driver and file system initialization, before starting up the user-space programs and applications that make up Android.

Often, the first-stage bootloader will provide support for loading recovery images to the system flash, or performing other recovery, update, or debugging tasks.

The bootloader on the ADP1 detects certain keypresses, which can be used to make it load a 'recovery' image (second instance of the kernel and system), or put the phone into a mode where the developer can perform development tasks ('fastboot' mode), such as re-writing flash images, directly downloading and executing an alternate kernel image, etc.

'init'
A key component of the Android bootup sequence is the program 'init', which is a specialized program for initializing elements of the Android system. Unlike other Linux systems (embedded or otherwise), Android uses its own initialization program. (Linux desktop systems have historically used some combination of /etc/inittab and sysV init levels - e.g. /etc/rc.d/init.d with symlinks in /etc/rc.d/rc.[2345]). Some embedded Linux systems use simplified forms of these -- such as the init program included in busybox, which processes a limited form of /etc/inittab, or a direct invocation of a shell script or small program to do fixed initialization steps.

The Android 'init' program processes two files, executing the commands it finds in them, called 'init.rc' and 'init..rc', where  is the name of the hardware that Android is running on. (Usually, this is a code word. The name of the HTC1 hardware for the ADP1 is 'trout', and the name of the emulator is 'goldfish'.

The 'init.rc' file is intended to provide the generic initialization instructions, while the 'init..rc' file is intended to provide the machine-specific initialization instructions.

'init' resources
The syntax for these .rc files is documented in a readme file in the source tree. See the Android init language reference

Or, see also: http://www.kandroid.org/android_pdk/bring_up.html

See also http://www.androidenea.com/2009/08/init-process-and-initrc.html

firmware

 * first-stage bootloader runs
 * it detects if a special key is held, and can launch the recovery image, or the 'fastboot' bootloader
 * eventually, a kernel is loaded into RAM (usually with an initrd)
 * normally, this will be the kernel from the 'boot' flash partition.

kernel

 * the kernel boots
 * core kernel initialization
 * memory and I/O areas are initialized
 * interrupts are started, and the process table is initialized
 * driver initialization
 * kernel daemons (threads) are started
 * root file system is mounted
 * the first user-space process is started
 * usually /init (note that other Linux systems usually start /sbin/init)

user space

 * the kernel runs /init
 * /init processes /init.rc and /init..rc
 * dalvik VM is started (zygote). See Android Zygote Startup
 * several daemons are started:
 * rild - radio interface link daemon
 * vold - volume daemon (media volumes, as in file systems - nothing to do with audio volume)
 * the system_server starts, and initializes several core services
 * See http://www.androidenea.com/2009/07/system-server-in-android.html
 * initalization is done in 2 steps:
 * 1) a library is loaded to initialize interfaces to native services, then
 * 2) java-based core services are initialized in ServerThread::run in SystemServer.java
 * the activity manager starts core applications (which are themselves dalvik applications)
 * com.android.phone - phone application
 * android.process.acore - home (desktop) and a few core apps.
 * other processes are also started by /init, somewhere in there:
 * adb
 * mediaserver
 * dbus-daemon
 * akmd

Tools for analyzing Android Bootup

 * Bootchart - see Using Bootchart on Android

Overview
See "Android Initialization Process" at: http://blog.chinaunix.net/u2/85805/showart_1421736.html

strace
http://benno.id.au/blog/2007/11/18/android-runtime-strace

Interaction of different processes on application initialization
Talking about Android Process - http://blog.csdn.net/mawl2002/archive/2009/06/24/4295905.aspx

Improving Bootup Time presentation
See Improving Android Boot Time - notes and material for a talk at LinuxCon North America, 2010 by Tim Bird

1-second boot of Android
Ubiquitous Corporation has announced boot of ARM-based Android system in 1 second. Actually, it's more like a suspend and resume than a boot. See http://www.linuxfordevices.com/c/a/News/Ubiquitous-QuickBoot/?kc=LNXDEVNL032410 [March, 2010]