> ## 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.

# 访问内核源代码

Qualcomm<sup>®</sup> Linux 内核源代码公开托管在 GitHub 上，无需任何特殊凭据。请选择与您的构建工作流相匹配的访问路径。

**表：内核分支**

| 分支            | Yocto 配方                 | 用例                                |
| ------------- | ------------------------ | --------------------------------- |
| `qcom-6.18.y` | `linux-qcom_6.18.bb`     | LTS 生产构建；推荐用于 SoC 启用（bring-up）和集成 |
| `qcom-next`   | `linux-qcom-next_git.bb` | 上游贡献以及针对最新内核的验证                   |

## Yocto 工作流

Yocto 工作流通过 `meta-qcom` 层访问内核。在构建期间，BitBake 会自动获取内核源代码。

获取以下仓库的访问权限：

* **meta-qcom**（层）：[https://github.com/qualcomm-linux/meta-qcom](https://github.com/qualcomm-linux/meta-qcom)

发布标签遵循 `qli-<version>` 约定（例如 `qli-2.0`）。有关可用标签，请参阅 [Qualcomm Linux 发行说明 - 简介](https://dragonwingdocs.qualcomm.com/Key-Documents/Software-Release-Notes/introduction)。

### 使用 kas 同步 meta 层

在您的工作区根目录下运行以下命令。同步后，工作区中将包含一个 `meta-qcom/` 目录。

```bash theme={null}
# Clone meta-qcom at the target release tag (e.g. -b qli-2.0)
git clone https://github.com/qualcomm-linux/meta-qcom \
    -b <release-tag>
```

要在不运行完整构建的情况下获取并解包内核源代码，请打开 kas shell（将 `rb3gen2-core-kit.yml` 替换为您的机器 YML）并运行 `unpack` 任务：

```bash theme={null}
kas shell meta-qcom/ci/rb3gen2-core-kit.yml:meta-qcom/ci/qcom-distro.yml
```

```bash theme={null}
bitbake -c unpack linux-qcom
```

之后即可在以下位置获得内核源代码：

```text theme={null}
build/tmp/work-shared/<machine>/kernel-source/
```

内核配方和版本在 `meta-qcom/conf/machine/include/qcom-base.inc` 中选择，每个机器配置都会继承该文件：

```text theme={null}
# Provider for linux kernel
PREFERRED_PROVIDER_virtual/kernel = "linux-qcom"
PREFERRED_VERSION_virtual/kernel = "6.18%"
```

<Note>
  对于 LTS BSP 选择 `linux-qcom`，对于主线（mainline）BSP 选择 `linux-qcom-next`，并将 `PREFERRED_VERSION_virtual/kernel` 留空。
</Note>

配方文件为每个发行版指定了确切的 `SRCREV` 和 `SRCBRANCH`：

* LTS 配方：[recipes-kernel/linux/linux-qcom\_6.18.bb](https://github.com/qualcomm-linux/meta-qcom/blob/master/recipes-kernel/linux/linux-qcom_6.18.bb)
* 主线配方：[recipes-kernel/linux/linux-qcom-next\_git.bb](https://github.com/qualcomm-linux/meta-qcom/blob/master/recipes-kernel/linux/linux-qcom-next_git.bb)

有关完整的构建步骤，请参阅[使用 Yocto 构建内核](./build-kernel-yocto)。

## 独立工作流

对于独立工作流（不构建完整 Yocto 镜像的纯内核构建），请克隆内核仓库：

```bash theme={null}
git clone --branch qcom-6.18.y \
    https://github.com/qualcomm-linux/kernel.git kernel
```

要与发布构建中使用的确切源代码版本保持一致，请检查 `meta-qcom/recipes-kernel/linux/linux-qcom_6.18.bb` 中的 `SRCREV` 字段。

有关完整的构建步骤，请参阅[不使用 Yocto 构建内核](./build-kernel-standalone)。
