# 排查内核问题

要排查内核问题，请使用以下方法：

## 选错/没有可用的 DTB 导致启动失败

排查因 DTB 加载问题而导致的启动失败时，需要验证鉴权及 DTB 可用性，然后按以下步骤解决问题。

如下场景会导致启动失败：

- **身份验证失败**

    以下示例所示为因鉴权错误而导致的启动失败的日志：

Platform Subtype : 0
        DtPlatformLoadDtb qcs6490-rb3gen2.dtb is loaded
        Platform Subtype : -2090817768
        DtPlatformLoadSign qcs6490-rb3gen2.sgn is loaded
        failed to authenticate image !
        Copy to clipboard
- **由于 DTB 不可用导致失败**

    以下示例所示为因缺少 DTB 而导致的启动失败的日志：

DtPlatformLoadDtb qcs6490-rb3gen2.dtb is loading failed with Status = E
        DtPlatformDxeEntryPoint: no DTB blob could be loaded, defaulting to ACPI (Status == Not Found)
        Copy to clipboard

    要修复 DTB 不可用问题，请执行以下步骤：

    - 验证相应的 DTB 文件是否包含在打包的 `efi.bin` 文件中。
    - 在主机开发机器本地挂载 `efi.bin` 文件以验证以下内容：

mount -t vfat efi.bin /mnt/
            
            ls -lR /mnt/
            Copy to clipboard
- **从内核日志中验证加载的 DTB**

    使用以下命令从内核日志验证启动期间加载的 DTB：

dmesg | grep -i model
        Copy to clipboard

## 串行控制台不工作

若要排查串行控制台日志失败问题，需在内核配置中启用特定的驱动程序并将相关参数添加到内核启动参数中。

- 在内核配置文件中启用以下驱动程序：

    - `CONFIG_SERIAL_QCOM_GENI=y`
    - `CONFIG_SERIAL_QCOM_GENI_CONSOLE=y`
- 将以下参数添加到内核启动参数中：

console=ttyMSM0,115200n8
        Copy to clipboard
- 若要从内核获取早期启动消息，需将以下参数添加到内核启动参数中：

earlycon
        Copy to clipboard

## 调试远程处理器故障

要排查 remoteproc 故障，请采集内核日志、使用匹配的固件签名文件并验证设备中的固件位置。

- 确保所有匹配的子系统镜像均已无错误刷写。
- 验证内核日志中是否存在任何错误。

    以下所示为内核日志示例：

0x000000000A27652C |   5198.790423:   qcom_q6v5_pas 3000000.remoteproc: fatal error received: err_inject_crash.c:413:Crash injected via Diag
        0x000000000A276689 |   5198.801061:   remoteproc remoteproc2: crash detected in 3000000.remoteproc: type fatal error
        0x000000000A2767A1 |   5198.809602:   remoteproc remoteproc2: handling crash #1 in 3000000.remoteproc
        0x000000000A27688E |   5198.816837:   remoteproc remoteproc2: recovering 3000000.remoteproc
        0x000000000A276971 |   5198.823784:   qcom_q6v5_pas 8a00000.remoteproc: subsystem event rejected
        Copy to clipboard
- 禁用以下子系统重启功能，确保 remoteproc 崩溃签名显示在内核日志中：

echo disabled > /sys/kernel/debug/remoteproc/remoteprocN/recovery
        Copy to clipboard
- 确认 rootfs 文件系统中的 `/lib/firmware/qcom/<SoC>` 中是否存在所有必要的固件文件。

## 调试配置或符号未反映在镜像中

若要调试内核配置更改问题，即配置或符号未反映在镜像中的问题，可按照下列步骤操作：

1. 将调试配置驱动程序添加到 `arch/arm64/configs/qcom_debug.config` 文件。
2. 在运行 `bitbake` 命令前导出 `DEBUG_BUILD=1` 宏。

Note

旧的调试配置文件与定制 BSP 版本有关。将更改添加到基本 BSP 变体的 `qcom.cfg` 文件中。

## 系统内存不足

要调试系统可用内存耗尽的情况，请参见[内存不足](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-12/debugging_linux_kernel.html#out-of-memory)。

## 在启动过程中识别 DTB

设备启动时，boot loader 会验证以下 ID 并加载相应的 DTB 文件：

qcom,msm-id = <x z>;
    qcom,board-id = <y y'>;
    Copy to clipboard

- x = ID for SoC
- z = ID for SoC revision (reserved field)
- y = CDP、MTP（硬件变体）和平台的 ID
- y’ = 子类型的 ID（若不存在则假定为 0）

## 调试 RT 内核

以下方法用于排查 RT 内核中的问题：

- 如何验证底层内核是否为实时内核？

    启动完成后，运行以下命令来验证内核类型：

uname -r
        6.6-rt15
        uname -v
        SMP PREMPT_RT
        Copy to clipboard
- 如何使驱动程序符合 RT 要求？

    确保同步原语不会破坏 RT 假设。

    以下是可能会破坏 RT 假设并导致系统行为异常的场景示例：

/* Acquiring a preemptible lock in non preemptible context */
        
        preempt_disable( )
        ……
        spin_lock( )
        
        /* Acquiring a preemptible lock in non preemptible context /
        
        raw_spin_lock( )
        ……
        spin_lock( )
        
        /* Acquiring a non preemptible lock in preemptible context /
        
        local_lock_irq( )
           …..
        raw_spin_lock( )
        Copy to clipboard
- 调试 RT 内核配置

    以下所列为 RT 内核的调试配置：

    - `CONFIG_DEBUG_ATOMIC_SLEEP` - 验证原子操作区段内的休眠。
    - `CONFIG_PROVE_RAW_LOCK_NESTING` - 允许 `raw_spinlock` 与自旋锁嵌套。确保不违反 `PREEMPT_RT` 内核的锁嵌套规则。

        在调试时，可以从 RT 内核切换到非 RT 内核。若要切换，请更改 `meta-qcom-realtime/conf/layer.conf` 文件以更改 `linux-qcom-base-rt` 中的虚拟/内核设置，然后重新编译。

        运行以下命令，执行更改：

- PREFERRED_PROVIDER_virtual/kernel = "linux-qcom-base"
            + PREFERRED_PROVIDER_virtual/kernel = "linux-qcom-base-rt"
            Copy to clipboard

有关 RT 内核锁原语的更多信息，请参见 [Lock types and their rules—The Linux Kernel documentation](https://www.kernel.org/doc/html/latest/locking/locktypes.html)。

## 排查 virtio 问题

使用以下方法排查 virtio 问题：

- 确保内核已按所需配置编译。
- 验证 QEMU 命令行选项或 libvirt XML 配置。
- 核实系统日志中是否存在错误。
- 在 QEMU 命令行中使用可用的跟踪后端为 virtio 启用跟踪功能。有关 KVM 跟踪的更多信息，请参阅 [KVM 跟踪](https://docs.qualcomm.com/doc/80-70022-3SC/topic/virtualization.html#kvm-traces)。

Last Published: Nov 04, 2025

[Previous Topic
配置内核调试器](https://docs.qualcomm.com/bundle/publicresource/80-70022-3SC/topics/configure-kernel-debugger.md) [Next Topic
参考资料](https://docs.qualcomm.com/bundle/publicresource/80-70022-3SC/topics/references.md)