Android startup process

Source: Internet
Author: User
Tags android bootloader

Android is a Linux-based open-source operating system. x86 (x86 is a series of computer microprocessor instruction set architectures based on the Intel 8086 CPU) is the most common system for Linux kernel deployment. However, all Android devices are running on ARM processors (arm originating from the advanced streamlined instruction set machine, originating from the arm architecture), in addition to Intel's Xolo devices (http://xolo.in/xolo-x900-features). The Xolo originates from the Atom 1.6GHz x86 processor. The boot process for Android devices or embedded devices or Linux-based arm devices is slightly different than the desktop version. In this article, I'll explain the startup process for Android devices. The deep Linux boot process is a good article on the desktop Linux startup process.

After you press the power switch, the Android device performs the following steps.


One of the words in Step2 in the picture is misspelled, boot loaeder should be boot Loader

First step: Power Up and system boot

When the power is pressed, the boot chip code starts to execute from a predefined place (cured in ROM). Load the bootloader into RAM and then execute.

Step Two: Boot program

The bootloader is a small program before the Android operating system starts to run. The bootloader is the first program to run, so it is specific to the motherboard and chip. Device manufacturers either use popular boot programs such as Redboot, Uboot, Qi bootloader, or develop their own boot programs, which are not part of the Android operating system. A bootloader is a place where OEMs or operators lock and restrict.

The bootstrapper executes in two phases:

    1. The first phase detects the external RAM and loads the program that is useful for the second phase;
    2. In the second stage, the boot program sets the network, memory, and so on. These are necessary for running the kernel, and in order to achieve a specific target, the bootstrapper can set the kernel based on configuration parameters or input data.

Android bootloader can be \bootable\bootloader\legacy\usbloader found in.

The traditional loader contains a file that needs to be explained here:

    1. Init.s Initialize the stack, clear 0 BBS segment, call MAIN.C's _main () function;
    2. MAIN.C Initialize the hardware (alarm, motherboard, keyboard, console) and create a Linux label.
Step Three: Kernel

The Android kernel boots up in the same way as the desktop Linux kernel. When the kernel boots, set the cache, Protected Storage, schedule list, load driver. When the kernel finishes the system setup, it first looks for the "init" file in the system files and then starts the root process or the first process of the system.

Fourth Step: Init process

Init is the first process, and we can say that it is the root process or the parent process of a process. The INIT process has two responsibilities, one is to mount the directory, such as/sys,/dev,/proc, and the second is to run the init.rc script.

    • The init process can be /system/core/init found at.
    • init.rc files can be /system/core/rootdir/init.rc found in.
    • Readme.txt can be /system/core/init/readme.txt found in.

For init.rc files, there are specific formats and rules in Android. In Android, we call the Android init language.

The Android initialization language consists of four types of declarations, actions, Commands (commands), Services (service), and options.

Action: The action is named after the command flow, and there is a trigger that determines whether the action occurs.

Services: The service is the program that the INIT process starts, and the INIT process restarts the service as appropriate when the service exits.

Options (optional)

The option is a description of the service. They affect how and when the init process starts the service.

Let's take a look at the default init.rc file. Here I only list the major events and services.

Table

Action/service Describe
On Early-init Set the INIT process and the priority of the child processes it creates, and set the security environment for the INIT process
On Init Set up the global environment to create cgroup (resource control) mount points for CPU accounting
On FS Mount MTD Partition
On Post-fs Changing the access rights of the system directory
On Post-fs-data Change the access permissions for the/data directory and its subdirectories
On boot Initialization of basic network, memory management, etc.
Service ServiceManager Start System Manager to manage all local services, such as location, audio, Shared preference, etc...
Service Zygote Start zygote as an application process

At this stage you can see the "Android" logo on the device's screen.

Fifth Step: Virtual machine

In Java, we know that different virtual machine instances allocate different memory for different applications. If Android apps should start as fast as possible, it consumes a lot of memory and time if the Android system launches different instances of Dalvik virtual machines for each application. Therefore, in order to overcome this problem, the Android system created "Zygote". Zygote makes it possible to share code, low memory usage, and minimal startup time for Dalvik VMs. Zygote is a virtual process, as we said in the previous step when booting the system. Zygote preloading and initializing the core library classes. These core classes are generally read-only and are part of the Android SDK or core framework. In a Java virtual machine, each instance has its own copy of the core library class file and the heap object.

Zygote Loading process

    1. Load Zygoteinit class, source code:/frameworks/base/core/java/com/android/internal/os/ZygoteInit.java
    2. Registerzygotesocket () registers a server socket for the zygote command connection.
    3. Preloadclassed "Preloaded-classes" is a simple text file containing a series of pre-loaded classes that you can find in <android source>/frameworks/base " Preloaded-classes "file.
    4. Preloadresources () Preloadresources also means local themes, layouts, and Android. Everything contained in the R file will be loaded with this method.

At this stage, you can see the start animation.

Sixth step: System Services or services

After completing the steps above, run the environment request Zygote run the system service. System services are written using both native and Java, and system services can be considered a process. The same system service is available in the Android SDK in the form of system services. The system service contains all of the systems services.

Zygote Create a new process to start the system service. You can find the source code in the "Startsystemserver" Method of the Zygoteinit class.

Core Services:

    1. Start the Power Manager;
    2. Create Activity Manager;
    3. Initiate phone registration;
    4. Start the Package manager;
    5. Set the activity Management Service as a system process;
    6. Launches the context Manager;
    7. Start the system context Providers;
    8. Start the battery service;
    9. Start the timing manager;
    10. Start the sensing service;
    11. Start the window manager;
    12. Start the Bluetooth service;
    13. Start the Mount service.

Other services:

    1. Start the status bar service;
    2. Start the hardware service;
    3. Start the network status service;
    4. Start the network connection service;
    5. Start the Notification Manager;
    6. Start the device storage monitoring service;
    7. Start the location manager;
    8. Start the search service;
    9. Start the Clipboard service;
    10. Start the registration service;
    11. Start the wallpaper service;
    12. Start the audio service;
    13. Start the headset monitoring;
    14. Start adbsettingsobserver (process adb command).
Seventh Step: Boot complete

Once the system service runs in memory, Android completes the boot process. At this time the "action_boot_completed" starts the broadcast will be sent out.

http://blog.jobbole.com/67931/

Android startup process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.