In previous and very first post of the blog, I told you about the booting process of Linux, here comes the Android as well! Android is an open source mobile operating system developed by Google Inc. and is based and operates on Linux kernel. There is a difference, Linux kernel is based on x86 architecture but almost all Android phones now are running on ARM architecture (Advanced RISC Machines) except Intel Xolo 900 which runs on Atom 1.6 GHz x86 processor.
- Boot ROM: When you power ON the Android phone, no initializations have been made. The only memory available is internal ROM. In its very first time, the processor executes a code called Boot ROM which is hardwired in the internal ROM. It is responsible for resolving the boot media and loading the bootloader from boot media. Bootloader is a component which initializes the DRAM and load another stages for booting.
- BL0/uBoot: Here comes the first stage or level of bootloader. It is responsible for determining and reading the boot image (kernel) and ramdisk (file system).
- Kernel: Kernel is the core of any operating system, which is responsible for booting the operating system and manage everything else. Android is based on Linux kernel. Kernel (sometimes referred as boot image ) can be a compressed or decompressed boot image. When kernel is loaded in memory, it creates and mounts the rootfs (root file system).
The kernel executes a script called boot image (which is located in the ramdisk), init , as its name suggest (initialize or, initialization), configures the rest of the process for booting and to setup the environment for the user. It is the very first process started by the kernel. In Android, init mounts the directories like /proc , /sys , /dev etc. and run the init.rc script. Android has its own specific format for its init.rc script which is also explained in the latter part of this guide.
The init.rc language of Android has mainly for parts:
- Actions: Actions are the sequence of commands to be executed. It consist of a trigger which tells when a action should be executed, for example: early-init, init, boot, fs, post-fs etc. Syntax :
- Services: Services (sometimes referred as daemons) are the programs that are to be executed when the init process starts.Syntax:
- Options: The options tells how and when the init runs the services.
The init.rc file is located in the root directory of any Android phone and looks like this (your may be different):
mount rfs /dev/stl9 /system check=no
mount rootfs rootfs / ro remount
service installd /system/bin/installd
socket installd stream 600 system system
- Zygote and dalvik: The zygote initializes the Dalivik VM and forks to create multiple instances to support each android process. It facilitates using a shared code across the VM instances resulting in a low memory foot print and short load time, ideal for an embedded system. Zygote apart from installing a listener on the server socket, also preloads classes and resources to be used later in the Android applications. Once done, the system server is started.
- System services: Sometimes referred as SystemServer, initializes and starts all the services on a Android phone. Some of the core services and other services have been mentioned below:
- ACTION_BOOT_COMPLETED: As soon as all the services are up and running, the Android broadcasts a ACTION_BOOT_COMPLETED message which is the end of the booting process of Android.
That was all how any Android phone boots up, please do a comment if you have any query!