# Booting process of Android devices

The booting process of Android devices starts at the power-on of the SoC (system on a chip) and ends at the visibility of the home screen, or special modes like recovery and fastboot. The boot process of devices that run Android is influenced by the firmware design of the SoC manufacturers.

## Background

As of 2018, 90% of the SoCs of the Android market are supplied by either Qualcomm, Samsung or MediaTek. Other vendors include Rockchip, Marvell, Nvidia and previously Texas Instruments.

## History

Verified boot, a booting security measure, was introduced with Android KitKat.

## Stages
### Primary Bootloader

The Primary Bootloader (PBL), which is stored in the Boot ROM is the first stage of the boot process. This code is written by the chipset manufacturer.
The PBL verifies the authenticity of the next stage.
On Samsung smartphones, the Samsung Secure Boot Key (SSBK) is used by the boot ROM to verify the next stages.
On SoCs from Qualcomm, it is possible to enter the Qualcomm Emergency Download Mode from the primary bootloader.
If the verification of the secondary bootloader fails, it will enter EDL.

### Secondary Bootloader

Because the space in the boot ROM is limited, a secondary bootloader on the eMMC or eUFS is used. The secondary bootloader initializes TrustZone.
On the Qualcomm MSM8960 for example, the Secondary Bootloader 1 loads the Secondary Bootloader 2. The Secondary Bootloader 2 loads TrustZone and the Secondary Bootloader 3.
The SBL is now called XBL by Qualcomm and which is an UEFI implementation.
Qualcomm uses LK (Little Kernel) plus Aboot, or XBL (eXtensible Bootloader) plus ABL; Samsung Exynos uses S-Boot; MediaTek uses Das U-Boot. Little Kernel is a microkernel for embedded devices, which has been modified by Qualcomm to use it as a bootloader. The Android Bootloader (Aboot or ABL), which implements the fastboot interface. Android Bootloader verifies the authenticity of the boot and recovery partitions. By pressing a specific key combination, devices can also boot in recovery mode. Android Bootloader then transfers control to the Linux kernel.

### Kernel and initramfs

The initramfs is a gzipped cpio archive that contains a small root file system. It contains init, which is executed. The Android kernel is a modified version of the Linux kernel. Init does mount the partitions. dm-verity verifies the integrity of the partitions that are specified in the fstab file. dm-verity is a Linux kernel module that was introduced by Google in Android since version 4.4. The stock implementation only supports block based verification, but Samsung has added support for files.

### Zygote

Zygote is spawned by the init process, which is responsible for starting Android applications and service processes. It loads and initializes classes that are supposed to be used very often into the heap. For example, dex data structures of libraries. After Zygote has started, it listens for commands on a socket. When a new application is to be started, a command is sent to Zygote which executes a fork system call.

## Partition layout

The Android system is divided across different partitions.
The Qualcomm platform makes use of the GUID partition table. This specification is part of the UEFI specification, but does not depend on UEFI firmware.