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

# 添加镜像 recipe

提供有关如何添加镜像 recipe 并使用 BitBake 命令进行构建的信息。

## **镜像 recipe 概念**

镜像 recipe（`.bb` 文件）定义了安装在根文件系统中的完整软件包集合。Qualcomm 在 `meta-qcom-distro/recipes-products/images` 中提供了参考镜像。有关每个参考镜像的描述，请参阅 [meta-qcom-distro](./meta-qcom-distro#image-recipes)。

## **Qualcomm 参考镜像**

| **镜像**                               | **描述**                       |
| ------------------------------------ | ---------------------------- |
| `qcom-minimal-image`                 | 可启动至 shell 的最小 rootfs        |
| `qcom-console-image`                 | 在最小镜像基础上扩展了 SSH 和软件包管理       |
| `qcom-multimedia-image`              | 包含上游组件的完整多媒体软件包              |
| `qcom-multimedia-proprietary-image`  | 包含 Qualcomm 专有功能的多媒体镜像       |
| `qcom-container-orchestration-image` | 包含 Kubernetes 和容器运行时的多媒体专有镜像 |

## **创建自定义镜像 recipe**

1. 要添加镜像 recipe，请将目录切换到 `<workspace>/layers/meta-qcom-distro/recipes-products/images`。
2. 创建一个文件，例如 `sample-image.bb`，并添加以下内容：
   ```text theme={null}
   require qcom-minimal-image.bb

   SUMMARY = "Basic sample image"

   IMAGE_FEATURES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', '', 'package-management', d)} \
                       ssh-server-openssh"

   CORE_IMAGE_BASE_INSTALL += " \
      packagegroup-qcom-security \
      packagegroup-qcom-utilities-debug-utils \
      packagegroup-qcom-utilities-network-utils \
      packagegroup-qcom-utilities-profile-utils \
      packagegroup-qcom-utilities-support-utils \
   "
   ```
3. 将 `sample-image.bb` 文件添加到 `meta-qcom/ci/qcom-distro.yml` CI 文件的 `target:` 下：
   ```text theme={null}
   target:
      - qcom-multimedia-image
      - qcom-multimedia-proprietary-image
      - qcom-container-orchestration-image
      - sample-image
   ```
4. 加载环境：
   ```text theme={null}
   kas shell meta-qcom/ci/rb3gen2-core-kit.yml:meta-qcom/ci/qcom-distro.yml
   ```
5. 使用 BitBake 命令进行构建：
   ```text theme={null}
   bitbake sample-image
   ```
   生成的镜像如下：
   ```text theme={null}
   build> $ ls tmp/deploy/images/rb3gen2-core-kit/sample-image.qcomflash/
   aop.mbn     gpt_backup0.bin  gpt_backup5.bin  gpt_main4.bin  kernel-modules.tgz  patch2.xml             prog_firehose_lite.elf  rawprogram2.xml  system.img    xbl_config.elf
   cpucp.elf   gpt_backup1.bin  gpt_main0.bin    gpt_main5.bin  logfs_ufs_8mb.bin   patch3.xml             qdl                     rawprogram3.xml  tz.mbn        xbl.elf
   devcfg.mbn  gpt_backup2.bin  gpt_main1.bin    hypvm.mbn      multi_image.mbn     patch4.xml             qupv3fw.elf             rawprogram4.xml  uefi.elf      XblRamdump.elf
   dtb.bin     gpt_backup3.bin  gpt_main2.bin    Image          patch0.xml          patch5.xml             rawprogram0.xml         rawprogram5.xml  uefi_sec.mbn  zeros_5sectors.bin
   efi.bin     gpt_backup4.bin  gpt_main3.bin    imagefv.elf    patch1.xml          prog_firehose_ddr.elf  rawprogram1.xml         shrm.elf         vmlinux
   ```
