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

# Build with GitHub workflow

Follow the detailed instructions to synchronize the Qualcomm Yocto and QIR SDK layers, and build the robotics image along with the QIR SDK artifacts.

<Warning>
  **Warning**

  It's not recommended to rebuild the QIR SDK, as the build process is complex for non-professionals. Build the QIR SDK ONLY if you understand the process and have the following needs:

  * Build an image for the device which doesn't have a prebuilt image, for example, the Qualcomm<sup>®</sup> IQ-8 Evaluation Kit. For details, see [Supported platforms](./qir-sdk-overview#supported-platforms).
  * Add new features to the QIR SDK.
  * Change the content of the target image.
  * Fix bugs in the QIR SDK.
  * Optimize the performance of the QIR SDK.
  * Change the version of certain components.
</Warning>

1. [Set up the host computer for build](#set-up-the-host-computer-for-build)
2. [Build the robotics image](#build-the-robotics-image)
3. [Generate QIR SDK artifacts](#generate-qir-sdk-artifacts)
4. [Flash the robotics image to devices](#flash-the-robotics-image-to-devices)

## Set up the host computer for build

Prepare your host computer for the build and install operations, ensuring it meets the [Host computer requirements](./build-the-qir-sdk#host-computer-requirements).

1. Install the required packages.
   ```shell 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 gfortran
   ```
2. Set up the locales.
   ```shell theme={null}
   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-8
   ```
3. Update git configurations.
   ```shell theme={null}
   # 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
   ```
4. Change the `/bin/sh` symlink to point to `/bin/bash` by default.
   ```shell theme={null}
   sudo ln -sf /bin/bash /bin/sh
   ```
5. Install the repo tool according to steps in [install-the-repo-utility](https://github.com/qualcomm-linux/qcom-manifest/blob/qcom-linux-scarthgap/README.md#install-the-repo-utility).

## Build the robotics image

The following steps set up a KAS-based compile environment on top of the Yocto Project and build the robotics image with the KAS tool.

1. Set up your Yocto Project build environment by referring to the steps in [Yocto Project Reference Manual](https://docs.yoctoproject.org/ref-manual/system-requirements.html).

2. The KAS tool offers an easy way to set up bitbake based projects. For more details, see [KAS documentation](https://kas.readthedocs.io/en/latest/index.html). Install the KAS tool using the following commands.

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

 # Restart your shell session after running this command to ensure
 # path changes take effect
 pipx ensurepath

 # The kas version is expected to be 4.8 or higher
 pipx install kas
```

3. Build using the KAS configuration for one of the supported boards.

   1. Download Qualcomm’s Yocto layer `meta-qcom-robotics-sdk` using the latest `<meta-qcom-robotics-sdk-release-tag>`.

      The following table describes the build tags for the current release.

      | **Release tag**                    | **Identifier** |
      | :--------------------------------- | :------------- |
      | meta-qcom-robotics-sdk-release-tag | `qli-2.0`      |

      Download Qualcomm’s Yocto layer `meta-qcom-robotics-sdk` by the latest `<meta-qcom-robotics-sdk-release-tag>`.

      ```shell theme={null}
        git clone https://github.com/qualcomm-linux/meta-qcom-robotics-sdk \
        -b qli-2.0
      ```

   2. Build the software image using `kas`.

      ```shell theme={null}
      kas build meta-qcom-robotics-sdk/ci/<MACHINE>.yml:meta-qcom-robotics-sdk/ci/<DISTRO>.yml:meta-qcom-robotics-sdk/ci/<TARGET>.yml:meta-qcom-robotics-sdk/ci/<KERNEL>.yml
      ```

      The following table lists the supported `<MACHINE>`, `<DISTRO>`, `<TARGET>`, and `<KERNEL>` combinations. Select one item from each column to replace the corresponding placeholder in the command. For more details about these KAS configuration fragments, see the [Robotics OpenEmbedded layer changes](./migration-robotics-oe-layer-changes#qir-sdk-for-qualcomm-linux-20-single-unified-layer) and the [`meta-qcom`](../../../Key-Documents/Yocto-Guide/meta-qcom) and [`meta-qcom-distro`](../../../Key-Documents/Yocto-Guide/meta-qcom-distro) sections of the Qualcomm Linux Yocto Guide.

      <table>
        <thead>
          <tr>
            <th align="center" valign="top">MACHINE configuration<br /></th>
            <th align="center" valign="top">DISTRO configuration<br /></th>
            <th align="center" valign="top">TARGET image recipe<br /></th>
            <th align="center" valign="top">KERNEL provider<br /></th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td align="left">
              <ul>
                <li><code>iq-8275-evk</code></li>
                <li><code>iq-9075-evk</code></li>
              </ul>
            </td>

            <td align="left">
              <ul>
                <li><code>qcom-robotics-distro</code></li>
                <li><code>qcom-robotics-distro-catchall</code></li>
              </ul>
            </td>

            <td align="left">
              <ul>
                <li><code>qcom-robotics-image</code></li>
                <li><code>qcom-robotics-proprietary-image</code></li>
              </ul>
            </td>

            <td align="left">
              <ul>
                <li><code>linux-qcom-6.18</code></li>
                <li><code>linux-qcom-rt-6.18</code></li>
              </ul>
            </td>
          </tr>
        </tbody>
      </table>

      **Examples**:

      * To build the robotics image based on open-source components, use the [qcom-robotics-image](https://github.com/qualcomm-linux/meta-qcom-robotics-sdk/blob/wrynose/recipes-products/images/qcom-robotics-image.bb) recipe:

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

        ```bash IQ-8275-EVK theme={null}
        kas build meta-qcom-robotics-sdk/ci/iq-8275-evk.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-distro.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-image.yml:meta-qcom-robotics-sdk/ci/linux-qcom-6.18.yml
        ```
      </CodeGroup>

      * To build the robotics image with features in the Qualcomm proprietary components, use the [qcom-robotics-proprietary-image](https://github.com/qualcomm-linux/meta-qcom-robotics-sdk/blob/wrynose/recipes-products/images/qcom-robotics-proprietary-image.bb) recipe:

      <CodeGroup>
        ```bash IQ-9075-EVK theme={null}
        kas build meta-qcom-robotics-sdk/ci/iq-9075-evk.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-distro.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-proprietary-image.yml:meta-qcom-robotics-sdk/ci/linux-qcom-6.18.yml
        ```

        ```bash IQ-8275-EVK theme={null}
        kas build meta-qcom-robotics-sdk/ci/iq-8275-evk.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-distro.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-proprietary-image.yml:meta-qcom-robotics-sdk/ci/linux-qcom-6.18.yml
        ```
      </CodeGroup>

4. **(Optional)** Build a debug or performance image.

   To build a debug or performance image, append the corresponding yaml fragment file to the end of the `kas build` command:

   <p style={{ textAlign: 'center', fontWeight: 'bold' }}>
     Yaml file for debug or performance images
   </p>

   | Image type        | Yaml file         |
   | ----------------- | ----------------- |
   | Debug build       | `debug.yml`       |
   | Performance build | `performance.yml` |

   **Example** (machine: `iq-9075-evk`, performance build):

   ```shell theme={null}
   kas build meta-qcom-robotics-sdk/ci/iq-9075-evk.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-distro.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-proprietary-image.yml:meta-qcom-robotics-sdk/ci/linux-qcom-6.18.yml:meta-qcom-robotics-sdk/ci/performance.yml
   ```

5. The `kas build` generates the image in the following path:

   ```shell theme={null}
   build/tmp/deploy/images/<MACHINE NAME>/*.rootfs.qcomflash
   ```

## Generate QIR SDK artifacts

To generate the QIR SDK, run the `generate_qirp_sdk` task after the image build completes:

```shell theme={null}
kas build meta-qcom-robotics-sdk/ci/<MACHINE>.yml:meta-qcom-robotics-sdk/ci/<DISTRO>.yml:meta-qcom-robotics-sdk/ci/<TARGET>.yml:meta-qcom-robotics-sdk/ci/<KERNEL>.yml -c generate_qirp_sdk
```

**Example** (machine: `iq-9075-evk`，kernel: `linux-qcom-6.18`):

```shell theme={null}
kas build meta-qcom-robotics-sdk/ci/iq-9075-evk.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-distro.yml:meta-qcom-robotics-sdk/ci/qcom-robotics-image.yml:meta-qcom-robotics-sdk/ci/linux-qcom-6.18.yml -c generate_qirp_sdk
```

The `kas build` generates the QIR SDK artifacts in the following path:

```shell theme={null}
build/tmp/deploy/qirpsdk_artifacts/<MACHINE NAME>/qirp_sdk.tar.gz
```

## Flash the robotics image to devices

To flash the robotics image to the device, see [Flash the robotics image](./flash-the-robotics-image), using the `qcom-robotics-image` or `qcom-robotics-proprietary-image` generated in [Build the robotics image](#build-the-robotics-image).
