Android开机流程分析
以上MTK官方给出的MTK平台启动流程
以下是博主抓取的QCOM平台开机LOG Androdi启动流程
bootchart 的测量时段是 init 进程启动之后,不包含 uboot 和 kernel 的启动时间。
Android系统启动的log分为Linux内核(kernel)的log和 Android Logger系统的log,
bootloader–>LK->kernel–>init->Zygote–>PMS–>AMS–>Launcher
关键字:Systemserver,zygote,boot_progress_,
[1]init 是 Android 第一个被启动的进程,init的 PID 的值是0,
我们可以通过查看Boot Event来确定是哪部分花时比较多。
后面的时间是systemclock.uptimemillis()开机到当前时间,毫秒。
01-01 08:01:39.056 777 777 I boot_progress_start: 19456//Android屏幕点亮开始显示启动动画,标志着kernel启动完成,user space 开始时间
01-01 08:01:39.958 777 777 I boot_progress_preload_start: 20358 //Zygote启动,zygote进程是在init进程中启动的
01-01 08:01:41.629 777 777 I boot_progress_preload_end: 22029 //Zygote结束
以上三条信息F18G项目并未抓取到,因为我们的离线日志是基本android中,无法抓到android vm虚拟机启动前的日志
01-15 06:34:55.963 0 0 I [ T1] KPI: Bootloader start count = 72184 //为LK 开始时间
01-15 06:34:55.968 0 0 I [ T1] KPI: Bootloader end count = 99627 //为LK 结束时间
01-15 06:34:55.973 0 0 I [ T1] KPI: Bootloader display count = 3234952363
01-15 06:34:55.979 0 0 I [ T1] KPI: Bootloader load kernel count = 4365
01-15 06:34:55.985 0 0 I [ T1] KPI: Kernel MPM timestamp = 276812 // bootloader 完成时间
01-15 06:34:55.990 0 0 I [ T1] KPI: Kernel MPM Clock frequency = 32768
01-15 06:35:13.901 1093 1093 I boot_progress_system_run: 21344 //SystemServer ready,开始启动Android系统服务,
01-15 06:35:15.270 1093 1093 I boot_progress_pms_start: 22713 //PMS开始扫描安装的应用
01-15 06:35:15.496 1093 1093 I boot_progress_pms_system_scan_start: 22939 //PMS先行扫描/system目录下的安装包
03-14 14:31:42.218 1093 1093 I boot_progress_pms_data_scan_start: 23694 //PMS扫描/data目录下的安装包
03-14 14:31:42.224 1093 1093 I boot_progress_pms_scan_end: 23700 //PMS扫描结束
03-14 14:31:42.571 1093 1093 I boot_progress_pms_ready: 24047 //PMS就绪
03-14 14:31:43.577 775 775 D ZygoteInitTiming_lazy: BeginPreload took to complete: 6ms //预加载虚拟机运行时所需要的各类资源
03-14 14:31:44.250 775 775 D ZygoteInitTiming_lazy: PreloadClasses took to complete: 673ms //预加载进程共用所需的classs文件
03-14 14:31:44.285 775 775 D ZygoteInitTiming_lazy: PreloadResources took to complete: 11ms //预加载系统资源,这样当应用程序被fork处理之后,进程内已经包含了这些classer文件及系统资源。
03-14 14:31:45.669 1093 1093 I boot_progress_ams_ready: 27145 //AMS就绪
03-15 10:30:17.726 1255 1255 I SystemServerTiming: StartSystemUI //启动systemUi此条记录是另一份log中的
03-14 14:31:46.165 1093 1093 I SystemServerTiming: startPersistentApps //启动系统自启APP
03-14 14:31:46.175 1093 1093 D SystemServerTiming: startPersistentApps took to complete: 10ms
03-14 14:31:46.175 1093 1093 I SystemServerTiming: startHomeOnAllDisplays //AMS启动完成前systemReady()中启动Launcher
03-14 14:31:46.350 1093 1093 D SystemServerTiming: startHomeOnAllDisplays took to complete: 174ms
03-14 14:31:46.383 1093 1093 D SystemServerTiming: ActivityManagerStartApps took to complete: 363ms //启动其它应用
03-14 14:31:46.383 1093 1093 D SystemServerTiming: PhaseActivityManagerReady took to complete: 725ms
03-14 14:31:46.383 1093 1093 D SystemServerTiming: startOtherServices took to complete: 2819ms //启动其它服务
03-14 14:31:46.383 1093 1093 D SystemServerTiming: StartServices took to complete: 6124ms
03-14 14:31:47.113 1093 1241 I boot_progress_enable_screen: 28589 //AMS启动完成后开始激活屏幕,从此以后屏幕才能响应用户的触摸,它在WindowManagerService发出退出开机动画的时间节点之前,而真正退出开机动画还会花费少许时间,
03-14 14:31:47.907 1146 1197 I sf_stop_bootanim: 29383 //SF设置service.bootanim.exit属性值为1,标志系统要结束开机动画了,
03-14 14:31:47.913 1093 1241 I wm_boot_animation_done: 29389 // 开机动画结束,这一步用户能直观感受到开机结束
03-14 14:31:47.913 1093 1241 I ActivityManagerTiming: FinishBooting
03-14 14:31:47.944 1093 1241 D ActivityManagerTiming: TotalBootTime took to complete: 8116ms
03-14 14:31:48.610 1093 1274 I ActivityManager: Posting BOOT_COMPLETED user #0
03-14 14:31:48.630 1093 1936 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000100 cmp=com.android.launcher3/.uioverrides.QuickstepLauncher} from uid 0
am_proc_start: [0,2472,10152,com.android.systemui,service,{com.android.systemui/com.android.systemui.ImageWallpaper}]
-----------------------------------------------------------------------------
查看系统的开机流程
androidos:/ # cat /proc/bootprof
----------------------------------------
0 BOOT PROF (unit:msec)
----------------------------------------
4228 : preloader
8556 : lk (Start->Show logo: 1984)
----------------------------------------
3.217000 : ON (Threshold: 15ms)
116.767154 : 1-swapper/0 : probe: probe=platform_drv_probe drv=clk-mt6761(0xc1655d58) 32.130077ms
136.107077 : 1-swapper/0 : initcall: of_platform_default_populate_init 95.597308ms
186.167461 : 1-swapper/0 : initcall: ccci_util_init 33.783692ms
259.965846 : 1-swapper/0 : initcall: tracer_init_tracefs 57.296077ms
311.679077 : 1-swapper/0 : initcall: populate_rootfs 47.066462ms
370.859770 : 1-swapper/0 : probe: probe=platform_drv_probe drv=mt6577-uart(0xc165e7e8) 20.599077ms
391.326539 : 1-swapper/0 : probe: probe=platform_drv_probe drv=mt6577-uart(0xc165e7e8) 20.416000ms
391.704616 : 1-swapper/0 : initcall: mtk8250_platform_driver_init 41.680077ms
480.263154 : 1-swapper/0 : probe: probe=platform_drv_probe drv=musb-hdrc(0xc16d2c28) 19.995076ms
480.293616 : 1-swapper/0 : probe: probe=platform_drv_probe drv=mt_usb(0xc16d2e90) 20.429000ms
480.779154 : 1-swapper/0 : initcall: mt_usb_driver_init 21.332000ms
509.955693 : 1-swapper/0 : probe: probe=platform_drv_probe drv=mt6397(0xc16d3ed0) 24.049308ms
510.073539 : 1-swapper/0 : initcall: mt6397_driver_init 25.249230ms
634.312616 : 1-swapper/0 : probe: probe=i2c_device_probe drv=aw22xxx_led(0xc16f72a0) 87.300385ms
634.401539 : 1-swapper/0 : initcall: aw22xxx_i2c_init 87.467077ms
723.669232 : 201-kworker/2:1 : probe: probe=platform_drv_probe drv=gpufreq(0xc1660a70) 23.779000ms
742.061540 : 201-kworker/2:1 : probe: probe=platform_drv_probe drv=driver_modem(0xc16af538) 17.291462ms
769.123694 : 201-kworker/2:1 : probe: probe=platform_drv_probe drv=mtkfb(0xc16bc020) 22.055384ms
807.904309 : 201-kworker/2:1 : probe: probe=platform_drv_probe drv=mt6357_gauge(0xc16f1af8) 33.899770ms
810.200078 : 1-swapper/0 : initcall: deferred_probe_initcall 114.581154ms
2135.867389 : 1-swapper/0 : probe: probe=i2c_device_probe drv=ltr559(0xc16ae2b0) 1314.633542ms
2136.025620 : 1-swapper/0 : initcall: alsps_init 1314.888926ms
2171.133312 : 1-swapper/0 : probe: probe=i2c_device_probe drv=mir3da(0xc16ae600) 34.776000ms
2171.275466 : 1-swapper/0 : initcall: acc_init 35.182769ms
2216.391082 : 1-swapper/0 : Kernel_init_done
2343.044082 : 273-kworker/u8:4 : probe: probe=i2c_device_probe drv=semi_touch(0xc16e2f88) 140.358385ms
2343.511697 : 273-kworker/u8:4 : probe: probe=platform_drv_probe drv=mtk-tpd(0xc16e2d50) 141.865308ms
4523.068626 : 310-init : INIT:early-init
6380.664322 : 310-init : INIT:init
6552.871784 : 310-init : INIT:late-init
6585.618169 : 310-init : INIT:early-fs
6586.832015 : 310-init : INIT:fs
6587.997246 : 310-init : INIT:Mount_START
6972.116401 : 310-init : INIT:Mount_END
7046.778247 : 310-init : INIT:post-fs
7149.025017 : 310-init : tkcore: prepare system ta path
7394.687402 : 310-init : INIT:late-fs
7396.213017 : 310-init : INIT:Mount_START --late
8882.532098 : 310-init : INIT:Mount_END --late
8937.969944 : 350-Binder:350_2 : vold:fbeEnable:START
8938.154867 : 350-Binder:350_2 : vold:retrieveOrGenerateKey:START
8947.231713 : 350-Binder:350_2 : vold:retrieveOrGenerateKey:END, rtn =1
8947.282559 : 350-Binder:350_2 : vold:install_storage_key(device_key):START
8948.172944 : 350-Binder:350_2 : vold:install_storage_key(device_key):END, rtn =1
8951.771175 : 350-Binder:350_2 : vold:generateStorageKey(per_boot_key):START
8951.912636 : 350-Binder:350_2 : vold:generateStorageKey(per_boot_key):END, rtn =1
8951.934867 : 350-Binder:350_2 : vold:install_storage_key(per_boot_key):START
8952.348329 : 350-Binder:350_2 : vold:install_storage_key(per_boot_key):END, rtn =1
8953.704405 : 350-Binder:350_2 : vold:fbeEnable:END, rtn =1
9251.821868 : 350-Binder:350_2 : vold:initUser0:START
9361.868406 : 350-Binder:350_2 : vold:initUser0:END, rtn =1
9571.839176 : 310-init : INIT:post-fs-data
9801.475715 : 310-init : post-fs-data: on modem start
10564.624332 : 310-init : INIT:zygote-start
10566.348102 : 310-init : INIT:early-boot
10947.961026 : 310-init : INIT:boot
11035.240026 : 479-ccci_mdinit : ccci_md1: md_init srv start
11041.985872 : 479-ccci_mdinit : ccci_md1: init
11044.140026 : 479-ccci_mdinit : ccci_md1: decpyt ready
11044.626872 : 479-ccci_mdinit : ccci_md1: decpyt ready
11045.697026 : 479-ccci_mdinit : ccci_md1: reset
11055.771410 : 480-ccci_mdinit : ccci_md3: md_init srv start
11414.721950 : 310-init : initcall: init_module [wmt_drv] 48.556538ms
11739.185027 : 452-zygote : boot_progress_start
11754.520028 : 390-wmt_loader : probe: probe=platform_drv_probe drv=mtk_wmt(alarm_timer_handler [wmt_drv]) 25.720384ms
12574.210799 : 479-ccci_mdinit : ccci_md1: bootup
12682.355184 : 310-init : USB ready
12825.909338 : 310-init : probe: probe=platform_drv_probe drv=fm(mt_fm_dev_drv [fmradio_drv_mt6631]) 36.215692ms
12826.093953 : 310-init : initcall: init_module [fmradio_drv_mt6631] 41.667385ms
13200.470800 : 310-init : tkcore: prepare basic
13208.382185 : 310-init : tkcore: prepare sfs
13221.095493 : 310-init : tkcore: prepare service provider ta path
13303.300339 : 310-init : tkcore: prepare log file
13623.264647 : 479-ccci_mdinit : ccci_md1: ready
14425.334265 : 452-main : Zygote:Preload Start
18984.744352 : 452-main : Zygote:Preload 13901 classes in 4153ms
19078.776430 : 452-main : Zygote:Preload 64 obtain resources in 66ms
19091.249891 : 452-main : Zygote:Preload 41 resources in 12ms
19808.905354 : 452-main : Zygote:Preload End
21846.273282 : 967-system_server : Android:SysServerInit_START
23840.278826 : 967-system_server : Android:PackageManagerService_Start
24343.427827 : 967-system_server : Android:PMS_scan_START
24358.855519 : 967-system_server : Android:PMS_scan_data:/product/overlay
24422.211135 : 967-system_server : Android:PMS_scan_data:/vendor/overlay
24452.517981 : 967-system_server : Android:PMS_scan_data:/system/framework
24568.698827 : 967-system_server : Android:PMS_scan_data:/system/priv-app
24923.348674 : 967-system_server : Android:PMS_scan_data:/system/app
25102.590906 : 967-system_server : Android:PMS_scan_data:/vendor/app
25130.169290 : 967-system_server : Android:PMS_scan_data:/product/priv-app
25156.063829 : 967-system_server : Android:PMS_scan_data:/product/app
25234.932137 : 967-system_server : Android:PMS_scan_data:/system/system_ext/priv-app
25446.533060 : 967-system_server : Android:PMS_scan_data:/system/system_ext/app
25585.210907 : 967-system_server : Android:PMS_scan_data:/apex/com.android.wifi/priv-app
25599.066291 : 967-system_server : Android:PMS_scan_data:/apex/com.android.wifi/app
25614.469599 : 967-system_server : Android:PMS_scan_data:/apex/com.android.tethering/priv-app
25632.150291 : 967-system_server : Android:PMS_scan_data:/apex/com.android.permission/priv-app
25673.553676 : 967-system_server : Android:PMS_scan_data:/apex/com.android.mediaprovider/priv-app
25698.882522 : 967-system_server : Android:PMS_scan_data:/apex/com.android.extservices/priv-app
25746.552676 : 967-system_server : Android:PMS_scan_END
25848.389061 : 967-system_server : PMS:reconcileAppsDataLI
26163.492139 : 967-system_server : Android:PMS_READY
29920.662302 : 967-system_server : AMS:systemReady
29934.869917 : 967-system_server : AMS:AMS_READY
30130.568379 : 1035-ActivityManager : AP_Init:[service]:[com.android.systemui]:[{com.android.systemui/com.android.systemui.ImageWallpaper}]:pid:1189:(PersistAP)
30336.602226 : 1035-ActivityManager : AP_Init:[null]:[WebViewLoader-armeabi-v7a]:pid:1230
30365.037610 : 967-system_server : SystemServer:NetworkStatsService systemReady
30442.825687 : 967-system_server : SystemServer:ConnectivityService systemReady
30599.725688 : 967-system_server : SystemServer:NetworkPolicyManagerServ systemReady
31053.861074 : 967-system_server : SystemServer:PhaseThirdPartyAppsCanStart
31414.226921 : 1035-ActivityManager : AP_Init:[added application]:[com.android.phone]:[com.android.phone]:pid:1312:(PersistAP)
31488.670536 : 1035-ActivityManager : AP_Init:[top-activity]:[com.android.settings]:[{com.android.settings/com.android.settings.FallbackHome}]:pid:1340
31489.612151 : 967-system_server : Keyguard bindService
31495.665382 : 967-system_server : Keyguard started
31498.605075 : 967-system_server : Android:SysServerInit_END
31616.685998 : 1035-ActivityManager : AP_Init:[service]:[android.ext.services]:[{android.ext.services/android.ext.services.autofill.InlineSuggestionRenderServiceImpl}]:pid:1362
32527.038616 : 1023-android.display : AMS:ENABLE_SCREEN
33356.391156 : 1035-ActivityManager : AP_Init:[service]:[com.android.launcher3]:[{com.android.launcher3/com.android.quickstep.TouchInteractionService}]:pid:1502
34656.439159 : 1021-android.ui : Keyguard connected
36343.233009 : 1035-ActivityManager : AP_Init:[service]:[com.android.permissioncontroller]:[{com.android.permissioncontroller/com.android.permissioncontroller.permission.service.PermissionControllerServiceImpl}]:pid:1584
36447.138009 : 1017-Binder:967_1 : Keyguard onDrawn
37717.268705 : OFF
----------------------------------------
评论