自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release 而非 aosp-main 构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
AOSP
文档
核心主题
内核概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 内核基于上游 Linux 长期支持 (LTS) 内核。在 Google,LTS 内核会与 Android 专用补丁结合,形成所谓的“Android 通用内核 (ACK)”。
较新的 ACK(版本 5.4 及更高版本)也称为 GKI 内核。GKI 内核支持将与硬件无关的通用核心内核代码和 GKI 模块与硬件专用供应商模块分离开来。
警告:4.19 内核不再受支持。已移除有关 4.19 内核的文档。
GKI 内核会与包含系统芯片 (SoC) 和板级代码的硬件专用供应商模块进行交互。GKI 内核与供应商模块之间的交互通过内核模块接口 (KMI) 来实现,该接口由标识供应商模块所需的函数和全局数据的符号列表组成。图 1 显示了 GKI 内核和供应商模块架构:
图 1. GKI 架构
注意:GKI 内核、GKI 模块和供应商模块架构是我们多年来一直致力于开展的通用内核映像 (GKI) 项目的成果。如需了解此项目及其各个阶段,请参阅通用内核映像 (GKI) 项目。
内核术语表
本部分包含整个内核文档中使用的术语。
内核类型
Android 通用内核 (ACK)
ACK 是长期支持 (LTS) 内核的下游,包含与 Android 社区相关但尚未合并到 Linux Mainline 或 LTS 内核的补丁。较新的 ACK(5.4 及更高版本)也称为 GKI 内核,因为它们支持将与硬件无关的通用内核代码和与硬件无关的 GKI 模块分离开来。
Android 开源项目 (AOSP) 内核
请参阅 Android 通用内核。
功能内核
确保实现平台版本功能的内核。例如,在 Android 12 中,两个功能内核为 android12-5.4 和 android12-5.10。Android 12 的功能无法向后移植到 4.19 内核;功能集与发布时搭载 4.19 内核和 Android 11 且升级到 Android 12 的设备类似。
通用核心内核
在所有设备上通用的 GKI 内核部分。
通用内核映像 (GKI) 内核
任何较新的(5.4 及更高版本)ACK 内核(目前仅限 aarch64)。此内核包含两个部分:核心 GKI 内核和 GKI 模块,前者的代码在所有设备上通用,后者由 Google 开发并可在设备上动态加载(如适用)。
内核模块接口 (KMI) 内核
请参阅 GKI 内核。
启动内核
对于启动指定 Android 平台版本的设备有效的内核。例如,在 Android 12 中,有效的启动内核为 4.19、5.4 和 5.10。
长期支持 (LTS) 内核
受支持 2 到 6 年的 Linux 内核。LTS 内核每年发布一次,是 Google 每个 ACK 的基础。
分支类型
ACK KMI 内核分支
构建 GKI 内核的分支。例如,android12-5.10 和 android13-5.15。
Android-mainline
Android 功能的主要开发分支。当上游声明了新的 LTS 内核时,相应的新 GKI 内核就会成为 android-mainline 的分支。
Linux Mainline
上游 Linux 内核(包括 LTS 内核)的主要开发分支。
其他术语
经过认证的启动映像
以二进制文件形式 (boot.img) 分发并刷写到设备上的内核。
此映像经过认证,因为它包含嵌入式证书,Google 可以验证设备搭载的内核已经过 Google 认证。
可动态加载的内核模块 (DLKM)
可以在设备启动过程中根据设备需求动态加载的模块。GKI 和供应商模块都是 DLKM。DLKM 以 .ko 形式发布,可以是驱动程序,也可以提供其他内核功能。
GKI 项目
一个 Google 项目,通过将通用核心内核功能从供应商专用 SoC 和板级支持分离出来并使其成为可加载模块,解决了内核碎片化问题。
通用内核映像 (GKI)
经过 Google 认证的启动映像,包含基于 ACK 源代码树构建的 GKI 内核,适合刷写到 Android 设备的启动分区。
KMI
GKI 内核与供应商模块之间的接口,使供应商模块能够独立于 GKI 内核进行更新。此接口包括已根据合作伙伴符号列表标识为供应商/OEM 依赖项的内核函数和全局数据。
GKI 模块
由 Google 构建的可在设备上动态加载的内核模块(若适用)。
这些模块构建为 GKI 内核的制品,并与 GKI 一起作为 system_dlkm_staging_archive.tar.gz 归档提供。GKI 模块由 Google 使用内核构建时间密钥对进行签名,并且仅与其构建时使用的 GKI 内核兼容。
供应商模块
由合作伙伴开发的硬件专用模块,包含 SoC 和设备专用功能。供应商模块是一种可动态加载的内核模块。
后续操作
如果您是 Android 内核开发新手,不妨先阅读以下内容:
长期稳定内核 - 馈送到 ACK 的上游 LTS 内核上的后台。
Android 通用内核 - ACK 上的后台。
如果您是 GKI 内核开发新手,请先阅读 GKI 开发。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Kernel overview\n\nThe Android kernel is based on an upstream\n[Linux Long Term Supported (LTS) kernel](https://www.kernel.org/category/lts). At Google, LTS kernels are combined\nwith Android-specific patches to form *Android Common Kernels (ACKs)*.\n\nACKs are built from the [kernel/common](https://android.googlesource.com/kernel/common) repository. This repository is a\nsuperset of the upstream Linux kernel, with additional Android-specific patches.\n\nACKs that are 5.10 and higher are also known as \\*generic kernel images (GKI)\nkernels. GKI kernels support the separation of the hardware-agnostic *generic\ncore kernel* code and [GKI modules](/docs/core/architecture/kernel/modules#gki-modules) from hardware-specific\n[vendor modules](/docs/core/architecture/kernel/modules#vendor-modules).\n\nThe interaction between the GKI kernel and vendor modules is enabled by the\n*Kernel Module Interface (KMI)* consisting of symbol lists identifying the\nfunctions and global data required by vendor modules. Figure 1 shows the GKI\nkernel and vendor module architecture:\n\n**Figure 1.** GKI kernel and vendor module architecture.\n| **Note:** The GKI kernel, GKI module, and vendor module architecture is the result of a multi-year effort known as the Generic Kernel Image (GKI) project. For information about this project and its phases, refer to [The Generic Kernel Image (GKI) project](/docs/core/architecture/kernel/generic-kernel-image).\n| **Note:** Kernels are referred to by their platform version followed by a kernel version. For example, `android15-6.6` is kernel for Android 15 with a version of `6.6`.\n\nKernel glossary\n---------------\n\nFollowing are terms used throughout the kernel documentation.\n\n### Kernel types\n\n*Android Common Kernel (ACK)*\n: A kernel that is downstream of a LTS kernel and includes patches that are\n important to the Android community. These patches haven't been merged into\n Linux mainline or Long Term GKI kernels.\n\nKernel with versions of 5.10 and higher are also referred to as\n[Generic Kernel Image (GKI)](#gkik) kernels.\n\n*Android Open Source Project (AOSP) kernel*\n: See [Android Common Kernel](#ack).\n\nAndroid 12 features can't be backported to 4.19 kernels; the feature set would\nbe similar to a device that launched with 4.19 on Android 11 and upgraded to\nAndroid 12.\n\n*Generic Kernel Image (GKI) kernel*\n\n: Any 5.10 and higher [ACK kernel](#ack)(aarch64 only). The GKI kernel has these\n two parts:\n\n - *Generic kernel* - The portion of the GKI kernel that is common across\n all devices.\n\n - *GKI modules* - Kernel modules built by Google that can be dynamically\n loaded on devices where applicable. These modules are built as artifacts\n of the GKI kernel and are delivered alongside GKI as the\n `system_dlkm_staging_archive.tar.gz` archive. GKI modules are signed by\n Google using the kernel build time key pair and are compatible only with the\n GKI kernel that they're built with.\n\n*Kernel Module Interface (KMI) kernel*\n\n: See [GKI kernel](#gkik).\n\n*Long Term Supported (LTS) kernel*\n\n: A Linux kernel that's supported for 2 to 6 years. [LTS kernels](https://www.kernel.org/category/lts) are\n released once per year and are the basis for each of Google's\n [Android Common Kernels](#ack).\n\n### Branch types\n\n*ACK KMI kernel branch*\n: The branch for which [GKI kernels](#gkik) are built. Branch names correspond\n to kernel versions, such as `android15-6.6`.\n\n*Android-mainline*\n: The primary development branch for Android features. When a new\n [LTS kernel](#lts) is declared upstream, the corresponding new\n [GKI kernel](#gkik)GKI kernel is branched from android-mainline.\n\n*Linux mainline*\n:The primary development branch for the upstream Linux kernels, including LTS\nkernels.\n\n### Other terms\n\n*Certified boot image*\n: The kernel delivered in binary form (`boot.img`) and flashed onto the device.\n This image is considered certified because contains embedded certificates so\n Google can verify that the device ships with a kernel certified by Google.\n\n*Dynamically loadable kernel module (DLKM)*\n: A module that can be dynamically loaded during device boot depending on the\n needs of the device. GKI and vendor modules are both types of DLKMs. DLKMs are\n released in `.ko` form and can be drivers or can deliver other kernel\n functionality.\n\n*GKI project*\n: A Google project addressing kernel fragmentation by separating common core\n kernel functionality from vendor-specific SoC and board support into loadable\n modules.\n\n*Generic Kernel Image (GKI)*\n:A boot image certified by Google that contains a [GKI kernel](#gkik) built from\nan [ACK](#ack) source tree and is suitable to be flashed to the boot partition\nof an Android-powered device.\n\n*Kernel Module Interface (KMI)*\n: An interface between the [GKI kernel](#gkik) and vendor modules allowing\n vendor modules to be updated independently of the GKI kernel. This interface\n consists of kernel functions and global data that have been identified as\n vendor/OEM dependencies using per-partner symbol lists.\n\n*Vendor module*\n: A hardware-specific module developed by a partner and that contains SoC and\n device-specific functionality. A vendor module is a type of dynamically loadable\n kernel module.\n\nWhat's next\n-----------\n\nIf you're new to Android kernel development, start by reading the\nfollowing:\n\n- [Long Term Stable Kernels](/docs/core/architecture/kernel/releases) - Background on upstream LTS kernels which feed into ACKs.\n- [Android Common Kernels](/docs/core/architecture/kernel/android-common) - Background on ACKs.\n\nIf you're new to GKI kernel development, start by reading\n[GKI development](/docs/core/architecture/kernel/gki-dev)."]]