Android Boot Process

Android Boot Process

Android is a software stack that includes operating system, middle ware, applications for the development of devices. Android has evolved greatly and user experience in addition to consumer level efficiency along with integration of android powered devices also expanded. Because of its promising features and characteristics like open source nature, rich user interface, consistent app API's. Android is being integrated and ported to various embedded devices this includes enterprise desktop IP phones, cameras, modem, sensors, and set-up boxes, automotive.

One major advantage of using android framework beyond the mobile devices is the android applications can talk to the functionality of all these devices powered by android and developers need not to write several applications for different embedded systems.

When switching off the power of the Android device and switch on it again, this process is known as the Android Booting sequence.

No alt text provided for this image

The image above shown 6 Steps of booting process for an Android-powered device:

  1. Boot Room
  2. Bootloader
  3. Linux Kernel (Androism)
  4. Init
  5. Zygote and Dalvik Virtual Machine DVM
  6. SystemServer and Managers

Boot ROM and Bootloader

When power starts, Boot ROM code start execution from predefined location i.e. ishard wired on ROM. It load Bootloader into RAM and start execution.

Bootloader is small program which runs before Android operating system running. Bootloader is first program to run so It is specific for board and processor. It perform execution in two stages:

  1. First stage It to detect external RAM and load program which helps which.
  2. In second stage, bootloader setup network, memory, etc. which requires to run kernel, bootloader is able to provide configuration parameters or inputs to the kernel for specific purpose.

The bootloader is located under <android source>/bootable/bootloader/legacy/usbloader in the Android Code Source Project AOSP. This legacy loader contains 2 important files:

1- Init.s : Initializes stacks, zeros the BSS segments and call_main() in main.c

2- Main.c : Initializes hardware (clocks, board, keyboard, console) and creates Linux tags

Android Kernel

Android kernel start similar way as desktop Linux kernel starts, as kernel launch it start setup cache, protected memory, scheduling, loads drivers. When kernel finishes system setup first thing it look for “init” in system files and launch root process or first process of system.

Init Process

It very first process, we can say it is root process or grandmother of all processes. Init process has two responsibilities

1. Mount directories like /sys, /dev, /proc

2. Run init.rc script.

The init process can be found at /init :: <android source>/system/core/init

Init.rc file can be found at :: <android source>/system/core/rootdir/

Android has a specific format and rules for init.rc files. At this stage, We can finally see the Android logo on our device screen.

Zygote and Dalvik

We know that separate Virtual Machine (VMs) instance will pop up in memory for separate per app in JAVA but in Android app should launch quick as possible. If Android OS launch different instance of Dalvik VM for every app then it consume lots of memory and time. So, to overcome this problem Android OS has“Zygote”. Zygote enable shared code across Dalvik VM, lower memory footprint and minimal startup time. Zygote is a VM process that starts at system boot time as we discussed in previous step. Zygote preloads and initializes core library classes. These are three core classes which are read-only and part of Android SDK or Core frameworks.

SystemServer and Managers

After completion of all steps runtime request Zygote to launch system servers. These are written in both native and java. The System servers in JAVA can consider as process as the same system server is available as System Services in Android SDK. Zygote fork new process to launch system services and we can see source code in Zygote Init class and “start System Server” method.

As System Services starts up and running in memory, Android has completed booting process and “ACTION_BOOT_COMPLETED” standard broadcast action will fire.

I hope you enjoyed this article. If you have any comments or questions feel free to contact me.

Thanks for the support!



要查看或添加评论,请登录

社区洞察

其他会员也浏览了