
主要以下幾個階段
- 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核心任務(wù)就是要初始化內(nèi)存,把boot.img(kernel 和 ramdisk)從flash上copy到RAM上面,然后交出對CPU的控制權(quán)給kernel。當(dāng)然,這個過程bootloader還會初始化一下LCM、串口、時鐘神馬的。什么是ramdisk(虛擬內(nèi)存盤)
個人認為,step 1 和 step 2比較像是某種黑盒子,我們不太需要深究它的細節(jié),只要大概清除它的作用是什么就好了。
當(dāng)機器/芯片啟動時,芯片上的寫死的 bootloader會解壓linux kernel(kernal以壓縮方式存儲在閃存上),把它加載到內(nèi)存中,并把控制權(quán)交給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 應(yīng)用進程啟動流程
The Android Booting process