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

# 使用 Yocto 构建 Qualcomm Linux

本页面面向希望使用 Yocto 项目从头构建 Qualcomm Linux 的用户。
它介绍了构建所需的关键 Yocto 概念，并逐步讲解整体工作流——从配置到执行。

## **主机系统要求**

* Configuration
  * x86 machine
  * Quad-core CPU, for example, Intel i7-2600 at 3.4 GHz (equivalent or better)
  * 300 GB free disk space (swap partition > 32 GB)
  * 16 GB RAM

- Tools
  * Git 1.8.3.1 or later versions
  * Tar 1.28 or later versions
  * Python 3.10.2 or later versions
  * GCC 10.1 or later versions
  * GNU Make 4.0 or later versions
  * Kas 4.8 or later versions

* Permissions
  * `sudo` permission is required to run a few commands

## **主机设置**

The following instructions are intended for use on a Ubuntu host system. The
Yocto build is also supported on other [distributions](https://docs.yoctoproject.org/ref-manual/system-requirements.html#supported-linux-distributions)
compatible with Yocto, but no validation is performed against them.

* Install the following packages to prepare your host environment for the Yocto build

  ```bash theme={null}
  sudo apt update
  sudo apt install build-essential chrpath cpio debianutils diffstat \
       file gawk gcc git iputils-ping libacl1 locales python3 python3-git \
       python3-jinja2 python3-pexpect python3-pip python3-subunit socat \
       texinfo unzip wget xz-utils zstd
  ```

* Qualcomm uses the `kas` tool to sync and build the Yocto project. Use
  the following steps to install `kas` on your system

  <Note>
    On older Ubuntu versions, the `kas` version provided by the system package
    manager may be outdated. Using `pipx` is the recommended way to install kas.
  </Note>

  1. Install `pipx`

     ```bash theme={null}
     sudo apt install pipx
     ```

  2. Add the `pipx` install location to your `PATH`

     ```bash theme={null}
     pipx ensurepath
     ```

     This command updates your shell's startup file, so the change only
     takes effect in new shell sessions. Restart your shell session before
     continuing to the next step.

  3. Install `kas` (version 4.8 or higher is required)

     ```bash theme={null}
     pipx install "kas>=4.8"
     ```

* Verify if the kas installation is successful.

  ```bash theme={null}
  kas --version
  ```

## **kas 配置模型**

Qualcomm 使用 `kas` 工具来同步和构建 Yocto 项目。`kas` 配置模型使用 YAML 文件来声明构建中要包含的层、机器和发行版。这些 YAML 文件位于 `meta-qcom/ci/` 目录中。

一个典型的 `kas` 构建命令组合了：

* 一个机器 YAML 文件（例如 `meta-qcom/ci/iq-9075-evk.yml`）
* 一个发行版 YAML 文件（例如 `meta-qcom/ci/qcom-distro.yml`）

```bash theme={null}
kas build meta-qcom/ci/<machine-name>.yml:meta-qcom/ci/<distro-name>.yml
```

## **选择 MACHINE 和 DISTRO**

The following table lists the supported `MACHINE` and `DISTRO` combinations. Use these values when invoking the `kas` command.

| **MACHINE**                                                                                                                                                                                    | **DISTRO**                                                                                                              |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------- |
| <ul><li>`iq-615-evk`</li><li>`iq-8275-evk`</li><li>`qcm6490-idp`</li><li>`rb3gen2-core-kit`</li><li>`iq-9075-evk`</li><li>`iq-x7181-evk`</li><li>`iq-x5121-evk`</li><li>`shikra-evk`</li></ul> | <ul><li>`qcom-distro`</li><li>`qcom-distro-catchall`</li><li>`qcom-distro-selinux`</li><li>`qcom-distro-sota`</li></ul> |

## 配置参数

The following table describes the build tags for the current release. These
values need to be substituted in the build commands.

| Release Tag           | Identifier |
| --------------------- | ---------- |
| meta-qcom-release-tag | qli-2.1    |

## **构建说明**

* Download Qualcomm's Yocto layer `meta-qcom`. For the latest
  `<meta-qcom-release-tag>`, see [Configuration Parameters](#configuration-parameters).

  ```bash theme={null}
  git clone https://github.com/qualcomm-linux/meta-qcom -b <meta-qcom-release-tag>
  ```

- Build the software image using `kas`. You define build targets based
  on machine and distro combinations.

  <CodeGroup>
    ```bash IQ-9075-EVK theme={null}
    kas build meta-qcom/ci/iq-9075-evk.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
    ```

    ```bash IQ-8275-EVK theme={null}
    kas build meta-qcom/ci/iq-8275-evk.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
    ```

    ```bash IQ-615-EVK theme={null}
    kas build meta-qcom/ci/iq-615-evk.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
    ```

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

    ```bash IQ-X7181-EVK theme={null}
    kas build meta-qcom/ci/iq-x7181-evk.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
    ```

    ```bash IQ-X5121-EVK theme={null}
    kas build meta-qcom/ci/iq-x5121-evk.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
    ```

    ```bash IQ2390 / CQ2390 theme={null}
    kas build meta-qcom/ci/shikra-evk.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
    ```
  </CodeGroup>

* The build creates a single tarball containing all the relevant files to
  perform a full clean flash, including partition metadata, boot firmware,
  ESP partition and the rootfs. After a successful build, check if the
  qcomflash tarball exists in the build artifacts. The following examples
  use `qcom-multimedia-proprietary-image` as the image name.

  <CodeGroup>
    ```bash IQ-9075-EVK theme={null}
    ls build/tmp/deploy/images/iq-9075-evk/qcom-multimedia-proprietary-image-iq-9075-evk.rootfs.qcomflash.tar.gz
    ```

    ```bash IQ-8275-EVK theme={null}
    ls build/tmp/deploy/images/iq-8275-evk/qcom-multimedia-proprietary-image-iq-8275-evk.rootfs.qcomflash.tar.gz
    ```

    ```bash IQ-615-EVK theme={null}
    ls build/tmp/deploy/images/iq-615-evk/qcom-multimedia-proprietary-image-iq-615-evk.rootfs.qcomflash.tar.gz
    ```

    ```bash QCS6490 theme={null}
    ls build/tmp/deploy/images/rb3gen2-core-kit/qcom-multimedia-proprietary-image-rb3gen2-core-kit.rootfs.qcomflash.tar.gz
    ```

    ```bash IQ-X7181-EVK theme={null}
    ls build/tmp/deploy/images/iq-x7181-evk/qcom-multimedia-proprietary-image-iq-x7181-evk.rootfs.qcomflash.tar.gz
    ```

    ```bash IQ-X5121-EVK theme={null}
    ls build/tmp/deploy/images/iq-x5121-evk/qcom-multimedia-proprietary-image-iq-x5121-evk.rootfs.qcomflash.tar.gz
    ```

    ```bash IQ2390 / CQ2390 theme={null}
    ls build/tmp/deploy/images/shikra-evk/qcom-multimedia-proprietary-image-shikra-evk.rootfs.qcomflash.tar.gz
    ```
  </CodeGroup>

## **相关主题**

* [如何构建 meta-qcom 的主线变体](./how-to-build-meta-qcom-mainline)
* [如何在容器化环境中构建镜像？](./how-to-build-meta-qcom-container)
* [如何使用旧版 repo manifest 方法构建 meta-qcom](./how-to-build-repo-manifest)
* [如何使用旧版 meta-qcom-releases 方法构建 meta-qcom](./how-to-build-meta-qcom-releases)
* [如何在 meta-qcom 构建中启用调试配置](./how-to-build-enable-debug-conf)
* [如何为 Yocto 构建设置共享缓存](./how-to-setup-shared-yocto-cache)
* [如何为 Yocto BSP 构建配置存储类型](./how-to-configure-storage-type)
* [如何增加系统内存以避免 OOM 错误](./how-to-increase-system-memory)
* [如何使用 kas 执行常见任务](./how-to-perform-common-tasks)
* [如何排查常见构建失败问题](./troubleshooting-yocto-builds)

## **后续步骤**

* 要将您构建的镜像烧录到设备上，请参见[烧录软件镜像](/zh/Key-Documents/Flash-Guide/flash-with-qdl)。
