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

# 安装和启动内核

构建成功后，Qualcomm<sup>®</sup> Linux 启动系统使用两个已烧写的镜像来启动
内核：`efi.bin`（ESP 分区）和 `dtb.bin`（DTB 分区）。

## 镜像组成

Yocto 构建将内核工件打包成可烧写的镜像：

* **`efi.bin`** 是 EFI 系统分区（ESP）镜像。包含 systemd-boot（启动管理器）
  以及打包为 UKI type-2 镜像的内核，后者捆绑了内核、initramfs 以及可选的
  设备树。烧写到 `efi` 分区。
* **`dtb.bin`** 是 DTB 分区镜像。包含所有已编译的设备树 blob（DTB）。
  烧写到 `dtb_a` 分区。

**表：内核构建工件**

| 镜像        | 镜像名称                                     | 构建部署路径                                                          | 详情                                            |
| --------- | ---------------------------------------- | --------------------------------------------------------------- | --------------------------------------------- |
| 内核 ELF    | `vmlinux`                                | `build/tmp/deploy/images/<machine>/<image>-*.rootfs.qcomflash/` | 带调试符号的输出内核 ELF。                               |
| Initramfs | `initramfs-qcom-image-<machine>.cpio.gz` | `build/tmp/deploy/images/<machine>/`                            | CPIO 格式的 initramfs。                           |
| 内核镜像      | `Image`                                  | `build/tmp/deploy/images/<machine>/`                            | 原始内核二进制文件。systemd-boot 不支持压缩镜像。               |
| 内核模块      | `modules-<machine>.tgz`                  | `build/tmp/deploy/images/<machine>/`                            | 可动态加载的内核模块（DLKM）。                             |
| 设备树 blob  | `<SoC>-<board>-<variant>.dtb`            | `build/tmp/deploy/images/<machine>/`                            | 单个设备树 blob。                                   |
| ESP 分区    | `efi.bin`                                | `build/tmp/deploy/images/<machine>/<image>-*.rootfs.qcomflash/` | systemd-boot、内核和 initramfs 打包为 UKI type-2 镜像。 |
| DTB 分区    | `dtb.bin`                                | `build/tmp/deploy/images/<machine>/<image>-*.rootfs.qcomflash/` | 打包在 FIT 镜像中的所有 DTBO。                          |

## 部署内核工件

如果您之前没有烧写过所有启动二进制文件，请先按照
[带固件的 BSP 镜像构建](https://dragonwingdocs.qualcomm.com/Key-Documents/Firmware-Guide/build-firmware)
中的完整烧写说明操作。

对于后续仅涉及内核的更新，您可以增量烧写 `efi.bin` 和 `dtb.bin`：

```bash theme={null}
# Navigate to the build output directory
cd build/tmp/deploy/images/<machine>/<image>-*.rootfs.qcomflash/

# Flash the ESP and DTB partition images
fastboot flash efi efi.bin
fastboot flash dtb_a dtb.bin
fastboot reboot
```

<Note>
  在内核或 DTS 更改后，`efi.bin` 和 `dtb.bin` 必须一起烧写，以保持内核
  与设备树同步。
</Note>

## 验证正在运行的内核

设备重启后，确认正在运行的是预期的内核版本，并且启动过程没有出现错误。

### 连接到设备

使用以下方法之一访问设备上的 shell：

* **串口控制台（UART）**：推荐用于早期启动检查。有关设置说明，请参阅
  [连接到您的目标设备](./connect-to-your-target)。
* **ADB shell**：设备完全启动后使用：

```bash theme={null}
adb shell
```

* **SSH**：使用设备 IP 地址通过网络连接：

```bash theme={null}
ssh root@<device-ip>
```

### 检查内核版本

```bash theme={null}
# Short version string
uname -r

# Full version, architecture, and build timestamp
uname -a

# Detailed version including compiler
cat /proc/version
```

`uname -r` 的输出应反映您构建并烧写的内核版本（例如，LTS 轨道的
`6.18.x` 字符串）。

### 检查启动健康状况

检查内核环形缓冲区中早期启动阶段的错误或警告：

```bash theme={null}
# Print the first 50 lines of kernel messages
dmesg | head -50

# Filter for errors and warnings only
dmesg --level=err,warn
```

在使用 systemd 的系统上，当前启动的内核消息也可以通过以下方式查看：

```bash theme={null}
journalctl -k -b
```

### 确认内核模块

验证预期的内核模块已成功加载：

```bash theme={null}
# List all loaded modules
lsmod

# Check if Qualcomm-specific modules are present
lsmod | grep qcom
```

要检查所需模块是否缺失，请在目标设备上运行以下命令，确认该模块已包含
在内核配置中，并且在配置更改后已重新构建镜像：

```bash theme={null}
zcat /proc/config.gz | grep CONFIG_<Module>
```

### 故障排除

如果内核版本与构建的版本不匹配，或者设备无法启动：

* 通过重新运行 `fastboot flash` 命令并检查 `OKAY` 响应，确认烧写过程
  没有出现错误。
* 确认 `efi.bin` 和 `dtb.bin` 已分别烧写到正确的分区（`efi` 和 `dtb_a`）。
* 有关启动失败和内核 panic 分析，请参阅
  [排查内核问题](./troubleshoot-kernel-issues)。
* 有关串口控制台日志捕获，请参阅
  [内核日志](./kernel-logging)。
