**************************************** **************************************** **************************************** ***
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 defineThis 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.