The Android boot process from power on
Since mobile platforms and embedded systems has some differences compared to Desktop systems in how they initially start up and boot. This post will discuss the initial boot stages of an Android phone in some detail. Since we have used theBeagle
Boardas reference in some previous examples any specifics here are related to a similar system.
1. Power on and boot ROM code execution
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. For more information on boot ROM and configurations study the initalization chapter in
the Omap 3530 TRM.
- 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.
- 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.
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 LinuxuBootis
often the boot loader of choice. Device manufacturers often use their own proprietary boot loaders. The requirements on a boot loader for Linux running on an ARM system can be found in the Booting document under/Documentation/arm
in the kernel
source tree.
- A. The first boot loader stage will detect and set up external 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.
- C. The second stage of the boot loader is the firstmajorprogram 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.
- 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.
- 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.
3. The Linux kernel
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.
- 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.
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.
- B. The init process will parse the init script and launch the system service processes.
5. Zygote and Dalvik
The Zygote is launched by the init process and will basically just start executing and and initialize the Dalvik VM.
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.
7. Boot completed
Added this part to the post on 20090831 since it is very useful and something I should not have left out from the beginning. Once the System Server is up and running and the system boot has completed there is a standard broadcast action called ACTION_BOOT_COMPLETED.
To start your own service, register an alarm or otherwise make your application perform some action after boot you should register to receive this broadcast intent.
The separate boot steps and possible places to add your own functionality are covered in more detail in separate posts.
分享到:
相关推荐
- Kernel:内核加载并初始化硬件驱动。 - Init:内核启动init进程,这是用户空间的第一个进程,具有root权限。 - System Server:init启动System Server进程,它是Android框架层的核心。 - Zygote:System ...
Android系统的运行环境始于Kernel启动,然后通过App_main进程初始化Android Runtime的JAVA运行环境。这里的关键角色是Zygote进程,它是Android的第一个进程,所有的Android应用都是通过Zygote的fork操作生成的子进程...
1. **内核初始化**:在`start_kernel`函数中开始,这是KERNEL的入口点。 2. **硬件初始化**:根据设备树配置继续初始化未由UBOOT处理的硬件。 3. **内存管理系统初始化**:建立页表,初始化内存分配器。 4. **初始化...
boot.img的结构包括kernel、ramdisk、secondstage等部分,其中还有一个称为boot header(bootheader)的部分,它是内核初始化参数表,对应于boot_img_hdr结构。这个结构中定义了多种成员变量,比如魔术字、内核大小...
`start_kernel()`函数是内核启动过程中的另一个核心环节,它的作用主要包括初始化中断处理程序、设置定时器、初始化设备驱动程序等。此外,还会进行一些系统级别的初始化工作,如设置进程调度策略等。 **代码示例**...
1. **内核初始化阶段 (kernel_init())**: - 在这个阶段,内核完成基本设置并准备启动用户空间的初始化程序。`kernel_init()`函数是这个过程的起点,它负责创建初始的用户空间进程——`init`。 - 如果存在`ramdisk...
- `start_kernel()`:这是内核初始化的起点,它会在`/init/main.c`中被调用。 - `setup_arch()`:用于设置与硬件架构相关的参数。 - `rest_init()`:执行剩余的初始化工作。 - `init()`:初始化用户空间环境,...
• bootloader---初始化、从Flash读取Kernel镜像及一些必须的配置信息,引导kernel启动 • linuxkernel启动linux内核 • init进程启动 • init进程读取init.rc启动必要的daemon程序,如:adbd、...
描述中提到驱动程序会在`sys/class/timed_output`目录下创建设备节点,这通常是通过在内核模块初始化时调用`device_create()`函数实现的。这个节点是用户空间访问驱动的接口,使得Hal层可以通过读写该节点的属性来...
1. **内核启动过程**:从硬件初始化到系统调用服务的整个流程,帮助读者理解操作系统如何从无到有地构建起来。 2. **内存管理**:介绍虚拟内存系统、页面缓存机制以及如何有效管理物理内存资源。 3. **进程管理*...
Bootloader是在操作系统内核运行之前执行的一段代码,它的主要作用是完成对硬件设备的基本初始化,创建并传递必要信息给操作系统内核,并负责引导和加载内核,最终调用操作系统内核。Bootloader对于嵌入式设备的启动...
使用repo工具初始化并同步Android的最新版本源代码。在创建的`android`目录下执行以下命令: ``` root@ubuntu:~# mkdir android root@ubuntu:~# cd android root@ubuntu:~/android# repo init -u ...
总结来说,Android系统的开机启动涉及从硬件层面的bootloader到软件层面的kernel、init、ServiceManager和Zygote等多个层次的初始化。这些组件共同构建了Android系统的基石,确保了系统能够正确、高效地启动并运行...
- **后续动作:** 完成所有子系统的初始化工作,最终启动Android操作系统。 #### 总结 高通MSM8994的启动流程涉及多个关键步骤,从最底层的RPMPBL到最终的Android系统启动,每个环节都至关重要。这一流程不仅展示...
- 例如,要获取Android 1.5的源码,可以使用命令`repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake`初始化并指定分支名称为`cupcake`,之后使用`repo sync`同步源码。这种方式同样适用...
然后,在一个工作目录下,使用`repo`初始化源代码仓库: ```bash mkdir /work/android-froyo-r2 cd /work/android-froyo-r2 repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo ``` 这里...
总之,编译Android 2.3源码在Ubuntu环境下需要安装必要的软件,设置环境,初始化源码仓库,下载源码,最后进行编译。整个过程可能遇到各种问题,如网络连接、文件权限或配置错误等,需要根据实际情况调整和解决。在...
2. init目录:该目录包含了Android系统启动过程中的初始化代码和其他相关文件。这些文件负责引导系统进入不同的运行模式,设置初始环境,并启动系统服务。 3. arch目录:arch目录包含了针对特定硬件架构的代码,...