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

# 将 IQ9 EVK 用作主线 Linux 内核的本地 Arm 构建和调试机器

> 将 IQ9-EVK 设置为本地 Arm 开发和内核构建机器。

<div
  style={{
width: "100%",
borderRadius: "14px",
overflow: "hidden",
backgroundImage: "url('https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/images/tutorials/my-post-hero.png')",
backgroundSize: "cover",
backgroundPosition: "center",
height: "260px",
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "relative",
marginBottom: "1.5rem"
}}
>
  <div
    style={{
position: "absolute",
bottom: "16px",
left: "50%",
transform: "translateX(-50%)",
background: "rgba(255,255,255,0.15)",
border: "1px solid rgba(255,255,255,0.4)",
color: "#fff",
fontSize: "0.75rem",
fontWeight: 700,
letterSpacing: "1px",
padding: "5px 14px",
borderRadius: "20px",
textTransform: "uppercase",
whiteSpace: "nowrap",
zIndex: 1
}}
  >
    Dragonwing · Qualcomm
  </div>
</div>

<div style={{ marginBottom: "2rem" }}>
  <div
    style={{
fontSize: "0.72rem",
fontWeight: 700,
color: "#31017D",
letterSpacing: "1.5px",
textTransform: "uppercase",
marginBottom: "0.5rem"
}}
  >
    类别
  </div>

  <p style={{ fontSize: "0.95rem", color: "#555", lineHeight: 1.7, margin: "0 0 0.75rem" }}>
    本文的简短介绍。请与教程首页的卡片摘要保持一致。
  </p>

  <div style={{ fontSize: "0.85rem", color: "#888", display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" }}>
    <span>作者或团队</span>
    <span>·</span>
    <span>YYYY 年 MM 月 DD 日</span>
    <span>·</span>
    <a href="/zh/tutorial" style={{ color: "#31017D", fontWeight: 600, textDecoration: "none" }}>← 全部文章</a>
  </div>
</div>

<hr style={{ border: "none", borderTop: "1px solid #eee", margin: "0 0 2rem" }} />

## 概述

IQ9 EVK 集成了 8 个 1.9 GHz 的 Cortex-A78 核心、12 GB 内存和 110 GB 存储——单条 USB-C 线即可供电，便于携带。当时我缺少一台本地 ARM 构建机，而 IQ9 EVK 就在手边。何乐而不为？

本篇博客涵盖两方面内容：

1. **本地 ARM 构建** — 将 IQ9 EVK 本身作为主线内核的 ARM 原生构建机器
2. **主线内核调试** — 更重要的是，这块开发板运行自己构建的产物，使其成为一个自包含的主线内核启动与调试平台

## 1. 在 IQ9 EVK 上进行本地 ARM 构建

IQ9 EVK 出厂预装 Qualcomm Linux（QLI 2.0）——这是一个基于 Yocto 的镜像，专为运行预构建应用而设计。它在设计上是被锁定的：没有 `apt-get`，也没有 `opkg`。

```bash theme={null}
$ cat /etc/issue
Qualcomm Linux Reference Distro (OTA-enabled) 2.0 \n \l

$ apt-get update
sh: apt-get: command not found

$ opkg --version
sh: opkg: command not found
```

要获得合适的构建环境，请按照[使用 Qualcomm Launcher 刷机](/zh/Ubuntu/devices/iq9075-evk/update-software/flash-using-qualcomm-launcher)刷入 Ubuntu

```
$ cat /etc/issue
Ubuntu 24.04.4 LTS \n \l
```

安装构建依赖：

```
sudo apt update && sudo apt upgrade -y

sudo apt install -y \
    flex bison bc \
    build-essential \
    libssl-dev libelf-dev \
    libncurses-dev \
    git make gcc \
    kmod cpio rsync \
    python3 perl
```

在开发板上原生克隆并构建主线内核：

```
git clone -b main https://github.com/qualcomm-linux/kernel-topics.git
make defconfig
make -j8
```

凭借 8 核和 12 GB 内存，构建可以在开发板上顺畅运行——无需交叉编译。

## 2. 在 IQ9 EVK 上调试主线内核

我们只有一台 IQ9 EVK — 没有备用机，没有第二块板。目标：调试主线内核而不损坏板子，同时能干净地回退到发布版 Ubuntu 镜像。

### 我们尝试过的方案（以及失败原因）

**a. kexec** — IQ9 的看门狗会在调试内核完全启动之前触发并强制重启。

**b. fastboot boot** — 在 IQ9 上尚不支持，而且无论如何都需要一台单独的宿主机。

**c. GRUB 菜单加载拼接了 DTB 的内核** — DTB 无法通过这种方式正确传递。

### 有效的方案：自定义 GRUB 菜单项

添加一个新的 GRUB 菜单项，指向调试内核和 DTB：

```bash theme={null}
# refer to /boot/grub/grub.cfg for the template
sudo vi /etc/grub.d/40_custom
```

```bash theme={null}
menuentry 'Ubuntu_debug' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-debug' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  c5de3ef5-e2b1-47ae-a2eb-34267d2d1441
        else
          search --no-floppy --fs-uuid --set=root c5de3ef5-e2b1-47ae-a2eb-34267d2d1441
        fi
        linux   /boot/Image dtb=/lemans-evk.dtb root=UUID=c5de3ef5-e2b1-47ae-a2eb-34267d2d1441 ro console=ttyMSM0,115200n8 pcie_pme=nomsi earlycon video=LVDS-1:d
        initrd  /boot/initramfs.cpio.gz
}
```

```bash theme={null}
sudo update-grub
```

部署构建产物：

```bash theme={null}
cd kernel-nord
# initramfs.cpio.gz must include the compiled kernel modules for this kernel build
sudo cp initramfs.cpio.gz /boot/
sudo cp arch/arm64/boot/dts/qcom/lemans-evk.dtb /boot/efi/
sudo cp arch/arm64/boot/Image /boot/

sudo reboot
```

启动时，当控制台显示：

```
The highlighted entry will be executed automatically in 3s.
```

选择 `*Ubuntu_debug` 以启动到主线内核。

### 验证

```bash theme={null}
$ uname -a
Linux qcom-armv8a 7.2.0-rc5-gf5098b6bae76 #1 SMP PREEMPT Fri Jul 31 07:31:15 UTC 2026 aarch64 GNU/Linux

$ mount /dev/sda3 /mnt
[   46.588831] EXT4-fs (sda3): mounted filesystem c5de3ef5-e2b1-47ae-a2eb-34267d2d1441 r/w with ordered data mode.

$ ls /mnt/home/ubuntu/
kernel-nord
```

主线内核 7.2-rc5 已成功运行。GRUB 中发布版 Ubuntu 的菜单项保持完整——如果出现任何问题，只需重启并选择默认菜单项即可。不会变砖。🎉

下次重启时，GRUB 会自动默认回到发布版 Ubuntu 镜像——无需人工干预。这为我们提供了一个安全、可重复的循环：

* 启动到 `Ubuntu_debug` 以测试主线内核
* 重启 → 自动回到稳定的发布版
* 迭代、修复、重复

这个工作流让调试最新主线内核和提交补丁变得非常方便。例如，我最早发现的其中一件事就是：**主线内核在 IQ9 上重启功能无法工作** — 得益于一个干净且低风险的调试环境，这个问题很快就被定位了。

尽情享用！🚀
