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

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

相关文章

Spring Security中用户名和密码的验证完整流程

《SpringSecurity中用户名和密码的验证完整流程》本文给大家介绍SpringSecurity中用户名和密码的验证完整流程,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定... 首先创建了一个UsernamePasswordAuthenticationTChina编程oken对象,这是S

linux重启命令有哪些? 7个实用的Linux系统重启命令汇总

《linux重启命令有哪些?7个实用的Linux系统重启命令汇总》Linux系统提供了多种重启命令,常用的包括shutdown-r、reboot、init6等,不同命令适用于不同场景,本文将详细... 在管理和维护 linux 服务器时,完成系统更新、故障排查或日常维护后,重启系统往往是必不可少的步骤。本文

Android ViewBinding使用流程

《AndroidViewBinding使用流程》AndroidViewBinding是Jetpack组件,替代findViewById,提供类型安全、空安全和编译时检查,代码简洁且性能优化,相比Da... 目录一、核心概念二、ViewBinding优点三、使用流程1. 启用 ViewBinding (模块级

Mac系统下卸载JAVA和JDK的步骤

《Mac系统下卸载JAVA和JDK的步骤》JDK是Java语言的软件开发工具包,它提供了开发和运行Java应用程序所需的工具、库和资源,:本文主要介绍Mac系统下卸载JAVA和JDK的相关资料,需... 目录1. 卸载系统自带的 Java 版本检查当前 Java 版本通过命令卸载系统 Java2. 卸载自定

SpringBoot整合Flowable实现工作流的详细流程

《SpringBoot整合Flowable实现工作流的详细流程》Flowable是一个使用Java编写的轻量级业务流程引擎,Flowable流程引擎可用于部署BPMN2.0流程定义,创建这些流程定义的... 目录1、流程引擎介绍2、创建项目3、画流程图4、开发接口4.1 Java 类梳理4.2 查看流程图4

java Long 与long之间的转换流程

《javaLong与long之间的转换流程》Long类提供了一些方法,用于在long和其他数据类型(如String)之间进行转换,本文将详细介绍如何在Java中实现Long和long之间的转换,感... 目录概述流程步骤1:将long转换为Long对象步骤2:将Longhttp://www.cppcns.c

基于Python实现一个简单的题库与在线考试系统

《基于Python实现一个简单的题库与在线考试系统》在当今信息化教育时代,在线学习与考试系统已成为教育技术领域的重要组成部分,本文就来介绍一下如何使用Python和PyQt5框架开发一个名为白泽题库系... 目录概述功能特点界面展示系统架构设计类结构图Excel题库填写格式模板题库题目填写格式表核心数据结构

Linux系统中的firewall-offline-cmd详解(收藏版)

《Linux系统中的firewall-offline-cmd详解(收藏版)》firewall-offline-cmd是firewalld的一个命令行工具,专门设计用于在没有运行firewalld服务的... 目录主要用途基本语法选项1. 状态管理2. 区域管理3. 服务管理4. 端口管理5. ICMP 阻断

Windows 系统下 Nginx 的配置步骤详解

《Windows系统下Nginx的配置步骤详解》Nginx是一款功能强大的软件,在互联网领域有广泛应用,简单来说,它就像一个聪明的交通指挥员,能让网站运行得更高效、更稳定,:本文主要介绍W... 目录一、为什么要用 Nginx二、Windows 系统下 Nginx 的配置步骤1. 下载 Nginx2. 解压

如何确定哪些软件是Mac系统自带的? Mac系统内置应用查看技巧

《如何确定哪些软件是Mac系统自带的?Mac系统内置应用查看技巧》如何确定哪些软件是Mac系统自带的?mac系统中有很多自带的应用,想要看看哪些是系统自带,该怎么查看呢?下面我们就来看看Mac系统内... 在MAC电脑上,可以使用以下方法来确定哪些软件是系统自带的:1.应用程序文件夹打开应用程序文件夹