# 入门指南

本信息说明如何下载、配置和开发适用于 Qualcomm 开发套件及其相关组件的 Qualcomm Linux 内核，以编译和刷写系统镜像。

在开始下载和配置 Qualcomm Linux 内核之前，应按照 [Qualcomm
Linux 编译指南](bundle/publicresource/topics/80-70015-254) 所述搭建主机，该指南还提供 Qualcomm Linux 内核常见工作流程的相关信息。

## 获取 Qualcomm Linux 内核源代码

如需获取 Qualcomm Linux 内核源代码，参见
[Qualcomm Linux 编译指南](bundle/publicresource/topics/80-70015-254)
并获取所有必要的 Qualcomm Linux 元数据层。

Qualcomm Linux 使用 LTS Linux 内核 (6.6.x)。Qualcomm 支持两种软件版本：

> 
> 
> - 基本板卡支持包 (BSP)
> - 定制 BSP

Note

- **基本 BSP** 版本使用上游 LTS Linux 内核 (6.6.x) 和一组有限的下游补丁。
- **定制 BSP** 版本使用定制的 LTS Linux 内核 (6.6.x)，并托管在 CodeLinaro 的 Qualcomm 存储库中。

表: 各版本的内核 recipe 路径

| 版本 | 内核 recipe 路径 |
| --- | --- |
| 基本 BSP | `recipes-kernel/linux/linux-qcom-base_6.6.bb` |
| 定制 BSP | `recipes-kernel/linux/linux-qcom-custom_6.6.bb` |

Note

基本 BSP 和定制 BSP 的内核 recipe 存在于 `meta-qcom-hwe` 层。

参见 `recipes-kernel/linux/linux-qcom-base_6.6.bb` 或 `recipes-kernel/linux/linux-qcom-custom_6.6.bb` 文件以了解用于
下载内核源代码的 Git 统一资源标识符 (URI)。

有关 Qualcomm Linux 层的详细信息，参见 [Qualcomm BSP
元数据层](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-27/platform_software_features.html#sub$qualcomm_bsp_metadata_layers)。

> 
> 
> Note
> 
> 
> Yocto recipe 是指在 [CodeLinaro](https://git.codelinaro.org/clo/la/kernel/qcom) 公开托管的 Qualcomm Linux 内核源代码。

以下示例展示了基本 BSP 和定制 BSP 的 Qualcomm Linux 内核 recipe 源 URI 信息：

**基本 BSP**

以下是基本 BSP 版本的源 URI 信息：

> 
> 
> SECTION = "kernel"
>     
>     SUMMARY = "Linux kernel for QCOM devices"
>     DESCRIPTION = "Recipe to build Linux kernel from 6.6 LTS branch"
>     
>     LICENSE = "GPL-2.0-only"
>     LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
>     
>     inherit kernel
>     
>     COMPATIBLE_MACHINE = "(qcom)"
>     
>     SRC_URI = " git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git;protocol=https;branch=linux-6.6.y \
>              file://qcom.cfg \
>        "
>     Copy to clipboard

**定制 BSP**

以下是定制 BSP 版本的源 URI 信息：

> 
> 
> SECTION = "kernel"
>     
>     SUMMARY = "Linux kernel for QCOM devices"
>     DESCRIPTION = "Recipe to build Linux kernel"
>     
>     LICENSE = "GPLv2.0-with-linux-syscall-note"
>     LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
>     
>     inherit kernel
>     
>     COMPATIBLE_MACHINE = "(qcom)"
>     
>     SRC_URI = "git://git.codelinaro.org/clo/la/kernel/qcom.git;protocol=https;rev=350dfd604d2ffbe0cac99bf3459b49114aad11f4;branch=kernel.qclinux.1.0.r1-rel \
>       file://QCLINUX-arm64-dts-qcom-sa8775p-ride-add-board-id-and.patch \
>       ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', ' file://selinux.cfg', '', d)} \
>       ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', ' file://selinux_debug.cfg', '', d)} \
>       "
>     Copy to clipboard

## 确定支持的 Qualcomm 机器

Qualcomm 机器配置文件位于
`meta-qcom-hwe/conf/machine/` 目录。

机器配置文件遵循 `<SoC>-<board>-<variant>​.conf` 命名约定，其中：

- `SoC` 是片上系统 (SoC) 名称
- `board` 是编译软件的电路板类型
- `variant` 是产品的类型

例如：

在 `qcs6490-rb3gen2-core-kit.conf` 文件名中，

- `qcs6490` 是 SoC
- `rb3gen2` 是电路板
- `core-kit` 是产品的类型

在平台特定的设备树文件中遵循相同的命名约定。

以下示例展示了配置为 Yocto 机器配置的受支持机器列表：

ls -l ./LE.QCLINUX.1.0/layers/meta-qcom-hwe/conf/machine/*.conf
    
    meta-qcom-hwe/conf/machine/qcs6490-rb3gen2-core-kit.conf
    meta-qcom-hwe/conf/machine/qcs6490-rb3gen2-vision-kit.conf
    meta-qcom-hwe/conf/machine/qcs9075-ride-sx.conf
    Copy to clipboard

以下示例展示了搭载 Qualcomm 芯片组的开发板的机器配置选项：

$ less meta-qcom-hwe/conf/machine/<SoC>-<board>-<variant>.conf
    
    #@TYPE: Machine
    #@NAME: <Machine name same as the machine conf file or ``<SoC>-<board>-<variant>`` >
    #@DESCRIPTION: Machine configuration for the development board, with Qualcomm qcs6490
    
    require conf/machine/include/qcom-<SoC>.inc
    Copy to clipboard

以下示例展示了基本和定制 BSP 版本的内核配置选项：

less meta-qcom-hwe/conf/machine/include/qcom-base.inc
    
    # Provider for linux kernel
    # qcom-base-bsp uses 'linux-qcom-base' as kernel
    PREFERRED_PROVIDER_virtual/kernel ?= "linux-qcom-custom"
    PREFERRED_PROVIDER_virtual/kernel:qcom-base-bsp ?= "linux-qcom-base"
    Copy to clipboard

Note

- 在编译基本 BSP 版本时选择 `linux-qcom-base`。
- 在编译定制 BSP 版本时选择 `linux-qcom-custom`。

## 编译 Yocto 镜像 recipe 和内核配置

用户可以访问 Qualcomm Linux 镜像 recipe以修改内核配置。下表列出了支持的
`meta-qcom-hwe` 镜像：

表：Qualcomm Linux 支持的镜像 recipe

| 镜像名称 | 说明 |
| --- | --- |
| qcom-console-image<br>    Copy to clipboard | 这是一个用于启动至 shell 的镜像，其中包含用于引入所有基本软件包的软件包组。 |
| qcom-multimedia-image<br>    Copy to clipboard | 此镜像 recipe 包含多媒体软件组件（例如音频、Bluetooth^®^、摄像头、计算机视觉、显示和视频）的 recipe。 |
| qcom-multimedia-test-image<br>    Copy to clipboard | 此镜像 recipe 包含测试镜像。 |

下载 Qualcomm Linux 代码后，运行 `bitbake` 命令编译镜像。

Note

基本 BSP 版本使用 `arch/arm64/configs/defconfig` 内核配置文件。局部更改叠加在 `meta-qcom-hwe/recipes-kernel/linux/linux-qcom-base-6.6/qcom.cfg` 文件的
`defconfig` 之上。

若要编译基本 BSP 版本的 Qualcomm Linux 内核，可运行以下命令：

# Use the filename of Machine conf file for MACHINE parameter
    $ MACHINE=<SoC>-<board>-<variant> DISTRO=qcom-wayland QCOM_SELECTED_BSP=base source setup-environment
    
    # build qcom linux console image
    $ bitbake qcom-console-image
    
    # Build Images are produced under "build-qcom-wayland/tmp-glibc/deploy/images/<SoC>-<board>-<variant>/qcom-console-image/"
    Copy to clipboard

若要编译 [表：Qualcomm Linux 支持的镜像 recipe](https://docs.qualcomm.com/doc/80-70015-3SC/topic/getting_started_chapter2.html#qualcomm-linux-supported-image-recipes) 中列出的的镜像，Qualcomm Linux 内核定制 BSP recipe 使用以下任一种内核配置文件：

Note

下游内核配置文件包含 `addons`。

表：定制 BSP 内核配置文件

| 内核配置文件 | 说明 |
| --- | --- |
| <kernel_src>/arch/arm64/configs/qcom_defconfig<br>    Copy to clipboard | 要求产品基本配置与上游内核保持一致。 |
| <kernel_src>/arch/arm64/configs/qcom_debug.config<br>    Copy to clipboard | 从上游内核调试配置文件。 |
| <kernel_src>/arch/arm64/configs/qcom_addons.config<br>    Copy to clipboard | 在上游一致的基本配置之上增加 Qualcomm 下游增加配置。 |
| <kernel_src>/arch/arm64/configs/qcom_addons_debug.config<br>    Copy to clipboard | 启用 Qualcomm 下游调试。 |

若要编译 Qualcomm Linux，包括定制 BSP 版本的内核，可运行以下命令：

# Use the filename of Machine conf file for MACHINE parameter
    $ MACHINE=<SoC>-<board>-<variant> DISTRO=qcom-wayland QCOM_SELECTED_BSP=custom source setup-environment
    
    # build qcom linux console image
    $ bitbake qcom-console-image
    
    # Build Images are produced under "build-qcom-wayland/tmp-glibc/deploy/images/<SoC>-<board>-<variant>/qcom-console-image/"
    Copy to clipboard

内核默认编译版本在 `linux-qcom-base_6.6.bb` 或 `linux-qcom-custom_6.6.bb` 文件中定义。

Qualcomm Linux 内核 recipe 支持下表中提到的 #3（性能）和 #4（调试）编译配置。默认编译配置为 #3（性能）。以下内核配置文件仅适用于定制 BSP 版本。

> 
> 
> 表：定制 BSP 内核编译配置类型和配置
> 
> 
> | 序列号 | 内核编译版本配置类型 | Defconfig/config 文件 |
> | --- | --- | --- |
> | 1 | 基本配置 | arch/arm64/configs/qcom_defconfig<br>    Copy to clipboard |
> | 2 | 启用调试的基本配置 | <ul><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_defconfig<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_debug.config<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br></ul> |
> | 3 | 增加下游配置的基本配置 | <ul><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_defconfig<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_addons.config<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br></ul> |
> | 4 | 包含下游配置且启用调试的基本配置 | <ul><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_defconfig<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_debug.config<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_addons.config<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br><li><div class="highlight-pre notranslate"><div class="highlight"><pre class="pre codeblock"><code>arch/arm64/configs/qcom_addons_debug.config<br></code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></div><br></div><br></li><br></ul> |

有关配置内核的详细信息，参见 [内核配置](https://docs.qualcomm.com/doc/80-70015-3SC/topic/features.html#kernel-configuration-1)。

### 编译 Qualcomm 调试编译版本

运行以下命令以编译调试编译版本：

$ DEBUG_BUILD=1 bitbake qcom-console-image
    Copy to clipboard

若要修改编译版本配置，可更新 `meta-qcom-hwe` 层
中 `linux-qcom-base_6.6.bb` 或 `linux-qcom-custom_6.6.bb` 内核 recipe 的
`KERNEL_CONFIG` 和 `KERNEL_CONFIG_FRAGMENTS`
变量。

### 内核配置示例

以下示例展示了基本 BSP 和定制 BSP 的内核配置：

**基本 BSP**

以下示例展示了使用
`linux-qcom-base_6.6.bb` 内核 recipe 的内核配置：

> 
> 
> KERNEL_CONFIG_FRAGMENTS:append = " ${WORKDIR}/qcom.cfg"
>     
>     S = "${WORKDIR}/git"
>     
>     # 6.6.38
>     SRCREV = "2928631d5304b8fec48bad4c7254ebf230b6cc51"
>     PV = "6.6+git${SRCPV}"
>     
>     KERNEL_CONFIG ??= "defconfig"
>     Copy to clipboard

**定制 BSP**

以下示例展示了使用
`linux-qcom-custom_6.6.bb` 内核 recipe 的内核配置：

> 
> 
> KERNEL_CONFIG ??= "qcom_defconfig"
>     
>     KERNEL_CONFIG_FRAGMENTS:append = " ${S}/arch/arm64/configs/qcom_addons.config"
>     KERNEL_CONFIG_FRAGMENTS:append = " ${@oe.utils.vartrue('DEBUG_BUILD', '${S}/arch/arm64/configs/qcom_debug.config', '', d)}"
>     KERNEL_CONFIG_FRAGMENTS:append = " ${@oe.utils.vartrue('DEBUG_BUILD', '${S}/arch/arm64/configs/qcom_addons_debug.config', '', d)}"
>     
>     # Enable selinux support
>     SELINUX_CFG = "${@oe.utils.vartrue('DEBUG_BUILD', 'selinux_debug.cfg', 'selinux.cfg', d)}"
>     KERNEL_CONFIG_FRAGMENTS:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', '${WORKDIR}/${SELINUX_CFG}', '', d)}"
>     Copy to clipboard

有关编译指令的详细信息，参见 [Qualcomm Linux 编译指南](bundle/publicresource/topics/80-70015-254)
中的 [使用QSC CLI 编译](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-254/build_from_source_QSC_CLI.html) 部分。

## 访问平台设备树

受支持开发套件特定的 Qualcomm 设备树源包含文件 (DTSI)
和设备树源文件 (DTS) 位于
`arch/arm64/boot/dts/qcom/` 目录中的内核源文件下。这些
Qualcomm 文件将与上游一致的配置和增加的 Qualcomm 下游配置
区分开。

具有 `addons` 的设备树文件是下游文件。
基本 BSP 版本软件不使用任何下游设备树文件。

`<SoC>-<board>-<variant>​.conf` 是 Qualcomm Linux 机器配置文件，
包含了所需设备树 blob (DTB) 选择配置数据。

- `SoC` 是受支持的 Qualcomm 芯片组。例如，QCS6490 和 QCS9075。
- `board` 是 RB3 Gen 2 支持的产品。
- `variant` 是产品的类型，例如 core-kit。

以下示例展示了纳入设备配置文件中的 DTB 包含文件：

KERNEL_DEVICETREE = " \
                          qcom/<SoC>-addons-<variant>.dtb \
                          "
    Copy to clipboard

Tab QCS6490
Tab QCS9075

下表列出了适用于 Qualcomm RB3 Gen 2 开发套件的 Qualcomm 设备树文件。

> 
> 
> 表：Qualcomm 设备树源文件
> 
> 
> | 设备树源 | 详细信息 |
> | --- | --- |
> | arch/arm64/boot/dts/qcom/sc7280.dtsi<br>    Copy to clipboard | QCS6490 SoC 源自 SC7280。 |
> | arch/arm64/boot/dts/qcom/qcs6490.dtsi<br>    Copy to clipboard | QCS6490 DTSI，其中包含不同于 SC7280 SoC 的所有更改。 |
> | arch/arm64/boot/dts/qcom/qcs6490-addons.dtsi<br>    Copy to clipboard | QCS6490 SoC 特定的下游增加配置。 |
> | arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts<br>    Copy to clipboard | 适用于 QCS6490 Qualcomm RB3 Gen 2 开发套件的设备树源文件。 |
> | arch/arm64/boot/dts/qcom/qcs6490-addons-rb3gen2.dts<br>    Copy to clipboard | Qualcomm RB3 Gen 2 开发套件的 QCS6490 特定的下游增加配置。 |
> | arch/arm64/boot/dts/qcom/qcs5430-addons-rb3gen2.dts<br>    Copy to clipboard | Qualcomm RB3 Gen 2 开发套件的 QCS5430 功能包-1特定的下游增加配置。 |
> | arch/arm64/boot/dts/qcom/qcs5430-fp2-addons-rb3gen2.dts<br>    Copy to clipboard | Qualcomm RB3 Gen 2 开发套件的 QCS5430 功能包-2的下游增加配置。 |
> | arch/arm64/boot/dts/qcom/qcs5430-fp2p5-addons-rb3gen2-vision-mezz.dts<br>    Copy to clipboard | RB3 Gen 2 视觉 Mezzanine 卡开发套件的QCS5430 功能包-2.5的下游增加配置。 |
> | arch/arm64/boot/dts/qcom/qcs5430-fp3-addons-rb3gen2-vision-mezz.dts<br>    Copy to clipboard | RB3 Gen 2 视觉 Mezzanine 卡开发套件的QCS5430 功能包-3的下游增加配置。 |

下表列出了适用于 QCS9075 开发套件的 Qualcomm 设备树文件。默认情况下，使用插件 DTB。

> 
> 
> 表：Qualcomm 设备树源文件
> 
> 
> | 设备树源 | 详细信息 |
> | --- | --- |
> | arch/arm64/boot/dts/qcom/sa8775p.dtsi<br>    Copy to clipboard | QCS9075 SoC 源自 SA8775P。 |
> | arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi<br>    Copy to clipboard | QCS9075 Qualcomm 开发套件。 |

## 管理树外 DT 覆盖文件

SoC 机器配置文件包括附加的树外 DTB 覆盖 (DTBO)。

图形、摄像头、无线局域网 (WLAN) 驱动程序及其设备树配置在内核源代码树之外进行维护。其各自的设备树源代码覆盖 (DTSO) 文件在编译时被覆盖在基本 DTB 之上。

DTBO 配置在 `conf/machine/<SoC>-<board>-<variant>.conf` 文件中完成。

以下示例展示了 DTBO 配置：

# OUT_OF_KERNEL_DTSO - qcs6490-rb3gen2-core-kit.conf
    # Additional list of DTBOs to be overlaid on top of base kernel devicetree files
    # Format - KERNEL_TECH_DTBOS[<base-dtb-name>] = "<dtbo1 <dtbo2>..."
    # For example:
    
     KERNEL_TECH_DTBOS[qcs6490-addons-rb3gen2] = " \
     qcm6490-graphics.dtbo qcm6490-wlan-rb3.dtbo \
     qcm6490-display-rb3.dtbo qcm6490-bt.dtbo \
     qcm6490-video.dtbo qcm6490-wlan-upstream.dtbo \
     "
    Copy to clipboard

## 管理树外内核模块

大多数内核驱动程序都是从上游内核源代码编译的。
但是，有些驱动程序在内核源代码树之外进行维护，并使用 Yocto 编译系统编译为内核模块。

在以下示例中，蓝牙模块是树外内核模块。其
recipe 位于 `recipes-connectivity/bt_dlkm_kernel/bt-dlkm-kernel_git.bb` 文件中，
该文件会将驱动程序编译为内核模块。若要在启动时自动加载内核模块，
可以将模块名称添加到 `KERNEL_MODULE_AUTOLOAD`
变量中。

# Example out-of-tree Kernel module recipe
    DESCRIPTION = "QCOM BT drivers"
    LICENSE = "GPL-2.0-only"
    LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/${LICENSE};md5=801f80980d171dd6425610833a22dbe6"
    
    inherit module
    
    SRC_URI += "git://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/bt-kernel.git;protocol=https;rev=9e5cf29625d60f78e88440c94d096a9139445c00;branch=bt-performant.qclinux.1.0.r1-rel \
               file://bt_dlkm \
               file://bt_dlkm.service \
               "
    
    S = "${WORKDIR}/git"
    
    RPROVIDES:${PN} += "kernel-module-bt-kernel"
    
    EXTRA_OEMAKE += "MACHINE='${MACHINE}'"
    MAKE_TARGETS = "modules"
    MODULES_INSTALL_TARGET = "modules_install"
    # Kernel module to be autoloaded
    KERNEL_MODULE_AUTOLOAD += "bt_fm_slim"
    Copy to clipboard

## 编译设备镜像

使用以下 Yocto 命令编译整个镜像和内核：

# setup the build environment
    $ export SHELL=/bin/bash
    
    $ source setup-environment
    # (select "<SoC> meta-qcom"   Enter   select "qcom-wayland meta-qcom-distro"          Enter)
    
    # build qcom linux console image
    $ bitbake qcom-console-image
    
    # Build kernel only
    $ bitbake linux-qcom-base
    
    # Build Images are produced under
    # build-qcom-wayland/tmp-glibc/deploy/images/<SoC>-<board>-<variant>/qcom-console-image/
    Copy to clipboard

有关如何面向 SoC 支持的 Qualcomm 发行版编译不同镜像的详细信息，参见 [内核配置](https://docs.qualcomm.com/doc/80-70015-3SC/topic/features.html#kernel-configuration-1)。

Note

要编译定制 BSP，使用 `linux-qcom-custom`。

## 调通设备

`efi.bin` 文件中包含 systemd-boot（启动管理器）、内核和 initramfs 镜像。Yocto 编译版本将这些镜像打包到
`efi.bin` 中，该文件可以刷入 EFI 系统分区 (ESP) 以启动设备。

设备树 blob 已更新或已添加到 `conf/machine/<SoC>-<board>-<variant>.conf` 文件的
`KERNEL_DEVICETREE` 变量中。
这些设备树 blob 用于编译 `dtb.bin` 文件。

使用以下 fastboot 命令刷写 `efi.bin` 和 `dtb.bin` 镜像：

# Bring the device in fastboot mode
    # cd to the source root location
    $ cd build-qcom-wayland/tmp-glibc/deploy/images/<SoC>/qcom-console-image
    $ fastboot flash efi efi.bin
    $ fastboot flash dtb_a dtb.bin
    $ fastboot reboot
    Copy to clipboard

Qualcomm Linux 编译完成后，会在 `tmp-glibc/deploy/images/<SoC>-<board>-<variant>/` 目录中创建内核相关镜像。

下表列出了与内核相关的编译文件：

表：内核编译文件

| 镜像 | 镜像名称 | 编译版本部署路径 | 详细信息 |
| --- | --- | --- | --- |
| 内核的可执行和可链接的格式 (ELF) 文件 | vmlinux<br>    Copy to clipboard | temp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 输出带有调试符号的内核 ELF 文件。 |
| Initramfs | initramfs-qcom-image-<SoC>-<board>-<variant>.cpio.gz<br>    Copy to clipboard | tmp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 拷贝输入/输出 (CPIO) 文件格式的 Initramfs。 |
| 内核镜像 | 镜像<br>    Copy to clipboard | tmp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 原始二进制文件格式的内核镜像，systemd-boot 不支持压缩镜像。 |
| 内核模块 | 不同的内核动态可加载内核模块 (DLKM)<br><br><br>modules-<SoC>-<board>-<variant>.tgz<br>    Copy to clipboard | tmp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 内核驱动程序模块。 |
| 设备树 blob | <SoC>-addons-<VARIANT>.dtb<br>    Copy to clipboard | tmp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 各个设备树 blob。 |
| ESP 分区 | efi.bin<br>    Copy to clipboard | tmp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 所有必需的启动镜像（包括 systemd-boot、内核和 initramfs）都打包到可扩展固件接口 (`efi.bin`) 二进制文件中。 |
| DTB 分区 | dtb.bin<br>    Copy to clipboard | tmp-glibc/deploy/images/<SoC>-<board>-<variant>/<br>    Copy to clipboard | 所有 DTBO 文件都合并到 (`dtb.bin`) 二进制文件中。 |

Last Published: Dec 15, 2024

[Previous Topic
概述](https://docs.qualcomm.com/bundle/publicresource/80-70015-3SC/topics/overview.md) [Next Topic
功能](https://docs.qualcomm.com/bundle/publicresource/80-70015-3SC/topics/features.md)