Android 系统启动过程详解
android 使用 linux 内核,一般运行在 ARM 体系架构上,android 设备启动的过程,应用层之下基本等同于linux, 从应用层第一个程序init开始有所区别,下面开始介绍。
step1, boot rom 主要作用是加载 boot loader 进入内存并执行,boot rom 一般固化在芯片上,设备启动加电自检后从固定的地址开始执行
step2,boot loader 分2步执行,boot rom只加载了第一部分bootloader代码进入内存,这部分代码随即加载第二部分bootloader代码,第二部分是核心,它完成了必要的环境准备后,开始加载内核.
- Bootloader is small program which runs before Android operating system running. Bootloader is first program to run so It is specific for board and processor. Device manufacturer either use popular bootloaders like redboot,uboot, qi bootloader or they develop own bootloaders, It’s not part of Android Operating System. bootloader is the place where OEMs and Carriers put there locks and restrictions.
- Bootloader perform execution in two stages, first stage It to detect external RAM and load program which helps in second stage, In second stage bootloader setup network, memory, etc. which requires to run kernel, bootloader is able to provide configuration parameters or inputs to the kernel for specific purpose.
- Android bootloader can be found at
- <Android Source>\bootable\bootloader\legacy\usbloaderlegacy loader contain two important files that need to address here.
- 1. init.s - Initializes stacks, zeros the BSS segments, call _main() in main.c
- 2. main.c - Initializes hardware (clocks, board, keypad, console), creates Linux tags
- Refer this link to know more about Android bootloader :
- https://motorola-global-portal.custhelp.com/app/answers/detail/a_id/86208/~/bootloader-frequently-asked-questions
step3, android 内核启动过程与标准linux类似,完成内存子系统、保护模式、任务调度系统、驱动子系统、设备系统、文件系统等的初始化,最后运行第一个应用程序init. 与标准系统有所不同的是,android的内核增加了部分驱动及补丁,
- What is the difference between the linux and android kernels?, here's a list of changes/addons that the Android Project made to the Linux kernel:
- Binder: It is an Android specific interprocess communication mechanism and remote method invocation system.
- ashmem: "Android Shared Memory". It is a new shared memory allocator, similar to POSIX SHM but with a different behavior and sporting a simpler file-based API.
- pmem: "Process memory allocator": It is used to manage large (-+ MB) physically contigous regions of memory shared between userspace and kernel drivers.
- logger: This is the kernel support for the logcat command.
- wakelocks: It is used for power management files. It holds the machine awake on a per-event basis until wakelock is released.
- oom handling: It kills processes as available memory becomes low.
- alarm manager: It lets user space tell the kernel when it would like to wake up.
- RAM_CONSOLE: Allows to save kernel printk messages to a buffer in RAM, so that after a kernel panic they can be viewed in the next kernel invocation.
- USB gadget driver for ADB
- yaffs2 flash filesystem
step4, init 进程,从这一步开始,android的启动跟其他linux发行版(如redhat,gentoo,ubuntu)就不一样了,init程序的实现、init.rc文件的格式,都是不一样的。init 进程主要功能是挂载磁盘分区,然后根据init.rc的配置解析并执行
- 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.
- - Mounts directories like /sys , /dev or /proc
- - 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.
init.rc主要配置项如下:

/system/bin/logd
/sbin/adbd
/system/bin/usbd
/system/bin/debuggerd
/system/bin/rild
/system/bin/runtime
/system/bin/dbus-daemon
system_server
- zygote
这些进程都是 init 进程 fork+execve 出来的子进程
- After the above steps are completed, Zygote launches the system services. The Zygote forks a new process to launch the system services.
- Core services:
- Starting power manager
- Creating the Activity Manager
- Starting telephony registry
- Starting package manager
- Set activity manager service as system process
- Starting context manager
- Starting system contact providers
- Starting battery service
- Starting alarm manager
- Starting sensor service
- Starting window manager
- Starting Bluetooth service
- Starting mount service
- Other services:
- Starting status bar service
- Starting hardware service
- Starting NetStat service
- Starting connectivity service
- Starting Notification Manager
- Starting DeviceStorageMonitor service
- Starting Location Manager
- Starting Search Service
- Starting Clipboard Service
- Starting checkin service
- Starting Wallpaper service
- Starting Audio Service
- Starting HeadsetObserver
- Starting AdbSettingsObserver
- Now we have finally completed the booting process (system service are up and running in memory).
Android 系统启动过程详解的更多相关文章
- Android 核心分析 之八Android 启动过程详解
Android 启动过程详解 Android从Linux系统启动有4个步骤: (1) init进程启动 (2) Native服务启动 (3) System Server,Android服务启动 (4) ...
- Android编译过程详解(一)
Android编译过程详解(一) 注:本文转载自Android编译过程详解(一):http://www.cnblogs.com/mr-raptor/archive/2012/06/07/2540359 ...
- linux内核剖析(零)linux系统启动过程详解-开机加电后发生了什么
本文参考了如下文章 深入理解linux启动过程 mbr (主引导记录(Master Boot Record)) 电脑从开机加电到操作系统main函数之前执行的过程 详解linux系统的启动过程及系统初 ...
- Cocos2dx-3.0版本 从开发环境搭建(Win32)到项目移植Android平台过程详解
作为重量级的跨平台开发的游戏引擎,Cocos2d-x在现今的手游开发领域占有重要地位.那么问题来了,作为Cocos2dx的学习者,它的可移植特性我们就需要掌握,要不然总觉得少一门技能.然而这个时候各种 ...
- Ubuntu系统启动过程详解
作者:杨硕,华清远见嵌入式学院讲师. 一. Ubuntu的启动流程 ubuntu的启动流程和我们熟知的RedHat的启动方式有所区别. RedHat的启动过程如下图: 这是我们熟知的linux启动流程 ...
- Android编译过程详解(三)
前面两节讲解了自定义Android编译项和创建Product产品配置文件,除了编译和定义产品相关环境变量外,还需要定义Board相关环境变量. 1. build/core/config.mk 109 ...
- Android编译过程详解(二)
通过上篇文章,我们分析了编译android时source build/envsetup.sh和lunch命令,在执行完上述两个命令后, 我们就可以进行编译android了. 1. make 执行ma ...
- Linux系统启动过程详解
启动第一步--加载BIOS当你打开计算机电源,计算机会首先加载BIOS信息,BIOS信息是如此的重要,以至于计算机必须在最开始就找到它.这是因为BIOS中包含了CPU的相关信息.设备启动顺序信息.硬盘 ...
- Cordova 打包 Android release app 过程详解
Cordova 打包 Android release app 过程详解 时间 -- :: SegmentFault 原文 https://segmentfault.com/a/119000000517 ...
随机推荐
- python—— 文件的打开模式和文件对象方法 & os、os.path 模块中关于文件、目录常用的函数使用方法
引用自“鱼c工作室” 文件的打开模式和文件对象方法 : https://fishc.com.cn/forum.php?mod=viewthread&tid=45279&ext ...
- mybatis <forEach>标签的使用
MyBatis<forEach>标签的使用 你可以传递一个 List 实例或者数组作为参数对象传给 MyBatis.当你这么做的时候,MyBatis 会自动将它包装在一个 Map 中,用名 ...
- 笔记-mysql-管理及基础操作
笔记-mysql使用-管理及基础操作 1. 简介 mysql是一个免费的关系型数据库,不过好像被oracle收购了.... 希望它继续免费. 1.1. 相关术语 数据库,表,列,行,冗 ...
- Python 文本挖掘:使用情感词典进行情感分析(算法及程序设计)
出处:http://www.ithao123.cn/content-242299.html 情感分析就是分析一句话说得是很主观还是客观描述,分析这句话表达的是积极的情绪还是消极的情绪. 原理 比如 ...
- Robolectric
今天学习了单元测试框架,Robolectric.初步感觉,可能我测试的少,没有感觉Robolectric能有多大的帮助.虽然可以帮助创建activity.可以模拟点击事件.可是有什么呢. 好吧,讲下使 ...
- ElasticSearch学习笔记(二)-- mapping
1. mapping简介 2. 自定义 mapping 3. mapping演示 创建索引,设置mapping,可以新增字段 get一下mapping 设置索引的字段不可新增 为索引添加字段,发现报错 ...
- sourceInsight *** more bytes are required
现象:用sourceinsight修改的文件无法保存,提示 No enough space to save "XXX", xxx more bytes are required. ...
- [转载]Network-Emulator Network-Emulato
Network-Emulator-Toolkit网络模拟器使用详细介绍 by:授客 QQ:1033553122 原理介绍 图1 如上图,一个ADSL用户通过modem连接到网络,通过网络应用如IE,M ...
- fclose后断电引起的数据丢失问题
问题背景: 客户反馈,设备断电以后,重新启动,原有配置丢失变砖 问题分析: 变砖的直接原因是配置丢失,配置丢失的原因是启动后flash上的数据已经被破坏,读取失败: 进一步分析,主要是flash数据未 ...
- leetcode 214. 最短回文串 解题报告
给定一个字符串 s,你可以通过在字符串前面添加字符将其转换为回文串.找到并返回可以用这种方式转换的最短回文串. 示例 1: 输入: "aacecaaa" 输出: "aaa ...