# 签名并刷写镜像

## 前提条件

检查 metabuild 中的以下文件来确定要签名的正确镜像。

- `<Metabuild>\contents.xml`

> 
> 
> 此文件包含以下详细信息：
> 
> 
> 
> > 
> > 
> > - 每个镜像的源路径。
> >     - 每个镜像的格式（例如，pil-split 或 mbn）。
- `<Metabuild>\common\sectoolsv2\<target>_security_profile.xml`

> 
> 
> 此文件提供签名相关的元数据，包括：
> 
> 
> 
> > 
> > 
> > - `--image-id` 值。
> >     - 必须由用户签名以确保设备安全的镜像列表。

## 签名镜像

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

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

1. 您可以使用 SecTools V2 对镜像进行签名。提供不同的签名方法和安全镜像功能。有关更多信息，请参阅 [SecTools V2: Secure Image User Guide](https://docs.qualcomm.com/bundle/80-NM248-12/resource/80-NM248-12_REV_AB_SecTools_V2__Secure_Image_User_Guide.pdf)。
2. 您可以使用本地签名者生成密钥和证书。有关更多信息，请参阅[生成本地（不安全）根密钥和证书](https://docs.qualcomm.com/doc/80-70022-11SC/topic/generate-keys-and-certificates.html#section-generate-local-root-key-certificate-lable)。
3. 要对单个镜像进行签名，请运行以下命令，其中 `tz.mbn` 用作示例。

> 
> 
> Note
> 
> 
> 您可以根据需要替换 OEM ID “**0x1**” 和 OEM 产品 ID “**0xabcd**” 的值。

<meta>/common/sectoolsv2/ext/linux/sectools secure-image --sign /path/to/tz.mbn --image-id=TZ --security-profile <meta>/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
        Copy to clipboard

    以下是 IQ-9075/IQ-9100 的示例命令。

> 
> 
> <meta>/common/sectoolsv2/ext/linux/sectools secure-image --sign /path/to/tz.mbn --image-id=TZ --security-profile <meta>/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
>         Copy to clipboard
4. 检查 contents.xml 文件中带有 `pil_split` 标志的镜像。

> 
> 
> 示例：`pil_split = "adsp"`
> 
> 
> 对于需要拆分的镜像，请使用 `--pil-split` 选项。
5. 要签署完整的 metabuild，请使用以下命令。

> 
> 
> ./sectools metabuild-secure-image --image-finder /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 KODIAK --outdir meta_signing_output/ --storage ufs
>         Copy to clipboard

    更多详细信息，请参阅 [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)。

Note

*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 的示例命令：

Note

- 确保命令中的 PK hash、OEM ID、Product ID 等值均为十六进制格式。
- 您可以根据需要替换 OEM ID “**0x1**” 和 OEM 产品 ID “**0xabcd**” 的值。
- 您可以将 `--fuse-pk-hash-0` 的值替换为 `OEM-KEYS/qpsa_rootca.cer` 的 SHA384 值。

> 
> 
> 要计算正确的 PK 哈希值，请使用以下命令：
> 
> 
> 
> > 
> > 
> > > 
> > > 
> > > openssl dgst -sha384 qpsa_rootca.cer
> > >         Copy to clipboard
> > 
> > 
> > 
> > 如需了解更多信息，请参阅[为 RSA 和 ECDSA 生成 SHA-384 哈希](https://docs.qualcomm.com/doc/80-70022-11SC/topic/generate-keys-and-certificates.html#section-generate-sha-384-hash-rsa-ecdsa-lable)。
- 在下面的 sec.elf 生成命令中替换此处从用户根证书生成的摘要。

- 阶段 1：基本安全启动（镜像身份验证 + OEM ID + 型号 ID）

    运行以下命令：

> 
> 
> Tab QCS5430/QCS6490
> Tab IQ-9075/IQ-9100
> Tab IQ-8275/IQ-8300
> Tab IQ-615
> 
> <meta>/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-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
>         Copy to clipboard
> 
> <meta>/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <meta>/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
>         Copy to clipboard
> 
> <meta>/common/sectoolsv2/ext/Linux/sectools fuse-blower --generate --security-profile <meta>/common/sectoolsv2/monaco_security_profile.xml --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=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
>         Copy to clipboard
> 
> <meta>/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile  <meta>/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
>         Copy to clipboard
- 阶段 2：完成全部安全启动（基本安全启动 + 调试禁用 + 防回滚 + 写入权限禁用）：

    运行以下命令。

> 
> 
> Tab QCS5430/QCS6490
> Tab IQ-9075/IQ-9100
> Tab IQ-8275/IQ-8300
> Tab IQ-615
> 
> <meta>/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=RANDOM --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
>         Copy to clipboard
> 
> <meta>/common/sectoolsv2/ext/Linux/sectools fuse-blower --security-profile <meta>/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=RANDOM --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
>         Copy to clipboard
> 
> <meta>/common/sectoolsv2/ext/Linux/sectools fuse-blower --generate --security-profile <meta>/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-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=0x1 --fuse-oem-product-id=0xabcd --fuse-pk-hash-0=<sha384 of OEM-KEYS/qpsa_rootca.cer> --fuse-sec-key-derivation-key=RANDOM --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
>         Copy to clipboard
> 
> <meta>/common/sectoolsv2/ext/Linux/sectools fuse-blower -security-profile <meta>/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=RANDOM --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
>         Copy to clipboard

> 
> 
> Note
> 
> 
> *SecTools* 指南可供具有授权访问权限的许可用户使用。
> 
> 
> Important
> 
> 
> `OEM_enable_bootup_from_a_b_partition` 配置是可选的，位于 `trustzone_images/ssg/securemsm/trustzone/qsee/mink/oem/config/<chipset>/oem_config.xml`。其默认值为 0。当设置为 1 并重新编译 `devcfg` 后，可实现回滚安全性。使用 SMC 从 UEFI 或客户端应用程序进行启动确认后，允许 TrustZone 更新镜像回滚版本。

## 统一镜像加密

统一镜像加密 (UIE) 旨在通过加密镜像文件来保护镜像完整性，从而防止未经授权的篡改。此机制确保只有授权设备才能解密和访问原始镜像。

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

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

> 
> 
> Note
> 
> 
> *SecTools* 指南可供具有授权访问权限的许可用户使用。

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

1. 用户 UIE 密钥是标准 AES 128 密钥，可以使用 OpenSSL 工具生成。

> 
> 
> 使用命令：
> 
> 
> 
> > 
> > 
> > openssl enc -aes-128-cbc -k <secret> -P -md sha1
> >         Copy to clipboard
> 
> 
> 
> 其中：
> 
>     - `openssl enc`：调用 OpenSSL 加密工具。
>     - `-aes-128-cbc`：指定加密算法 - 在密码块链 (CBC) 模式下使用 128 位密钥的 AES。
>     - `-k secret`：提供用于生成密钥和初始化向量 (IV) 的密码（密钥）。
>     - `-P`：打印派生密钥和初始向量 (IV)，而不是执行加密或解密。
>     - `-md sha1`：指定密钥派生函数 (KDF) 中使用的消息摘要算法 (sha1)。
> 
> 
> 
> 例如：
> 
> 
> 
> > 
> > 
> > openssl enc -aes-128-cbc -k "secret_passphrase" -P -md sha1
> >         Copy to clipboard
> 
> 
>     - `salt=E2A1F3C4D5B6A798`
>     - `key=5F4DCC3B5AA765D61D8327DEB882CF99`
>     - `iv =AABBCCDDEEFF00112233445566778899`
2. 将密钥复制到文件中以生成您的密钥。

> 
> 
> `echo "5F4DCC3B5AA765D61D8327DEB882CF99" > l1_key.key`

### 生成 UIE sec.elf 文件

1. 使用该命令生成 UIE sec.elf 文件。

./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
        Copy to clipboard
2. 更新适用于芯片组的安全配置文件 XML。
3. 根据需求将签名模式设置为 LOCAL 或 PLUGIN。
4. 根据您的密钥更新加密密钥。

生成 UIE sec.elf 文件后，即可将其刷写到非安全设备上。刷写 UIE sec.elf 后，应同时刷写安全启动启用 sec.elf 及其他熔丝设置。

### 加密二进制文件

要使用测试密钥加密二进制文件，请使用以下参数和签名命令。

> 
> 
> --encrypt  --encryption-mode TEST
>     Copy to clipboard

要使用本地密钥加密二进制文件，请使用以下参数和签名命令。

> 
> 
> --encrypt --encryption-mode LOCAL --l1-key l1_key.key
>     Copy to clipboard

## 刷写镜像

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

按照以下步骤刷写镜像：

1. 有关要配置的熔丝列表，请参阅[设置 QFPROM 熔丝](https://docs.qualcomm.com/doc/80-70022-11SC/topic/appendix-fuse-configurations.html#appendix-fuse-configurations)。
2. 将所有二进制文件替换为在[签名镜像](https://docs.qualcomm.com/doc/80-70022-11SC/topic/sign-and-flash-images.html#section-sign-image-lable)中生成的签名非 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 编译指南](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-254/build_frm_source_qsc_cli.html)。
4. 生成签名镜像和 `sec.elf` 后，启用安全启动：

    1. 首先刷写除 `sec.elf` 以外的所有已签名镜像，并确保设备成功启动。
    2. 通过更新 `rawprogram4.xml` 文件来刷写 sec.elf，如下所示：

> 
> 
> `<program start_sector="207781" 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="0x32ba5000" SECTOR_SIZE_IN_BYTES="4096" label="secdata"/>`

    2. 使用 [Qualcomm Linux 编译指南](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-254/flash_images.html)中的刷写程序刷写签名的镜像和 `sec.elf`。
    3. 使用 PCAT 刷写镜像。
    4. 使用[调通 → 已验证安全启动](https://docs.qualcomm.com/doc/80-70022-11SC/topic/bring-up.html#section-bringup-verify-secure-boot-label)验证是否启用了安全启动。

Important

启用安全启动后，设备需要使用一种名为验证镜像编程 (VIP) 的安全编程方法来刷写镜像。要继续，请参阅[执行 VIP 刷写](https://docs.qualcomm.com/doc/80-70022-11SC/topic/vip-flashing.html#vip-flashing)

## 后续步骤

- 通过仅允许使用数字签名的镜像进行编程来确保设备安全，请参阅[执行 VIP 刷写](https://docs.qualcomm.com/doc/80-70022-11SC/topic/vip-flashing.html#vip-flashing)。
- 要执行严格的访问控制，请参阅[启用 SELinux](https://docs.qualcomm.com/doc/80-70022-11SC/topic/enable-selinux.html#enable-selinux)。

Last Published: Apr 14, 2026

[Previous Topic
生成密钥和证书](https://docs.qualcomm.com/bundle/publicresource/80-70022-11SC/topics/generate-keys-and-certificates.md) [Next Topic
执行 VIP 刷写](https://docs.qualcomm.com/bundle/publicresource/80-70022-11SC/topics/vip-flashing.md)