# GitHub 工作流程（固件和附加组件）

Source: [https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html)

Note: 这些步骤仅适用于授权用户。要升级您的访问权限，可访问 [http://www.qualcomm.com/support/working-with-qualcomm](http://www.qualcomm.com/support/working-with-qualcomm)。

要使用选择性专有源和二进制文件/库编译包括 `meta-qcom-hwe`、`meta-qcom-extras`、`meta-qcom-qim-product-sdk` 和 `meta-qcom-robotics-sdk` 在内的各种 Qualcomm Linux Yocto 层，可按照这些分步参考说明进行操作。

## 主机要求

Source: [https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html)

| 配置 | 工具 | 权限 |
| --- | --- | --- |
| x86 机器 | Git 1.8.3.1 或更高版本 | 有些命令在执行时需要 `sudo` 权限。 |
| 至少四核 CPU，例如 Intel i7-2600 @ 3.4 GHz（同等或更高配置） | Tar 1.28 或更高版本 | 有些命令在执行时需要 `sudo` 权限。 |
| 300 GB 可用磁盘空间（交换分区 &gt; 32 GB） | Python 3.10.2 或更高版本 | 有些命令在执行时需要 `sudo` 权限。 |
| 16 GB RAM | GCC 7.5 或更高版本 | 有些命令在执行时需要 `sudo` 权限。 |
| Ubuntu 22.04 | GNU Make 4.0 或更高版本 | 有些命令在执行时需要 `sudo` 权限。 |
|  |  |  |
|  |  |  |
|  |  |  |
|  |  |  |

## 安装 QSC CLI

Source: [https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html)

安装 `qsc-cli`：
1. 安装 curl（如果尚未安装）：

        sudo apt install curlCopy to clipboard
2. 下载 `qsc-cli` 的 Debian 软件包：

        cd <workspace_path>
        curl -L https://softwarecenter.qualcomm.com/api/download/software/qsc/linux/latest.deb -o qsc_installer.debCopy to clipboard
3. 安装 `qsc-cli` Debian 软件包：

        sudo dpkg -i qsc_installer.debCopy to clipboard
4. 登录到 `qsc-cli`：

        qsc-cli login -u <username>Copy to clipboard

Note: 需要登录一次 [chipcode.qti.qualcomm.com](http://chipcode.qti.qualcomm.com/) 才能下载 Qualcomm 专有的 git 代码仓库。使用您的 Qualcomm 帐号密码完成此步骤。
有关更多详细信息，参见[方法](https://docs.qualcomm.com/doc/80-70014-254Y/topic/how_to.html)章节中与 `qsc-cli` 相关的主题。

## Ubuntu 主机配置

Source: [https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html)

Ubuntu 主机需要进行一些配置操作，确保所需的软件工具已准备就绪。

1. 安装以下软件包：

        sudo apt update
        sudo apt install repo gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint xterm python3-subunit mesa-common-dev zstd liblz4-tool locales tar python-is-python3 file libxml-opml-simplegen-perl vim whiptail
        sudo apt-get install lib32stdc++6 libncurses5 checkinstall libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev curlCopy to clipboard
2. 将 Qualcomm 登录 ID 及 PAT 添加到主目录下的 `.netrc` 文件中：

        # Log in to qsc-cli to generate PAT
        qsc-cli login -u <username>
        # Run the following command to generate PAT
        qsc-cli pat --get
        # This command gives output as shown in the following note
        # The last line in this output is the token, which can be used to access
        # Qualcomm Proprietary repositories. This token expires in two weeks.Copy to clipboard

Note: 
                            
user@hostname:/local/mnt/workspace$ qsc-cli pat --get

[Info]: 启动 qsc-cli 版本 0.0.0.9

**5LThNlklb55mMVLB5C2KqUGU2jCF**

        vim ~/.netrc # add the following entries
         
        machine chipmaster2.qti.qualcomm.com
        login <your Qualcomm login id>
        password <your PAT token>
         
        machine qpm-git.qualcomm.com
        login <your Qualcomm login id>
        password <your PAT token>Copy to clipboard
3. 设置语言环境（如果尚未设置）：

        sudo locale-gen en_US.UTF-8
        sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
        export LC_ALL=en_US.UTF-8
        export LANG=en_US.UTF-8Copy to clipboard
4. 更新 git 配置：

        # Check if your identity is configured in .gitconfig
        git config --get user.email
        git config --get user.name
         
        # Run the following commands if you do not have your account identity set in .gitconfig
        git config --global user.email <Your email ID>
        git config --global user.name <"Your Name">
         
        # Add the following UI color option for output of console (optional)
        git config --global color.ui auto
         
        # Add the following git configurations to fetch large size repositories and to avoid unreliable connections
        git config --global http.postBuffer 1048576000
        git config --global http.maxRequestBuffer 1048576000
        git config --global http.lowSpeedLimit 0
        git config --global http.lowSpeedTime 999999
        
        # Add the following git configurations to follow remote redirects from http-alternates files or alternates
        git config --global http.https://chipmaster2.qti.qualcomm.com.followRedirects true
        git config --global http.https://qpm-git.qualcomm.com.followRedirects trueCopy to clipboard
5. 安装 Python 3.10.2：
Note: 如果已经安装 python 3.10.2 或更高版本，可跳过以下说明：

        python --version
        # Download it in a directory of your choice 
        wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz
        tar -xvf Python-3.10.2.tgz
        cd Python-3.10.2
        # Use sudo if you need to access /opt
        ./configure --prefix=/opt/python3 --enable-optimizations
        make
        make install
        ln -s /opt/python3/bin/python3  /opt/python3/bin/python
        export PATH=/opt/python3/bin:$PATH
        export PYTHONPATH=/opt/python3/lib:$PYTHONPATHCopy to clipboard

## 使用固件源代码编译

Source: [https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html)

### 同步固件

下表介绍了 Qualcomm Yocto 层和发布标签：

| 访问级别 | Yocto 层 | 发布标签 | 示例 |
| --- | --- | --- | --- |
| 使用任意电子邮件地址的注册开发人员 | `meta-qcom-hwe` | manifest release tag | qcom-6.6.28-QLI.1.1-Ver.1.1.xml |
| 使用任意电子邮件地址的注册开发人员 | `meta-qcom-qim-product-sdk` | manifest release tag | qcom-6.6.28-QLI.1.1-Ver.1.1\_qim-product-sdk-1.1.3.xml |
| 使用任意电子邮件地址的注册开发人员 | `meta-qcom-robotics-sdk` | manifest release tag | qcom-6.6.28-QLI.1.1-Ver.1.1\_robotics-product-sdk-1.1.xml |
| 经过验证的组织的注册开发人员 | `meta-qcom-extras` | meta-qcom-extras 发布标签 | r1.0\_00041.0 |
| 参见[Table : 映射访问级别](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html#build_private_distribution_with_extras__mapping_access_levels)。 | 不适用 | 固件发布标签 | r1.0\_00039.2 |
|  |  |  |  |
|  |  |  |  |

下表介绍了可根据需要和权限下载的固件发行版本：

| **访问级别** | **发行版** | Yocto 层 |
| --- | --- | --- |
| 经过验证的组织的注册开发人员 | 基础版本：High-level OS 和固件（仅限 GPS）源代码<br>`Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|NoModem` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras` |
| 经过验证的组织的注册开发人员 | 基础版本 + QIMP SDK<br>`Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|NM_QIMPSDK` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras`<br><br><br>                                    <br>`meta-qcom-qim-product-sdk` |
| 经过验证的组织的注册开发人员 | 基础版本 + QIMP SDK + QIRP SDK<br>`Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|NM_QIRPSDK` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras`<br><br><br>                                    <br>`meta-qcom-robotics-extras`<br><br><br>                                    <br>`meta-ros`<br><br><br>                                    <br>`meta-qcom-robotics`<br><br><br>                                    <br>`meta-qcom-robotics-distro`<br><br><br>                                    <br>`meta-qcom-robotics-sdk`<br><br><br>                                    <br>`meta-qcom-qim-product-sdk` |
| 具有额外访问权限的许可开发人员 | 基础版本：High-level OS 和固件（仅限 GPS）源代码<br>`Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras` |
| 具有额外访问权限的许可开发人员 | 基础版本 + QIMP SDK（仅限 GPS）<br>`Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|QIMPSDK` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras`<br><br><br>                                    <br>`meta-qcom-qim-product-sdk` |
| 具有额外访问权限的许可开发人员 | 基础版本：High-level OS 和固件（GPS 和 modem）源代码<br>`Qualcomm_Linux.SPF.1.0|AMSS|Standard|OEM|` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras` |
| 具有额外访问权限的许可开发人员 | 基础版本 + QIMP SDK（GPS 和 modem）<br>`Qualcomm_Linux.SPF.1.0|AMSS|Standard|OEM|QIMPSDK` | `meta-qcom`<br><br><br>                                    <br>`meta-qcom-hwe`<br><br><br>                                    <br>`meta-qcom-extras`<br><br><br>                                    <br>`meta-qcom-qim-product-sdk` |
|  |  |  |
|  |  |  |
|  |  |  |

有关 Yocto 层的说明，参见[Table :  1. Qualcomm Linux Yocto 层](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_from_source_qsc_gui_intro.html#concept_n2t_tjn_w1c__Yocto_layer_descriptions)。

Table : 固件发行版本和 git 代码仓库的映射

| 固件发行版本 | Git 命令 | 在 git clone 上同步固件的目录 |
| --- | --- | --- |
| Qualcomm\_Linux.SPF.1.0|AP|Standard|OEM|NoModem | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem.git` | `qualcomm-linux-spf-1-0_ap_standard_oem_nomodem` |
| Qualcomm\_Linux.SPF.1.0|AP|Standard|OEM|NM\_QIMPSDK | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk.git` | `qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk` |
| Qualcomm\_Linux.SPF.1.0|AP|Standard|OEM|NM\_QIRPSDK | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk.git` | `qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk` |
| Qualcomm\_Linux.SPF.1.0|AP|Standard|OEM| | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_ap_standard_oem.git` | `qualcomm-linux-spf-1-0_ap_standard_oem` |
| Qualcomm\_Linux.SPF.1.0|AP|Standard|OEM|QIMPSDK | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_ap_standard_oem_qimpsdk.git` | `qualcomm-linux-spf-1-0_ap_standard_oem_qimpsdk` |
| Qualcomm\_Linux.SPF.1.0|AMSS|Standard|OEM| | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_amss_standard_oem.git` | `qualcomm-linux-spf-1-0_amss_standard_oem` |
| Qualcomm\_Linux.SPF.1.0|AMSS|Standard|OEM|QIMPSDK | `git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_amss_standard_oem_qimpsdk.git` | `qualcomm-linux-spf-1-0_amss_standard_oem_qimpsdk` |

Note: 以下章节中的命令基于不带 Modem 和 GPS 的固件镜像的二进制文件和源代码（参见[Table : 固件发行版本和 git 代码仓库的映射](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html#build_private_distribution_with_extras__distributions_firmware)）。因此，可使用 `qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk`。如果使用的是任何其他发行版本，可相应地更新该目录。

**Git 命令**列（参见[Table : 固件发行版本和 git 代码仓库的映射](https://docs.qualcomm.com/doc/80-70014-254Y/topic/build_addn_info.html#build_private_distribution_with_extras__distributions_firmware)）提供了 git 代码仓库，其中包含固件源代码。这些代码仓库托管在 Qualcomm 服务器上。根据您的访问 profile 和用例克隆适当的代码仓库。以下 git clone 命令用于下载源代码中选定的固件组件（Modem 除外）：

    mkdir -p <FIRMWARE_ROOT>
    cd <FIRMWARE_ROOT>
    git clone -b <firmware release tag> --depth 1 https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk.git
    # Example, <firmware release tag> is r1.0_00039.2Copy to clipboard

Note: `git clone` 命令可将内容克隆到 `<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk` 目录。
有关最新的 `<firmware release tag>`，参见[发行说明](https://docs.qualcomm.com/bundle/publicresource/topics/RNO-240626095531/)中的<cite class="cite">编译关键发布标签</cite>部分。

### 编译固件

- **前提条件**
    - 确保工作 shell 为 `bash`。检查输出：

            echo $0Copy to clipboard

该命令的预期输出应为 `bash`。如果不是，则输入 bash shell：

            bashCopy to clipboard
    - 使用以下命令安装 libffi6。这对 QAIC 编译器是必需操作，该编译器从 IDL 文件生成头文件和源文件：

            curl -LO http://archive.ubuntu.com/ubuntu/pool/main/libf/libffi/libffi6_3.2.1-8_amd64.deb
            sudo dpkg -i libffi6_3.2.1-8_amd64.debCopy to clipboard
    - 安装 LLVM 进行 AOP、TZ 和 BOOT 编译：
cd <FIRMWARE_ROOT>
            mkdir llvm
            
            # Log in to qpm-cli and activate the license
            qpm-cli --login
            qpm-cli --license-activate sdllvm_arm
             
            # LLVM requirement for BOOT compilation is 10.0.3
            qpm-cli --install sdllvm_arm --version 10.0.3 --path <FIRMWARE_ROOT>/llvm/10.0.3
            chmod -R 777 <FIRMWARE_ROOT>/llvm/10.0.3
              
            # LLVM requirement for AOP is 14.0.4 
            qpm-cli --install sdllvm_arm --version 14.0.4 --path <FIRMWARE_ROOT>/llvm/14.0.4
            chmod -R 777 <FIRMWARE_ROOT>/llvm/14.0.4
              
            # LLVM requirement for TZ compilation is 16.0.7
            qpm-cli --install sdllvm_arm --version 16.0.7 --path <FIRMWARE_ROOT>/llvm/16.0.7
            chmod -R 777 <FIRMWARE_ROOT>/llvm/16.0.7Copy to clipboard
    - 导出 `SECTOOLS` 变量并编译固件版本（`<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk` 是最顶层目录）：

            export SECTOOLS=<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/<product>/common/sectoolsv2/ext/Linux/sectools
            export SECTOOLS_DIR=<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/<product>/common/sectoolsv2/ext/Linux
            # An example <product> is QCM6490.LE.1.0, see the latest Release Notes.Copy to clipboard
    - 安装和配置 Qualcomm^®^ Hexagon^™^：

            qpm-cli --extract hexagon8.4 --version 8.4.07
            export HEXAGON_ROOT=$HOME/Qualcomm/HEXAGON_Tools
            echo $HEXAGON_ROOTCopy to clipboard

Note: 将环境变量 HEXAGON\_ROOT 设置为 Hexagon SDK 的安装路径。如需在使用 `qpm-cli` 时更改安装路径，参见[如何更改 Hexagon 工具安装路径？](https://docs.qualcomm.com/doc/80-70014-254Y/topic/how_to.html#howto_build__section_nqg_cj3_v1c_vinayjk_03-23-24-006-3-877)部分。
- **编译 cDSP**
**所需工具**
    - 编译器版本 - Hexagon 8.4.07
    - Python 版本 - Python 3.10.2
    - 安装 libffi6

    **编译步骤**

1. 导航至以下目录：

            cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/CDSP.HT.2.5.c3/cdsp_proc/build/msCopy to clipboard
    2. 清理编译：

            python ./build_variant.py kodiak.cdsp.prod --cleanCopy to clipboard
    3. 编译镜像：

            python ./build_variant.py kodiak.cdsp.prodCopy to clipboard
- **编译 aDSP**
**所需工具**
    - 编译器版本 - Hexagon 8.4.07
    - Python 版本 - Python 3.10.2
    - 安装 libffi6

**Nanopb 集成（仅需设置一次）**

        cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/ADSP.HT.5.5.c8/adsp_proc/qsh_api
        curl https://jpa.kapsi.fi/nanopb/download/nanopb-0.3.9.5-linux-x86.tar.gz -o nanopb-0.3.9.5-linux-x86.tar.gz
        cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/ADSP.HT.5.5.c8/adsp_proc/
        python qsh_api/build/config_nanopb_dependency.py -f nanopb-0.3.9.5-linux-x86Copy to clipboard

    **编译步骤**

    1. 导航至以下目录：

            cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/ADSP.HT.5.5.c8/adsp_proc/build/msCopy to clipboard
    2. 清理编译：

            python ./build_variant.py kodiak.adsp.prod --cleanCopy to clipboard
    3. 编译镜像：

            python ./build_variant.py kodiak.adsp.prodCopy to clipboard
- **编译 Boot**
**所需工具**
    - 编译器版本 - LLVM 版本必须更新至 10.0.3
Note: 为了避免编译错误，确保命令的末尾有 `/`。

            export LLVM=<FIRMWARE_ROOT>/llvm/10.0.3/Copy to clipboard
    - Python 版本 - Python 3.10
    - 安装 libffi6

    **编译步骤**

1. 为了编译 Boot，您需要 /pkg/qct/software/boottools 目录中的设备树编译器。安装软件包：

            sudo apt-get install device-tree-compilerCopy to clipboard
    2. 将 /usr/bin/dtc 文件复制到 /pkg/qct/software/boottools 目录：

            sudo mkdir -p /pkg/qct/software/boottools
            sudo cp -r /usr/bin/dtc /pkg/qct/software/boottoolsCopy to clipboard
    3. 导航至以下目录：

            cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/BOOT.MXF.1.0.c1/Copy to clipboard
    4. 安装依赖项：

            python -m pip install -r boot_images/boot_tools/dtschema_tools/oss/requirements.txtCopy to clipboard
    5. 清理编译：

            python -u boot_images/boot_tools/buildex.py -t kodiak,QcomToolsPkg -v LAA -r RELEASE --build_flags=cleanallCopy to clipboard
    6. 编译镜像：

            python -u boot_images/boot_tools/buildex.py -t kodiak,QcomToolsPkg -v LAA -r RELEASECopy to clipboard

Note: 对于调试版本编译，将 `RELEASE` 替换为 `DEBUG`。
- **TZ 固件**
**所需工具**
    - 编译器版本 - LLVM 16.0.7
    - Python 版本 - Python 3.10

**编译步骤**
    1. 安装 LLVM：

            cd <FIRMWARE_ROOT>/TZ.XF.5.0/trustzone_images/build/ms/
            vi build_config_deploy_kodiak.xml
            # Edit all the occurrences of /pkg/qct/software/llvm/release/arm/16.0.7/ to <FIRMWARE_ROOT>/llvm/16.0.7/Copy to clipboard
    2. 编译镜像：

            cd <FIRMWARE_ROOT>/TZ.XF.5.0/trustzone_images/build/ms/
            python build_all.py -b TZ.XF.5.0 CHIPSET=kodiak --cfg=build_config_deploy_kodiak.xmlCopy to clipboard
- **AOP 固件**
**所需工具**
    - 编译器版本 - LLVM 14.0.4
    - Python 版本 - Python 3.10

    **编译步骤**

    1. 导航至以下目录：

            cd <FIRMWARE_ROOT>/AOP.HO.3.6/aop_proc/build/Copy to clipboard
    2. 编译镜像：

            ./build_kodiak.sh -l <FIRMWARE_ROOT>/llvm/14.0.4/Copy to clipboard
- **CPUCP 固件**
    CPUCP 固件以二进制文件格式发布，不需要编译。
- **CPUSYS.VM 固件**
    CPUSYS.VM 固件以二进制文件格式发布，不需要编译。
- **BTFM 固件**
    BTFM 固件以二进制文件格式发布，不需要编译。
- **WLAN 固件**
    WLAN 固件以二进制文件格式发布，不需要编译。
- **生成固件预编译（启动关键和拆分固件二进制文件）**
从编译的各个组件创建集成固件二进制文件：

        # cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/<product>/common/build
        # An example <product> is QCM6490.LE.1.0, see the latest Release Notes
        cd <FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/QCM6490.LE.1.0/common/build
        python build.py --imfCopy to clipboard

Note: 如果 &lt;FIRMWARE\_ROOT&gt;/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nm-qimpsdk/QCM6490.LE.1.0/common/build/ufs/bin目录中生成了以下 zip 文件，则表示固件预编译成功：
    - QCM6490\_bootbinaries.zip
    - QCM6490\_dspso.zip
    - QCM6490\_fw.zip

### 使用附加组件编译基础镜像

1. 下载 Qualcomm Yocto 和包含附加组件的支持层：

        # cd to directory where you have 300 GB of free storage space to create your workspaces
        mkdir <WORKSPACE_DIR>
        cd <WORKSPACE_DIR>
        repo init -u https://github.com/quic-yocto/qcom-manifest -b qcom-linux-kirkstone -m <manifest release tag>
        # Example, <manifest release tag> is qcom-6.6.28-QLI.1.1-Ver.1.1.xml
        repo sync
        git clone https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_hlos_oem_metadata.git -b <meta-qcom-extras release tag> --depth 1
        # Example, <meta-qcom-extras release tag> is r1.0_00041.0
        mkdir -p layers/meta-qcom-extras
        cp -rf qualcomm-linux-spf-1-0_hlos_oem_metadata/QCM6490.LE.1.0/common/config/meta-qcom-extras/* layers/meta-qcom-extras/Copy to clipboard

Note: 有关 `<manifest release tag>` 和 `<meta-qcom-extras release tag>` 的信息，参见[发行说明](https://docs.qualcomm.com/bundle/publicresource/topics/RNO-240626095531/)中的<cite class="cite">编译关键发布标签</cite>部分。
2. 设置 Yocto 版本：

        # Export additional meta layers to EXTRALAYERS. Location is assumed under <WORKSPACE DIR>/layers.
        export EXTRALAYERS="meta-qcom-extras"
         
        # CUST_ID is used to clone the proprietary source repositories downloaded by meta-qcom-extras.
        # It enables source compilation for the corresponding binaries present in meta-qcom-hwe.
        # This ID is constant for the firmware repository qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk.git.
        # CUST_ID must be initialized to <PARTY_ID> for "Licensed customers with additional access".
        # For example, for distros like "Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|" and "Qualcomm_Linux.SPF.1.0|AMSS|Standard|OEM|",
        # <PARTY_ID> is provided while signing up for distros mapping to "Licensed customers with additional access".
        # To find <PARTY_ID>, sign in to your account at qualcomm.com.
        # Click the profile icon, select Account Settings, and then scroll to Company Information section.
        # Use the number specified for Export ID as <PARTY_ID>.
        export CUST_ID="213195"
         
        # The firmware recipe is compiled when the Yocto build is initiated. Firmware recipe expects the
        # path of firmware. You have generated firmware prebuilts (boot-critical and split-firmware binaries)
        # using the steps described in the previous section. The directory path must contain QCM6490_bootbinaries.zip,
        # QCM6490_dspso.zip, and QCM6490_fw.zip. 
        # Set the environment variable to pick up the prebuilts:
        export FWZIP_PATH="<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/<product>/common/build/ufs/bin"
        # An example <product> is QCM6490.LE.1.0. For more information on <product>, see the latest Release Notes.
        
        MACHINE=qcm6490 DISTRO=qcom-wayland source setup-environment
        # source setup-environment: Sets the environment settings, creates the build directory build-qcom-wayland,
        # and enters into build-qcom-wayland directory.Copy to clipboard
3. 编译 Yocto 版本：

        bitbake qcom-multimedia-imageCopy to clipboard

Note: 清理 Yocto 版本：

        bitbake -fc cleansstate qcom-multimedia-image
        bitbake -fc cleanall qcom-multimedia-imageCopy to clipboard

编译成功后，可以检查 `system.img` 是否位于 `<workspace_path>/build-qcom-wayland/tmp-glibc/deploy/images/qcm6490/qcom-multimedia-image` 目录中：

        cd <workspace_path>/build-qcom-wayland/tmp-glibc/deploy/images/qcm6490/qcom-multimedia-image
        ls -al system.imgCopy to clipboard
4. 按[注册用户刷写镜像](https://docs.qualcomm.com/doc/80-70014-254Y/topic/flash_images.html)部分所述刷写生成的编译版本。

### 使用附加组件编译 QIMP SDK 镜像

1. 下载 QIMP SDK 层、Qualcomm Yocto 和包含附加组件的支持层：

        # cd to directory where you have 300 GB of free storage space to create your workspaces
        mkdir <WORKSPACE_DIR>
        cd <WORKSPACE_DIR>
        repo init -u https://github.com/quic-yocto/qcom-manifest -b qcom-linux-kirkstone -m <manifest release tag>
        # Example, <manifest release tag> is qcom-6.6.28-QLI.1.1-Ver.1.1.xml
        repo sync
        git clone https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_hlos_oem_metadata.git -b <meta-qcom-extras release tag> --depth 1
        # Example, <meta-qcom-extras release tag> is r1.0_00041.0
        mkdir -p layers/meta-qcom-extras
        cp -rf qualcomm-linux-spf-1-0_hlos_oem_metadata/QCM6490.LE.1.0/common/config/meta-qcom-extras/* layers/meta-qcom-extras/
        git clone https://github.com/quic-yocto/meta-qcom-qim-product-sdk -b qcom-6.6.28-QLI.1.1-Ver.1.1_qim-product-sdk-1.1.3 layers/meta-qcom-qim-product-sdkCopy to clipboard

Note: 有关 `<manifest release tag>` 和 `<meta-qcom-extras release tag>` 的信息，参见[发行说明](https://docs.qualcomm.com/bundle/publicresource/topics/RNO-240626095531/)中的<cite class="cite">编译关键发布标签</cite>部分。
2. 设置 Yocto 版本：

        # Export additional meta layers to EXTRALAYERS. Location is assumed under <WORKSPACE DIR>/layers.
        export EXTRALAYERS="meta-qcom-extras meta-qcom-qim-product-sdk"
         
        # CUST_ID is used to clone the proprietary source repositories downloaded by meta-qcom-extras.
        # It enables source compilation for the corresponding binaries present in meta-qcom-hwe.
        # This ID is constant for the firmware repository qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk.git.
        # CUST_ID must be initialized to <PARTY_ID> for "Licensed customers with additional access".
        # For example, for distros like "Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|" and "Qualcomm_Linux.SPF.1.0|AMSS|Standard|OEM|",
        # <PARTY_ID> is provided while signing up for distros mapping to "Licensed customers with additional access".
        # To find <PARTY_ID>, sign in to your account at qualcomm.com.
        # Click the profile icon, select Account Settings, and then scroll to Company Information section.
        # Use the number specified for Export ID as <PARTY_ID>.
        export CUST_ID="213195"
         
        # The firmware recipe is compiled when the Yocto build is initiated. Firmware recipe expects the
        # path of firmware. You have generated firmware prebuilts (boot-critical and split-firmware binaries)
        # using the steps described in the previous section. The directory path must contain QCM6490_bootbinaries.zip,
        # QCM6490_dspso.zip, and QCM6490_fw.zip. 
        # Set the environment variable to pick up the prebuilts:
        export FWZIP_PATH="<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qimpsdk/<product>/common/build/ufs/bin"
        # An example <product> is QCM6490.LE.1.0. For more information on <product>, see the latest Release Notes.
        
        MACHINE=qcm6490 DISTRO=qcom-wayland source setup-environment
        # source setup-environment: Sets the environment settings, creates the build directory build-qcom-wayland,
        # and enters into build-qcom-wayland directory.Copy to clipboard
3. 编译 QIMP SDK 版本：

        bitbake qcom-multimedia-image
        bitbake qim-product-sdkCopy to clipboard

Note: 清理 QIMP SDK 版本：

        bitbake -fc cleansstate qcom-multimedia-image
        bitbake -fc cleanall qcom-multimedia-image
        
        bitbake -fc cleansstate qim-product-sdk
        bitbake -fc cleanall qim-product-sdkCopy to clipboard

编译成功后，可以检查 `system.img` 是否位于 `<workspace_path>/build-qcom-wayland/tmp-glibc/deploy/images/qcm6490/qcom-multimedia-image` 目录中：

        cd <workspace_path>/build-qcom-wayland/tmp-glibc/deploy/images/qcm6490/qcom-multimedia-image
        ls -al system.imgCopy to clipboard
4. 按[注册用户刷写镜像](https://docs.qualcomm.com/doc/80-70014-254Y/topic/flash_images.html)部分所述刷写生成的编译版本。

### 使用附加组件编译 QIRP SDK 镜像

Note: 确保您已经克隆了 QIRP SDK 的相应固件。例如，`qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk`。

1. 下载 QIRP SDK 层、Qualcomm Yocto 和包含附加组件的支持层：

        # cd to directory where you have 300 GB of free storage space to create your workspaces
        mkdir <WORKSPACE_DIR>
        cd <WORKSPACE_DIR>
        repo init -u https://github.com/quic-yocto/qcom-manifest -b qcom-linux-kirkstone -m <manifest release tag>
        # Example, <manifest release tag> is qcom-6.6.28-QLI.1.1-Ver.1.1.xml
        repo sync
        git clone https://qpm-git.qualcomm.com/home2/git/qualcomm/qualcomm-linux-spf-1-0_hlos_oem_metadata.git -b <meta-qcom-extras release tag> --depth 1
        # Example, <meta-qcom-extras release tag> is r1.0_00041.0
        mkdir -p layers/meta-qcom-extras
        mkdir -p layers/meta-qcom-robotics-extras
        cp -rf qualcomm-linux-spf-1-0_hlos_oem_metadata/QCM6490.LE.1.0/common/config/meta-qcom-extras/* layers/meta-qcom-extras/
        cp -rf qualcomm-linux-spf-1-0_hlos_oem_metadata/QCM6490.LE.1.0/common/config/meta-qcom-robotics-extras/* layers/meta-qcom-robotics-extras/
        
        git clone https://git.codelinaro.org/clo/le/meta-ros.git -b ros.qclinux.1.0.r1-rel layers/meta-ros
        git clone https://github.com/quic-yocto/meta-qcom-robotics.git layers/meta-qcom-robotics
        git clone https://github.com/quic-yocto/meta-qcom-robotics-distro.git layers/meta-qcom-robotics-distro
        git clone https://github.com/quic-yocto/meta-qcom-robotics-sdk.git layers/meta-qcom-robotics-sdk
        git clone https://github.com/quic-yocto/meta-qcom-qim-product-sdk -b <qim-product-sdk release tag> layers/meta-qcom-qim-product-sdk
        # Example, <qim-product-sdk release tag> is qcom-6.6.28-QLI.1.1-Ver.1.1_qim-product-sdk-1.1.3Copy to clipboard

Note: 有关 `<manifest release tag>`、`<meta-qcom-extras release tag>` 和 `<qim-product-sdk release tag>` 的信息，参见[发行说明](https://docs.qualcomm.com/bundle/publicresource/topics/RNO-240626095531/)中的<cite class="cite">编译关键发布标签</cite>部分。
2. 设置 Yocto 版本：

        # Export additional meta layers to EXTRALAYERS. Location is assumed under <WORKSPACE DIR>/layers.
        export EXTRALAYERS="meta-qcom-extras meta-qcom-robotics-extras"
         
        # CUST_ID is used to clone the proprietary source repositories downloaded by meta-qcom-extras.
        # It enables source compilation for the corresponding binaries present in meta-qcom-hwe.
        # This ID is constant for the firmware repository qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk.git.
        # CUST_ID must be initialized to <PARTY_ID> for "Licensed customers with additional access".
        # For example, for distros like "Qualcomm_Linux.SPF.1.0|AP|Standard|OEM|" and "Qualcomm_Linux.SPF.1.0|AMSS|Standard|OEM|",
        # <PARTY_ID> is provided while signing up for distros mapping to "Licensed customers with additional access".
        # To find <PARTY_ID>, sign in to your account at qualcomm.com.
        # Click the profile icon, select Account Settings, and then scroll to Company Information section.
        # Use the number specified for Export ID as <PARTY_ID>.
        export CUST_ID="213195"
         
        # The firmware recipe is compiled when the Yocto build is initiated. Firmware recipe expects the
        # path of firmware. You have generated firmware prebuilts (boot-critical and split-firmware binaries)
        # using the steps described in the previous section. The directory path must contain QCM6490_bootbinaries.zip,
        # QCM6490_dspso.zip, and QCM6490_fw.zip.
        # Set the environment variable to pick up the prebuilts:
        export FWZIP_PATH="<FIRMWARE_ROOT>/qualcomm-linux-spf-1-0_ap_standard_oem_nm-qirpsdk/<product>/common/build/ufs/bin"
        # An example <product> is QCM6490.LE.1.0. For more information on <product>, see the latest Release Notes.Copy to clipboard
3. 编译 QIRP SDK 版本：

        ln -s layers/meta-qcom-robotics-distro/set_bb_env.sh ./setup-robotics-environment
        ln -s layers/meta-qcom-robotics-sdk/scripts/qirp-build ./qirp-build
        MACHINE=qcm6490 DISTRO=qcom-robotics-ros2-humble source setup-robotics-environment
        # source setup-robotics-environment: Sets the environment settings, creates the build directory build-qcom-robotics-ros2-humble,
        # and enters into build-qcom-robotics-ros2-humble directory.
        ../qirp-build qcom-robotics-full-imageCopy to clipboard

编译成功后，可以在以下路径看到 QIRP SDK 编译文件：

        QIRP SDK artifacts: <workspace_path>/build-qcom-robotics-ros2-humble/tmp-glibc/deploy/qirpsdk_artifacts/qirp-sdk_<version>.tar.gz
        # system.img is present in the following path
        Robotics image: <workspace_path>/build-qcom-robotics-ros2-humble/tmp-glibc/deploy/images/qcm6490/qcom-robotics-full-imageCopy to clipboard
4. 按[注册用户刷写镜像](https://docs.qualcomm.com/doc/80-70014-254Y/topic/flash_images.html)部分所述刷写生成的编译版本。

Last Published: Oct 09, 2024

[Previous Topic
注册用户的 GitHub 工作流程](https://docs.qualcomm.com/bundle/publicresource/80-70014-254Y/topics/build_from_source_github_intro.md) [Next Topic
非注册用户刷写镜像](https://docs.qualcomm.com/bundle/publicresource/80-70014-254Y/topics/flash_images_unregistered.md)