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:
- boot ROM code execution
- Boot loader
- Linux kernel
- init process
- Zygote and Dalvik
- System server
- 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:
- Initialise necessary hardware
-
Scan and find Boot Media
Boot media has -
Boot code
- File system
- 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:
- Initial Program Load (IPL)
- Second Program Load (SPL)
[Diagram — add to assets/ if available]
IPL¶
Function:
- Detects and sets up external RAM
- 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
- Locates Linux kernel in boot media
- Once, located - Decompresses the image
- 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:
- Start Power Manager
- Create Activity Manager
- Start Telephony REgistry
- Start Pakage Manager
- Set activity Manager
- Set activity manager as system process start
- Context manager
- Start system context providers
- Start battery service
- Start alarm manager
- Start sensor service
- Start window manager
- 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