Based on android2.3.5: How does Linux start the Andriod daemon init?

Source: Internet
Author: User

**************************************** **************************************** **************************************** ***
Author: EasyWave time: 2013.07.28

Category: Android source code analysis statement: reprinted. Please keep the link

NOTE: If any error occurs, please correct it. These are my Learning Log articles ......

**************************************** **************************************** **************************************** ***

1): How does Linux Andriod work?

We all know that when starting a file system in Linux, command line is usually specified in the Linux kernel, as shown below:

We can see from the figure that there is a Boot options option in the Linux Kernel configuration. After Entering, we can see a line of command like this:

Console = ttySAC0 root =/dev/mtdblock2 rootfstype = cramfs init =/linuxrc

This line is very important. To successfully start the Andriod system, you need to pay attention to init =/linuxrc. This will be explained in detail later. Now let's take a look at the kernel startup, what do you do? For details, refer to another blog:MACHINE_START and MACHINE_END
Macro define
This section details how to start Linux. Here we only focus on this function: static noinline int init_post (void) as follows:

We can see that after the kernel is started, it will automatically find the previously specified init =/linuxrc. If it cannot be found, then he will find the following/sbin/init,/etc/init and so on. In the andriod file system, there is a linuxrc file under the root directory. How can we see it? We can decompress ramdisk by running the command. img. The procedure is as follows [taking the OK6410 Andriod system as an example]:

Enter the following command in the command line:Cp ramdisk. img ramdisk.img.gz

Create a folder, such as mkdir test, and copy ramdisk.img.gz to the new test file. Then run the command: gunzip ramdisk.img.gz to decompress the folder. The following command is used:

Cpio-I-F ramdisk. img decompress the file system, as shown below:

We can see a linuxrc file in the test folder, as shown below:

Finally, open the linuxrc file and check the content as follows:

Check whether the last line/init is correct. The Linux kernel loads linuxrc through command line, and then loads the/init Andriod daemon init in linuxrc.

 

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.