android 启动过程 booting process

android 启动过程 booting process_第1张图片
流程图

主要以下几个阶段

  • Step 1: Power On and System Startup
  • Step 2: Bootloader
  • Step 3: Kernel
  • Step 4: init process
  • Step 5: Zygote and Dalvik
  • Step 6: System service

step1: Power On and System Startup

When we press the power button, the Boot ROM code starts executing from a pre-defined location which is hardwired in ROM. It loads the Bootloader into RAM and starts executing.

Step 2: Bootloader

总的来说,bootloader是为了定位并加载linux kernal的。
Bootloader核心任务就是要初始化内存,把boot.img(kernel 和 ramdisk)从flash上copy到RAM上面,然后交出对CPU的控制权给kernel。当然,这个过程bootloader还会初始化一下LCM、串口、时钟神马的。什么是ramdisk(虚拟内存盘)


个人认为,step 1 和 step 2比较像是某种黑盒子,我们不太需要深究它的细节,只要大概清除它的作用是什么就好了。

当机器/芯片启动时,芯片上的写死的 bootloader会解压linux kernel(kernal以压缩方式存储在闪存上),把它加载到内存中,并把控制权交给linux

Step 4: init process

Init is the very first process, we can say it is a root process, or the grandfather of all processes. The init process has two responsibilities.

  • 1- 挂载目录。Mounts directories like /sys , /dev or /proc 什么是挂载目录

  • 2- 运行init.rc。Runs init.rc script

  • The init process can be found at /init :: /system/core/init
  • Init.rc file can be found at :: /system/core/rootdir/

Android has specific format and rules for init.rc files. More information about this rules can be found in: What is inside the init.rc and what is it used for.

At this stage, you can finally see the Android logo in your screen.


参考文献
什么是挂载目录
Digging Into Android Startup(youtube视频)
Android白话启动篇(Android booting process)
Android 应用进程启动流程
The Android Booting process

你可能感兴趣的:(android 启动过程 booting process)