android 启动过程 booting process

流程图

主要以下几个阶段

  • 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 :: <android source>/system/core/init
  • Init.rc file can be found at :: <android source>/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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容