安卓系统加电引导流程剖析

2024-03-15 05:32

本文主要是介绍安卓系统加电引导流程剖析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. Power on and boot ROM code execution      
    开机并执行 boot ROM 代码

    

At power on the CPU will be in a state where no initializations have been done. Internal clocks are not set up and the only memory available is the internal RAM. 
When power supplies are stable the execution will start with the Boot ROM code. This is a small piece of code that is hardwired in the CPU ASIC. 

才开机时,CPU 处于未初始化状态,还没有设定内部时钟,仅仅只有内部 RAM 可用。当电源稳定后会开始执行 BOOT ROM 代码,这是一小块代码被硬编码在 CPU ASIC 中。

  • A. The Boot ROM code will detect the boot media using a system register that maps to some physical balls on the asic. 
        This is to determine where to find the first stage of the boot loader.
        Boot ROM 代码会引导 boot 媒介使用系统寄存器映射到 ASIC 中一些物理区域,这是为了确定哪里能找到 boot loader 的第一阶段

  • B. Once the boot media sequence is established the boot ROM will try to load the first stage boot loader to internal RAM. 
        Once the boot loader is in place the boot ROM code will perform a jump and execution continues in the boot loader.
        一旦 boot 媒介顺序确定,boot ROM 会试着装载 boot loader 的第一阶段到内部 RAM 中,一旦 boot loader 就位,boot ROM 代码会跳到并执行 boot loader

 

2. The boot loader

The boot loader is a special program separate from the Linux kernel that is used to set up initial memories and load the kernel to RAM. 
On desktop systems the boot loaders are programs like GRUB and in embedded Linux uBoot is often the boot loader of choice. 
Device manufacturers often use their own proprietary boot loaders. 

boot loader 是一个特殊的独立于 Linux 内核的程序,它用来初始化内存和装载内核到 RAM 中,桌面系统的 boot loader 程序有 GRUB,嵌入式系统常用 uBoot,
设备制造商常常使用自己专有的 boot loader 程序。

 

  • A. The first boot loader stage will detect and set up external RAM.
        boot loader 第一阶段会检测和设置外部 RAM

  • B. Once external RAM is available and the system is ready the to run something more significant the first stage will load the main boot loader and place it in external RAM.
        一旦外部 RAM 可用,系统会准备装载主 boot loader,把它放到外部 RAM 中

  • C. The second stage of the boot loader is the first major program that will run. This may contain code to set up file systems, additional memory, 
        network support and other things.On a mobile phone it may also be responsible for loading code for the modem CPU and setting up low level memory 
        protections and security options.

        boot loader 第二阶段是运行的第一个重要程序,它包含了设置文件系统,内存,网络支持和其他的代码。在一个移动电话上,
        也可能是负责加载调制解调器的CPU代码和设定低级别的内存保护和安全选项

  • D. Once the boot loader is done with any special tasks it will look for a Linux kernel to boot. It will load this from the boot media 
        (or some other source depending on system configuration) and place it in the RAM. 
        It will also place some boot parameters in memory for the kernel to read when it starts up.
        一旦 boot loader 完成这些特殊任务,开始寻找 linux 内核,它会从 boot 媒介上装载 linux 内核(或者其他地方,这取决于系统配置),把它放到 RAM 中,
       它也会在内存中为内核替换一些在内核启动时读取的启动参数

  • E. Once the boot loader is done it will perform a jump to the Linux kernel, usually some decompression routine, and the kernel assumes system responsibility.
        一旦 boot loader 完成会跳到 linux 内核,通常通过解压程序解压内核文件,内核将取得系统权限

     

3. The Linux kernel
  linux 内核

The Linux kernel starts up in a similar way on Android as on other systems. It will set up everything that is needed for the system to run. Initialize interrupt controllers,
set up memory protections, caches and scheduling.
linux 内核在 android 上跟在其他系统上的启动方式一样,它将设置系统运行需要的一切,初始化中断控制器,设定内存保护,高速缓存和调度

  • A. Once the memory management units and caches have been initialized the system will be able to use virtual memory and launch user space processes.
      一旦内存管理单元和高速缓存初始化完成,系统将可以使用虚拟内存和启动用户空间进程

  • B. The kernel will look in the root file system for the init process (found under system/core/init in the Android open source tree) and launch it as the initial user space process.
      内核在根目录寻找初始化程序(代码对应 android source tree: /system/core/init ),启动它作为初始化用户空间进程

     

4. The init process
  初始化进程

The init process is the "grandmother" of all system processes. Every other process in the system will be launched from this process or one of its descendants.
初始化进程是所有其他系统进程的 “祖母 ”,系统的每一个其他进程将从该进程中或者该进程的子进程中启动

 

  • A. The init process in Android will look for a file called init.rc. This is a script that describes the system services, file system and other parameters that need to be set up. 
        The init.rc script is placed in system/core/rootdir in the Android open source project. 
        初始化进程会寻找 init.rc 文件,init.rc 脚本文件描述了系统服务,文件系统和其他需要设定的参数,该文件在代码:system/core/rootdir

  • B. The init process will parse the init script and launch the system service processes.
        初始化进程解析 init 脚本,启动系统服务进程

     

5. Zygote and Dalvik

The Zygote is launched by the init process and will basically just start executing and and initialize the Dalvik VM.
Zygote 被初始化进程启动,开始运行和初始化 dalvik 虚拟机

6. The system server
    系统服务
The system server is the first java component to run in the system. It will start all the Android services such as telephony manager and bluetooth. 
Start up of each service is currently written directly into the run method of the system server. The system server source can be found in the file :
frameworks/base/services/java/com/android/server/SystemServer.java in the open source project.

系统服务是在系统中运行的第一个 java 组件,它会启动所有的 android 服务,比如:电话服务,蓝牙服务,每个服务的启动被直接写在 SystemServer.java 这个类的 run 方法里面
代码: frameworks/base/services/java/com/android/server/SystemServer.java


7. Boot completed
  启动完成

 Once the System Server is up and running and the system boot has completed there is a standard broadcast action called ACTION_BOOT_COMPLETED. 
  一旦系统服务启动并运行,android 系统启动就完成了,同时发出 ACTION_BOOT_COMPLETED 广播

这篇关于安卓系统加电引导流程剖析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/810950

相关文章

基于C++的UDP网络通信系统设计与实现详解

《基于C++的UDP网络通信系统设计与实现详解》在网络编程领域,UDP作为一种无连接的传输层协议,以其高效、低延迟的特性在实时性要求高的应用场景中占据重要地位,下面我们就来看看如何从零开始构建一个完整... 目录前言一、UDP服务器UdpServer.hpp1.1 基本框架设计1.2 初始化函数Init详解

MySQL游标和触发器的操作流程

《MySQL游标和触发器的操作流程》本文介绍了MySQL中的游标和触发器的使用方法,游标可以对查询结果集进行逐行处理,而触发器则可以在数据表发生更改时自动执行预定义的操作,感兴趣的朋友跟随小编一起看看... 目录游标游标的操作流程1. 定义游标2.打开游标3.利用游标检索数据4.关闭游标例题触发器触发器的基

C++简单日志系统实现代码示例

《C++简单日志系统实现代码示例》日志系统是成熟软件中的一个重要组成部分,其记录软件的使用和运行行为,方便事后进行故障分析、数据统计等,:本文主要介绍C++简单日志系统实现的相关资料,文中通过代码... 目录前言Util.hppLevel.hppLogMsg.hppFormat.hppSink.hppBuf

在DataGrip中操作MySQL完整流程步骤(从登录到数据查询)

《在DataGrip中操作MySQL完整流程步骤(从登录到数据查询)》DataGrip是JetBrains公司出品的一款现代化数据库管理工具,支持多种数据库系统,包括MySQL,:本文主要介绍在D... 目录前言一、登录 mysql 服务器1.1 打开 DataGrip 并添加数据源1.2 配置 MySQL

Nginx分布式部署流程分析

《Nginx分布式部署流程分析》文章介绍Nginx在分布式部署中的反向代理和负载均衡作用,用于分发请求、减轻服务器压力及解决session共享问题,涵盖配置方法、策略及Java项目应用,并提及分布式事... 目录分布式部署NginxJava中的代理代理分为正向代理和反向代理正向代理反向代理Nginx应用场景

linux系统中java的cacerts的优先级详解

《linux系统中java的cacerts的优先级详解》文章讲解了Java信任库(cacerts)的优先级与管理方式,指出JDK自带的cacerts默认优先级更高,系统级cacerts需手动同步或显式... 目录Java 默认使用哪个?如何检查当前使用的信任库?简要了解Java的信任库总结了解 Java 信

Spring Boot分层架构详解之从Controller到Service再到Mapper的完整流程(用户管理系统为例)

《SpringBoot分层架构详解之从Controller到Service再到Mapper的完整流程(用户管理系统为例)》本文将以一个实际案例(用户管理系统)为例,详细解析SpringBoot中Co... 目录引言:为什么学习Spring Boot分层架构?第一部分:Spring Boot的整体架构1.1

nodejs打包作为公共包使用的完整流程

《nodejs打包作为公共包使用的完整流程》在Node.js项目中,打包和部署是发布应用的关键步骤,:本文主要介绍nodejs打包作为公共包使用的相关资料,文中通过代码介绍的非常详细,需要的朋友可... 目录前言一、前置准备二、创建与编码三、一键构建四、本地“白嫖”测试(可选)五、发布公共包六、常见踩坑提醒

Ubuntu向多台主机批量传输文件的流程步骤

《Ubuntu向多台主机批量传输文件的流程步骤》:本文主要介绍在Ubuntu中批量传输文件到多台主机的方法,需确保主机互通、用户名密码统一及端口开放,通过安装sshpass工具,准备包含目标主机信... 目录Ubuntu 向多台主机批量传输文件1.安装 sshpass2.准备主机列表文件3.创建一个批处理脚

一个Java的main方法在JVM中的执行流程示例详解

《一个Java的main方法在JVM中的执行流程示例详解》main方法是Java程序的入口点,程序从这里开始执行,:本文主要介绍一个Java的main方法在JVM中执行流程的相关资料,文中通过代码... 目录第一阶段:加载 (Loading)第二阶段:链接 (Linking)第三阶段:初始化 (Initia