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

# 对镜像进行签名和烧写

## **前提条件**

### **检查 metabuild**

通过检查 metabuild 中的以下文件,确定需要签名的正确镜像。

* `<Metabuild>/<chipset>.LE.X.x/contents.xml`
  > 此文件包含以下详细信息:
  >
  > > * 每个镜像的源路径。
  > > * 每个镜像的格式(例如 pil-split 或 mbn)。
* `<Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/<chipset>_security_profile.xml`
  > 此文件提供与签名相关的元数据,包括:
  >
  > > * `--image-id` 值。
  > > * 用户必须签名以确保设备安全的镜像列表。

### **更改适用于 Windows 的 SecTools 命令**

要在 Windows 平台上使用 SecTools 命令,请将 `<Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools` 替换为 `<Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Windows/sectools.exe`。

## **对镜像进行签名**

镜像签名是一种安全过程,涉及为数字镜像添加加密签名。此签名作为唯一标识符,用于验证镜像的真实性、完整性和来源。如果没有镜像签名,就无法保证镜像的完整性或可信来源,可能导致安全漏洞和数据丢失。

按照以下步骤对镜像进行签名。

1. 您可以使用 SecTools V2 对镜像进行签名。提供多种签名方法和安全镜像功能。有关更多信息,请参阅 [SecTools V2: Secure Image User Guide](https://docs.qualcomm.com/doc/80-NM248-12/topic/secure-image-usage.html)。
2. 您可以使用本地签名器生成密钥和证书。有关更多信息,请参阅[生成本地(非安全)根密钥和证书](./generate-keys-and-certificates#generate-local-insecure-root-key-and-certificate)。
3. 要对单个镜像进行签名,请运行以下命令,此处以 `tz.mbn` 为例。
   > **注意**
   >
   > 您可以根据需要替换 OEM ID "**0x1**" 和 OEM Product ID "**0xabcd**" 的值。
   ```text theme={null}
   <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools secure-image --sign <path to tz>/trustzone_images/build/ms/bin/<flavor>/tz.mbn --image-id=TZ --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/<chipset>_security_profile.xml --oem-id=0x1 --oem-product-id=0xabcd --anti-rollback-version=0x0 --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --outfile ./signed_images_out/tz.mbn
   ```
   以下是适用于 IQ-9075/IQ-9100 的示例命令。
   > > ```text theme={null}
   > > <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools secure-image --sign <path to tz>/trustzone_images/build/ms/bin/<flavor>/tz.mbn --image-id=TZ --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/lemans_security_profile.xml --oem-id=0x1 --oem-product-id=0xabcd --anti-rollback-version=0x0 --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --outfile ./signed_images_out/tz.mbn
   > > ```
   >
   > **注意**
   >
   > 请根据 contents.xml 文件中指定的路径更新镜像路径。
4. 检查 contents.xml 文件中所有带有 `pil_split` 标志的镜像。
   > 示例:`pil_split = "adsp"`
   >
   > 对于需要拆分的镜像,请使用 `--pil-split` 选项。
5. 要对整个 metabuild 进行签名,请使用以下命令。
   > ```text theme={null}
   > <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools metabuild-secure-image --image-finder <meta>/common/build/app/image_finder.py --sign --oem-id=0x1 --oem-product-id=0xabcd --anti-rollback-version=0x0 --signing-mode LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --chipset <CHIPSET_NAME> --outdir meta_signing_output/ --storage ufs
   > ```
   有关更多信息,请参阅 [SecTools V2: Metabuild Secure Image User Guide](https://docs.qualcomm.com/bundle/80-NM248-17/resource/80-NM248-17_REV_AB_SecTools_V2__Metabuild_Secure_Image_User_Guide.pdf)。
   > **注意**
   >
   > *SecTools* 指南仅面向具有授权访问权限的许可用户提供。

## **生成已签名的 sec.elf 镜像**

生成已签名的 sec.elf 镜像涉及创建带有加密签名的安全可执行与可链接格式(ELF)文件。对该镜像进行签名可确保其真实性、完整性和来源。

熔丝熔断二进制文件用于出于安全原因永久禁用设备的某些功能或组件。生成已签名的 sec.elf 镜像以及熔丝熔断二进制文件需要一系列步骤,以确保固件的完整性和设备的安全性。要生成熔丝熔断二进制文件,请参阅 [SecTools V2: Fuse Blower User Guide](https://docs.qualcomm.com/bundle/80-NM248-9/resource/80-NM248-9_REV_AB_SecTools_V2__Fuse_Blower_User_Guide.pdf)。

## **使用 SecTools 集成示例命令**

本节仅提供示例命令。以下是适用于 Windows 的 SecTools 示例命令。

**注意**

* 确保命令中的 PK 哈希、OEM ID 和 Product ID 等值采用十六进制格式。

* 您可以根据需要替换 OEM ID "**0x1**" 和 OEM Product ID "**0xabcd**" 的值。

* 您可以将 `--fuse-pk-hash-0` 的值替换为 `OEM-KEYS/qpsa_rootca.cer` 的 SHA384 值。
  > 要计算正确的 PK 哈希值,请使用以下命令:
  >
  > > > ```text theme={null}
  > > > openssl dgst -sha384 qpsa_rootca.cer >sha384rootcert.txt
  > > > ```
  > >
  > > 有关更多信息,请参阅[为 RSA 和 ECDSA 生成 SHA-384 哈希](./generate-keys-and-certificates#generate-sha-384-hash-for-rsa-and-ecdsa)。

* 在下面的 sec.elf 生成命令中,将此处从用户根证书生成的摘要值替换进去。

* 阶段 1:基本安全启动(镜像身份验证 + OEM ID + MODEL ID)
  运行以下命令:

  <Tabs>
    <Tab title="QCS5430/QCS6490">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/kodiak_security_profile.xml --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-secure-boot2-pk-hash-in-fuse --fuse-oem-secure-boot2-auth-en --fuse-oem-secure-boot3-pk-hash-in-fuse --fuse-oem-secure-boot3-auth-en --fuse-oem-hw-id=0x0001 --fuse-oem-product-id=0xabcd --generate --sign --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --oem-id=0x1 --oem-product-id=0xabcd --outfile basic_sec.elf
      ```
    </Tab>

    <Tab title="IQ-9075/IQ-9100">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/lemans_security_profile.xml --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-secure-boot2-pk-hash-in-fuse --fuse-oem-secure-boot2-auth-en --fuse-oem-secure-boot3-pk-hash-in-fuse --fuse-oem-secure-boot3-auth-en --fuse-oem-hw-id=0x0001 --fuse-oem-product-id=0xabcd --generate --sign --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --oem-id=0x1 --oem-product-id=0xabcd --outfile basic_sec.elf
      ```
    </Tab>

    <Tab title="IQ-8275/IQ-8300">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --generate --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/monaco_security_profile.xml --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-hw-id=0x1 --fuse-oem-product-id=0xabcd --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --sign --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key  --outfile basic_sec.elf
      ```
    </Tab>

    <Tab title="IQ-615">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile  <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/talos_security_profile.xml --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-secure-boot2-pk-hash-in-fuse --fuse-oem-secure-boot2-auth-en --fuse-oem-secure-boot3-pk-hash-in-fuse --fuse-oem-secure-boot3-auth-en --fuse-oem-hw-id=0x0001 --fuse-oem-product-id=0xabcd --generate --sign --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --oem-id=0x1 --oem-product-id=0xabcd --outfile basic_sec.elf
      ```
    </Tab>
  </Tabs>

* 阶段 2:完整安全启动(基本安全启动 + 调试禁用 + 防回滚 + 写权限禁用):
  运行以下命令。

  <Tabs>
    <Tab title="QCS5430/QCS6490">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <meta\>/common/sectoolsv2/kodiak_security_profile.xml --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-secure-boot2-pk-hash-in-fuse --fuse-oem-secure-boot2-auth-en --fuse-oem-secure-boot3-pk-hash-in-fuse --fuse-oem-secure-boot3-auth-en --fuse-oem-secure-boot-fec-enable --fuse-wdog-en --fuse-shared-qsee-spiden-disable --fuse-shared-qsee-spniden-disable --fuse-shared-mss-dbgen-disable --fuse-shared-mss-niden-disable --fuse-shared-cp-dbgen-disable --fuse-shared-cp-niden-disable --fuse-shared-ns-dbgen-disable --fuse-shared-ns-niden-disable --fuse-apps-dbgen-disable --fuse-apps-niden-disable --fuse-shared-misc-debug-disable --fuse-eku-enforcement-en --fuse-anti-rollback-feature-en=0xF --fuse-sec-key-derivation-key=0x00 --fuse-read-permissions-write-disable --fuse-oem-configuration-write-disable --fuse-secondary-key-derivation-key-read-disable --fuse-write-permissions-write-disable --fuse-public-key-hash-0-write-disable --fuse-oem-secure-boot-write-disable --fuse-secondary-key-derivation-key-write-disable --fuse-secondary-key-derivation-key-fec-enable --fuse-fec-enables-write-disable --generate --sign --fuse-oem-hw-id=0x0001 --fuse-oem-product-id=0xabcd --signing-mode=LOCAL --root-certificate=./ OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --oem-id=0x1 --oem-product-id=0xabcd --outfile sec.elf
      ```
    </Tab>

    <Tab title="IQ-9075/IQ-9100">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/lemans_security_profile.xml --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-secure-boot2-pk-hash-in-fuse --fuse-oem-secure-boot2-auth-en --fuse-oem-secure-boot3-pk-hash-in-fuse --fuse-oem-secure-boot3-auth-en --fuse-oem-secure-boot-fec-enable --fuse-wdog-en --fuse-shared-qsee-spiden-disable --fuse-shared-qsee-spniden-disable --fuse-shared-mss-dbgen-disable --fuse-shared-mss-niden-disable --fuse-shared-cp-dbgen-disable --fuse-shared-cp-niden-disable --fuse-shared-ns-dbgen-disable --fuse-shared-ns-niden-disable --fuse-apps-dbgen-disable --fuse-apps-niden-disable --fuse-shared-misc-debug-disable --fuse-eku-enforcement-en --fuse-anti-rollback-feature-en=0xF --fuse-sec-key-derivation-key=0x00 --fuse-read-permissions-write-disable --fuse-oem-configuration-write-disable --fuse-secondary-key-derivation-key-read-disable --fuse-public-key-hash-0-write-disable --fuse-oem-secure-boot-write-disable --fuse-secondary-key-derivation-key-write-disable --fuse-secondary-key-derivation-key-fec-enable --fuse-fec-enables-write-disable --fuse-write-permissions-write-disable  --generate --sign --fuse-oem-hw-id=0x0001 --fuse-oem-product-id=0xabcd --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --oem-id=0x1 --oem-product-id=0xabcd --outfile sec.elf
      ```
    </Tab>

    <Tab title="IQ-8275/IQ-8300">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --generate --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/monaco_security_profile.xml --fuse-secondary-key-derivation-key-read-disable --fuse-read-permissions-write-disable --fuse-write-permissions-write-disable --fuse-fec-enables-write-disable --fuse-public-key-hash-0-write-disable --fuse-secondary-key-derivation-key-write-disable --fuse-oem-secure-boot-fec-enable --fuse-secondary-key-derivation-key-fec-enable --fuse-wdog-en --fuse-eku-enforcement-en --fuse-oem-configuration-write-disable --fuse-oem-secure-boot-write-disable --fuse-anti-rollback-feature-en=0xf --fuse-shared-qsee-spiden-disable --fuse-shared-qsee-spniden-disable --fuse-shared-mss-dbgen-disable --fuse-shared-mss-niden-disable --fuse-shared-cp-dbgen-disable --fuse-shared-cp-niden-disable --fuse-shared-ns-dbgen-disable --fuse-shared-ns-niden-disable --fuse-apps-dbgen-disable --fuse-apps-niden-disable --fuse-shared-misc-debug-disable --fuse-usb-pipo-disable --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-hw-id=0x1 --fuse-oem-product-id=0xabcd --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-sec-key-derivation-key=0x00 --sign --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key  --outfile sec.elf
      ```
    </Tab>

    <Tab title="IQ-615">
      ```shell theme={null}
      <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <Metabuild>/<chipset>.LE.X.x/common/sectoolsv2/talos_security_profile.xml --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-oem-secure-boot1-pk-hash-in-fuse --fuse-oem-secure-boot1-auth-en --fuse-oem-secure-boot2-pk-hash-in-fuse --fuse-oem-secure-boot2-auth-en --fuse-oem-secure-boot3-pk-hash-in-fuse --fuse-oem-secure-boot3-auth-en --fuse-oem-secure-boot-fec-enable --fuse-wdog-en --fuse-apps-apb-dfd-disable --fuse-dcc-debug-disable --fuse-debug-bus-disable --fuse-aoss-aop-dfd-disable --fuse-eud-disable --fuse-dap-deviceen-disable --fuse-apps-dbgen-disable --fuse-dap-dbgen-disable --fuse-lpass-turing-dbgen-disable --fuse-wcss-dbgen-disable --fuse-aoss-aop-dbgen-disable --fuse-cam-icp-dbgen-disable --fuse-ssc-dbgen-disable --fuse-venus-0-dbgen-disable --fuse-a5x-isdb-dbgen-disable --fuse-mss-dbgen-disable --fuse-apps-niden-disable --fuse-dap-niden-disable --fuse-lpass-turing-niden-disable --fuse-wcss-niden-disable --fuse-aoss-aop-niden-disable --fuse-cam-icp-niden-disable --fuse-ssc-niden-disable --fuse-mss-niden-disable --fuse-apps-spniden-disable --fuse-dap-spniden-disable --fuse-apps-spiden-disable --fuse-dap-spiden-disable --fuse-llcc-dsrw-disable --fuse-read-permissions-write-disable --fuse-oem-configuration-write-disable --fuse-secondary-key-derivation-key-read-disable --fuse-public-key-hash-0-write-disable --fuse-oem-secure-boot-write-disable --fuse-secondary-key-derivation-key-write-disable --fuse-secondary-key-derivation-key-fec-enable --fuse-sec-key-derivation-key=0x00 --fuse-fec-enables-write-disable --generate --sign --fuse-oem-hw-id=0x0001 --fuse-oem-product-id=0xabcd --signing-mode=LOCAL --root-certificate=./OEM-KEYS/qpsa_rootca.cer --ca-certificate=./OEM-KEYS/qpsa_attestca.cer --ca-key=./OEM-KEYS/qpsa_attestca.key --oem-id=0x1 --oem-product-id=0xabcd --outfile sec.elf
      ```
    </Tab>
  </Tabs>

> **注意**
>
> *SecTools* 指南仅面向具有授权访问权限的许可用户提供。

> **重要**
>
> `OEM_enable_bootup_from_a_b_partition` 配置是可选的,位于 `trustzone_images/ssg/securemsm/trustzone/qsee/mink/oem/config/<chipset>/oem_config.xml` 中。其默认值为 0。设置为 1 并重新编译 `devcfg` 后,它会启用回滚安全性。在通过来自 UEFI 或客户端应用程序的 SMC 完成启动确认后,它允许 TrustZone 更新镜像回滚版本。

## **使用统一镜像加密**

统一镜像加密(UIE)是一种标准化的镜像加密方案。它使用分层的 L1-L2-L3 AES 密钥梯,L1 是熔断在硬件中的根密钥。L2 是用 L1 密钥封装的下一级密钥,L3 是用于加密镜像的密钥,它由 L2 密钥封装。

有关与 UIE 加密相关的命令行用法,请参阅 [SecTools V2: Secure Image User Guide](https://docs.qualcomm.com/doc/80-NM248-12/topic/secure-image-usage.html)。

IQ-9075/IQ-9100 和 IQ-8275/IQ-8300 不支持 UIE 加密。

> **注意**
>
> *SecTools* 指南仅面向具有授权访问权限的许可用户提供。

### **生成您自己的加密密钥**

1. 用户 UIE 密钥是标准的 AES 128 密钥,可以使用 OpenSSL 工具生成。
   > 使用以下命令:
   >
   > > ```text theme={null}
   > > openssl enc -aes-128-cbc -k <secret> -P -md sha1
   > > ```
   >
   > 其中:
   >
   > * `openssl enc`:调用 OpenSSL 加密工具。
   > * `-aes-128-cbc`:指定加密算法 — 采用密码块链(CBC)模式的 128 位密钥 AES。
   > * `-k secret`:提供用于派生密钥和初始化向量(IV)的口令(secret)。
   > * `-P`:打印派生出的密钥和 IV,而不执行加密或解密操作。
   > * `-md sha1`:指定密钥派生函数(KDF)中使用的消息摘要算法(sha1)。
   >
   > 例如:
   >
   > > ```text theme={null}
   > > openssl enc -aes-128-cbc -k "secret_passphrase" -P -md sha1
   > > ```
   >
   > * `salt=E2A1F3C4D5B6A798`
   > * `key=5F4DCC3B5AA765D61D8327DEB882CF99`
   > * `iv =AABBCCDDEEFF00112233445566778899`
2. 将密钥复制到文件中以生成您的密钥。
   > `echo -n "5F4DCC3B5AA765D61D8327DEB882CF99"  | xxd -r -p > l1_key.key`

### **生成 UIE sec.elf 文件**

1. 使用以下命令生成 UIE sec.elf 文件。
   ```text theme={null}
   ./sectools fuse-blower --security-profile <chipset>_security_profile.xml --outfile uie_sec.elf --fuse-image-encryption-enable --generate --sign --signing-mode TEST  --fuse-oem-image-encryption-key=0x5F4DCC3B5AA765D61D8327DEB882CF99 --fuse-oem-image-encryption-key-fec-enable
   ```
2. 根据芯片组更新相应的安全配置文件 XML。
3. 根据需求将签名模式设置为 LOCAL 或 PLUGIN。
4. 根据您的密钥更新加密密钥。

生成 UIE sec.elf 文件后,您可以将其烧写到非安全设备上。烧写 UIE sec.elf 之后,应再连同其他熔丝一起烧写用于启用安全启动的 sec.elf。

### **加密二进制文件**

要使用测试密钥加密二进制文件,请在签名命令中附加以下参数。

> ```text theme={null}
> --encrypt  --encryption-mode TEST
> ```

要使用本地密钥加密二进制文件,请在签名命令中附加以下参数。

> ```text theme={null}
> --encrypt --encryption-mode LOCAL --l1-key l1_key.key
> ```

## **烧写镜像**

烧写镜像涉及将整个镜像(包括分区、文件系统和数据)写入存储设备。此过程有助于保持设备的功能、安全性和性能。

按照以下步骤烧写镜像:

1. 有关需要配置的熔丝列表,请参阅[设置 QFPROM 熔丝](./set-the-qfprom-fuses)。
2. 将所有二进制文件替换为在[对镜像进行签名](./sign-and-flash-the-images#sign-the-images)中生成的已签名非 Linux 二进制文件,包括 `prog_firehose_ddr.elf`。
   要替换 PIL 镜像,请将现有 PIL 镜像替换为先前生成的对应签名版本。
   > * 解压 `<chipset_name.LE.x.x>/common/build/ufs/bin/<chipset_name>_fw.zip` 文件。
   > * 将签名输出中生成的 PIL 拆分二进制文件和 `.mdt` 文件替换到解压后的目录 `<chipset_name.LE.x.x>/common/build/ufs/bin/<chipset_name>_fw/lib/firmware/qcom/<chipset_name>` 中。
   > * 将 `<chipset_name.LE.x.x>/common/build/ufs/bin/<chipset_name>_fw` 目录压缩为名为 `<chipset_name>_fw.zip` 的文件。
   > * 重新编译 Yocto 构建。
3. 要将所有已签名的二进制文件烧写到设备,请参阅 [Qualcomm Linux Build Guide](https://docs.qualcomm.com/bundle/publicresource/topics/80-80021-254/build_frm_source_qsc_cli.html)。
4. 生成已签名镜像和 `sec.elf` 后,启用安全启动:
   1. 首先在不包含 `sec.elf` 的情况下烧写已签名镜像,并确保设备能够成功启动。
   2. 通过更新正确的 `rawprogramX.xml` 文件来烧写 sec.elf。
      > 通过更新正确的 `rawprogramX.xml` 文件来烧写 sec.elf。找到包含 label="secdata" 条目的 rawprogramX.xml 文件,并将该条目中的文件名更新为 `sec.elf`。例如,在 QCM6490 中:
      >
      > `<program start_sector="315239" size_in_KB="28.0" physical_partition_number="4" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="7" readbackverify="false" filename="sec.elf" sparse="false" start_byte_hex="0x4cf67000" SECTOR_SIZE_IN_BYTES="4096" label="secdata"/>`
   3. 使用 [Qualcomm Linux Build Guide](https://docs.qualcomm.com/bundle/publicresource/topics/80-80021-254/flash_images.html) 中的烧写流程烧写已签名镜像和 `sec.elf`。
   4. 使用 PCAT 烧写镜像。
   5. 使用[启动验证 → 已验证的安全启动](./verify-the-security-configurations-of-qualcomm-linux#verify-secure-boot-and-uefi-secure-boot)验证安全启动是否已启用。
      **重要**
      启用安全启动后,设备要求使用一种称为已验证镜像编程(VIP)的安全编程方法来烧写镜像。要继续操作,请参阅[执行 VIP 烧写](./perform-vip-flashing)

## **后续步骤**

* 要通过仅允许烧写经过数字签名的镜像来确保设备安全,请参阅[执行 VIP 烧写](./perform-vip-flashing)。
* 要强制执行严格的访问控制,请参阅[启用 SELinux](./enable-se-linux)。
