Skip to content

Android Boot Process

Android Boot Process

Questions:

  • What happens on starting your mobile phone?
  • Which process starts first?
  • where does the kernel reside?
  • Role of internal and external RAM
  • Which process is responsible for initialising RAM
  • Which process is responsible for loading the kernel into external RAM?

When Android device is first powered on, these is a sequence of steps that are executed , helping the device to load necessary firmware, OS, application data and so on into memory
Sequence of Steps is as follows:

  1. boot ROM code execution
  2. Boot loader
  3. Linux kernel
  4. init process
  5. Zygote and Dalvik
  6. System server
  7. Launcher

Step 1-2 are common in all Linux kernel but modified slightly for Android
4 to 7 are Android specific

1.Boot ROM Code Execution

Boot ROM code is small code present in SoC (System on Chip)

  • Hardcoded by chip manufacturer and cannot be modified(Read-only)

Functions:

  1. Initialise necessary hardware
  2. Scan and find Boot Media

    Boot media has
    
  3. Boot code

  4. File system
  5. Kernel code

Steps

  • Boot code contains boot sequence that tells from where to start and the next steps to be performs
  • As soon as boot sequence is found, executions move to boot loader
  • Boot loader copied to the internal RAM (part of CPU)
  • Execution shifts to code loaded into the internal RAM

2.Boot Loader

Boot loader is a piece of program that is executed before the OS starts to function and finds the kernel and loads it
2 stages in Andoird boot loader:

  1. Initial Program Load (IPL)
  2. Second Program Load (SPL)

[Diagram — add to assets/ if available]

IPL

Function:

  1. Detects and sets up external RAM
  2. Copies SPL into external RAM

Primary bootloader
- initalises h/w

  • Detect and setup external RAM & copies secondary bootloader into external RAM

SPL

Secondary bootloader loads Android OS

  1. Locates Linux kernel in boot media
  2. Once, located - Decompresses the image
  3. Loaded into external RAM

Get access to boot modes like fastboot, recovery etc

3. Linux Kernel

It is the heart of Andoird OS and is responsible for process management, memory management and enforcing security on the device

Functions:
After kernel is loaded, it

  • Mounts root file system (rootfs)
  • Provides access to system resources

When memory management units and cches have been initialized, the system can use virtual memory and launch user space processes

Kernel will look in the rootfs for the init process and launch it as the initial use space process

4. Init Process

Init process looks for a script named `init.rc` that describes the system services, file system and any other parameters that need to be setup

Init process parses init.rc script and launch system service processes. At this stage, you will see Android logo on device screen

5. Zygote and Dalvik

  • Zygote is one of the first init processes created after the device boots
  • Zygote initializes Dalvik virtual machine and tries to create multiple instances to support each android process
  • DVM in the the vm which executed android application written in JAva
  • Zygote facilitates using a shared code across the VM thus helping to save memory and reduce the burden on the system
  • Every new app can request for a new DVM

In ART(Andoird Run TIme) (since Android 5),

  • Each app runs in its own Linux process with an ART runtime instance
  • Zygote initializes ART runtime environment and foreks ART-enabled processes

6. System Server

All cores features of the device like telephony, network, and other important functions are started by system server

The following core services are started in this process:

  1. Start Power Manager
  2. Create Activity Manager
  3. Start Telephony REgistry
  4. Start Pakage Manager
  5. Set activity Manager
  6. Set activity manager as system process start
  7. Context manager
  8. Start system context providers
  9. Start battery service
  10. Start alarm manager
  11. Start sensor service
  12. Start window manager
  13. Start bluetooth service etc

After this, system sens broadcast action calle ACTION_BOOT_COMPLETED which informs all the dependent processes that the boot process is complete

After this, device displays the home screen and is ready to interact with the user

Now the device displays home screen and is ready to interact with the user