> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Yocto 中的内核集成

本节介绍 Qualcomm Linux 内核如何集成到 Yocto 构建系统中。它与 [Qualcomm Linux 内核指南](https://dragonwingdocs.qualcomm.com/System/Kernel/kernel-overview)之间有明确的边界划分 — 本页涵盖 Yocto 侧的集成；内核指南则涵盖内核开发和调试。

## **内核配方概述**

Qualcomm Linux 使用的 Linux 内核配方位于 `<workspace>/meta-qcom/recipes-kernel/linux`。Qualcomm Linux 支持长期支持（LTS）版 Qualcomm Linux 内核 v6.18.x。

在 `meta-qcom` 层中，有两个内核配方：

|         **内核配方**        |                      **用途**                      |
| :---------------------: | :----------------------------------------------: |
|   `linux-qcom_6.18.bb`  |             构建标准 Qualcomm Linux 内核镜像。            |
| `linux-qcom-rt_6.18.bb` | 构建实时 Qualcomm Linux 内核镜像。应用 `rt.config` 以实现实时运行。 |

有关包括 `SRCREV`、`SRC_URI` 和配置片段在内的完整配方详情，请参阅 [meta-qcom — 内核配方](./meta-qcom#kernel-recipes)。

## **内核配置流程**

Qualcomm Linux 内核配方使用一组分层的内核配置文件和片段：

|          **变体**         |                                   **配置和片段文件**                                   |
| :---------------------: | :-----------------------------------------------------------------------------: |
|   `linux-qcom_6.18.bb`  | `defconfig`、`hardening.config`、`prune.config`、`qcom.config`、`bsp-additions.cfg` |
| `linux-qcom-rt_6.18.bb` |                               与上面相同，另加 `rt.config`                              |

当设置了 `DEBUG_BUILD=1`（通过 `meta-qcom/ci/debug.yml`）时，还会应用以下额外片段：

```text theme={null}
KBUILD_CONFIG_EXTRA:append = " ${@oe.utils.vartrue('DEBUG_BUILD', '${S}/kernel/configs/debug.config', '', d)}"
KBUILD_CONFIG_EXTRA:append:aarch64 = " ${@oe.utils.vartrue('DEBUG_BUILD', '${S}/arch/arm64/configs/qcom_debug.config', '', d)}"
```

有关使用 `devtool` 进行内核开发，请参阅[使用 devtool 修改 Qualcomm Device Loader 源代码](./modify-qdl-source-using-devtool)和[使用 Yocto 开发内核](https://dragonwingdocs.qualcomm.com/System/Kernel/build-kernel-yocto)。

## **设备树集成**

设备树二进制文件（DTB）和覆盖文件（DTBO）由 `dtb-fit-image.bbclass` 类打包成 FIT 镜像。每个机器配置文件中的 `KERNEL_DEVICETREE` 变量用于选择要包含哪些 DTB 和 DTBO。

有关完整的设备树集成详情，包括 `FIT_DTB_COMPATIBLE` 条目和 FIT 镜像生成，请参阅 [meta-qcom — 包含 DTB 和 DTB 覆盖](./meta-qcom#include-dtb-and-dtb-overlay)。

有关设备树开发和平台设备树管理，请参阅内核指南中的[设备树架构](https://dragonwingdocs.qualcomm.com/System/Kernel/device-tree-architecture)和[查找和修改设备树](https://dragonwingdocs.qualcomm.com/System/Kernel/locate-and-modify-device-trees)。

## **树外内核模块**

要使用 Yocto 配方构建树外（out-of-tree）内核模块，请参阅[使用配方处理树外内核模块和设备树](./handling-out-of-tree-kernel-modules-and-device-tree-using-recipes)。

**注意**

Qualcomm Linux 仅在 `custom` 变体上支持内核外设备树覆盖。

## **后续步骤**

* 有关内核开发、配置和调试，请参阅 [Qualcomm Linux 内核指南](https://dragonwingdocs.qualcomm.com/System/Kernel/kernel-overview)。
* 要创建调试构建，请参阅[创建用于调试的构建](./create-a-build-for-debugging)。
