1. Article purpose[edit | edit source]
The purpose of this article is to explain how to perform a secure boot for any development platform of the STM32MP25x lines
(STM32MP25 boards) with the OpenSTDroid Distribution Package.
To do so, steps, described in chapters below, must be followed :
- Create the signature keys with the KeyGen tool (if not already done).
- Fuse the secure elements on the STM32 MPU (if not already done).
- Compile the OpenSTDroid distribution for signed binaries.
- Flash the STM32 MPU with the FlashLayout file dedicated for signed binaries.
- Check the secure boot execution.
- Close the device (if not already done).
2. Prerequisites[edit | edit source]
STM32CubeProgrammer must be installed with the KeyGen tool and Signing tool..
The OpenSTDroid distribution must be installed and environment has been set for your STM32MP25 development platform STM32MP257F-DK
or STM32MP257F-EV1
board.
eMMC key slot provisioning need for the RPMB authenticated transaction process is mandatory, see the how to provision secrets for Android.
3. Create signature keys[edit | edit source]
The list of signature materials, public and private keys, and hashes required in the M33 TD-flavor secure boot process is shown in the table below. The private keys are used to sign the firmwares. These keys and their associated passwords must be stored securely. The hashes have to be fused in OTP.
In the proposed configuration, a single OEM-KEY1 key is used to authenticate multiple firmware images. A list of 8 keys is generated, and the first key at index 0 is used for signing. Knowing that using a key permanently revokes the lower-indexed keys in the list.
| STM32MP25 firmware to authenticate | Signature key materials | Hash file |
| FSBL M (Arm® Cortex®-M33) | ||
| TF-M MCUBOOT | a35_OEM-KEY1_privateKey0X.pem a35_OEM-KEY1_publicKey0X.pem a35_OEM-KEY1_publicKeyHask0X.pem where X:0 to 7 |
a35_OEM-KEY1_publicKeysHashHashes.bin |
| M33DDR (Arm® Cortex®-M33) | ||
| TF-M DDR firmware | m33_FSBLM-DDR-FW-PKH_privateKey.pem m33_FSBLM-DDR-FW-PKH_publicKey.pem |
m33_FSBLM-DDR-FW-PKH_hash.bin |
| M33FW (Arm® Cortex®-M33) | ||
| TF-M Secure + M33 firmware nonsecure | m33_FSBLM-M33-FW-PKH_privateKey.pem m33_FSBLM-M33-FW-PKH_publicKey.pem |
m33_FSBLM-M33-FW-PKH_hash.bin |
| FSBL A (Arm® Cortex®-A35) | ||
| TF-A | a35_OEM-KEY1_privateKey0X.pem a35_OEM-KEY1_publicKey0X.pem a35_OEM-KEY1_publicKeyHask0X.pem where X:0 to 7 |
a35_OEM-KEY1_publicKeysHashHashes.bin |
| FIP (Arm® Cortex®-A35) | ||
| TF-A (bl31 + fwconfig) | a35_OEM-KEY1_privateKey0X.pem a35_OEM-KEY1_publicKey0X.pem a35_OEM-KEY1_publicKeyHask0X.pem where X:0 to 7 |
a35_OEM-KEY1_publicKeysHashHashes.bin |
| TRUSTY | a35_OEM-KEY1_privateKey0X.pem a35_OEM-KEY1_publicKey0X.pem a35_OEM-KEY1_publicKeyHask0X.pem where X:0 to 7 |
a35_OEM-KEY1_publicKeysHashHashes.bin |
| U-BOOT | a35_OEM-KEY1_privateKey0X.pem a35_OEM-KEY1_publicKey0X.pem a35_OEM-KEY1_publicKeyHask0X.pem where X:0 to 7 |
a35_OEM-KEY1_publicKeysHashHashes.bin |
The TF-M requires a key for Initial Attestation [1] to fuse in OTP.
| FSBL M Initial Attestation (Arm® Cortex®-M33) | ||
| TF-M IAK | m33_TFM-IAK_key_256bits.bin | |
The process is the same as the one described for the OpenSTLinux distribution. The signature materials created have to be stored in the folder device/stm/stm32mp2/security/keys
See in the page How to perform Secure Boot from Distribution Package#For_STM32MP2_series all paragraphs concerning the STM32MP25x M33-TD flavor
.
4. Fuse signature materials on STM32MP25x OTP[edit | edit source]
| For demonstration and test purposes, the signature materials can be fused manually on the STM32 MPU device using a simple U-Boot command on the development board. For production purposes, it must be set in the production phase, as described in Secure Secret Provisioning (SSP) overview. |
Thanks to the fastboot protocol in U-Boot you can provision the board remotely.
It's recommended to use the serial console on Arm®-Cortex®-A35 to check command execution (see How to open several serial consoles page for more information). Then, enter in the U-Boot shell, pressing a key on you host keyboard as soon as required.
To manually fuse a signature material.
- Boot the board
- Stop on the U-Boot console.
- In the U-boot console execute the command :
fastboot usb 0
- In a host terminal :
For the m33_TFM-IAK_key_256bits.bin fusing (TFM-IAK) OTP352-359:
fastboot oem run:'stm32key select TFM-IAK' fastboot stage device/stm/stm32mp2/security/keys/m33_TFM-IAK_key_256bits.bin
Verification before fusing, compare the output of the two commands :
fastboot oem run:'stm32key read 0x84000000' hexdump -C device/stm/stm32mp2/security/keys/m33_TFM-IAK_key_256bits.bin
Fusing:
fastboot oem run:'stm32key fuse 0x84000000'
For the m33_FSBLM-DDR-FW-PKH_hash.bin (FSBLM-DDR-FW-PKH) OTP192-199 :
fastboot oem run:'stm32key select FSBLM-DDR-FW-PKH' fastboot stage device/stm/stm32mp2/security/keys/m33_FSBLM-DDR-FW-PKH_hash.bin
Verification before fusing, compare the output of the two commands :
fastboot oem run:'stm32key read 0x84000000' hexdump -C device/stm/stm32mp2/security/keys/m33_FSBLM-DDR-FW-PKH_hash.bin
Fusing:
fastboot oem run:'stm32key fuse 0x84000000'
For the m33_FSBLM-M33-FW-PKH_hash.bin (FSBLM-M33-FW-PKH) OTP184-191 :
fastboot oem run:'stm32key select FSBLM-M33-FW-PKH fastboot stage device/stm/stm32mp2/security/keys/m33_FSBLM-M33-FW-PKH_hash.bin
Verification before fusing, compare the output of the two commands :
fastboot oem run:'stm32key read 0x84000000'
hexdump -C device/stm/stm32mp2/security/keys/m33_FSBLM-M33-FW-PKH_hash.bin
Fusing:
fastboot oem run:'stm32key fuse 0x84000000'
For the a35_OEM-KEY1_publicKeysHashHashes.bin fusing (OEM-KEY1) OTP144-151:
fastboot oem run:'stm32key select OEM-KEY1' fastboot stage device/stm/stm32mp2/security/keys/a35_OEM-KEY1_publicKeysHashHashes.bin
Verification before fusing, compare the output of the two commands :
fastboot oem run:'stm32key read 0x84000000'
hexdump -C device/stm/stm32mp2/security/keys/a35_OEM-KEY1_publicKeysHashHashes.bin
Fusing:
fastboot oem run:'stm32key fuse 0x84000000'
5. Update the OpenSTDroid distribution with signed binaries[edit | edit source]
For enabling FIP content authentication by TF-A (setting of the build flag TRUSTED_BOARD_BOOT), load and rebuild the bootloader firmwares with options "-si":
load_bootloader build_bootloader -si
Note that the flag DYN_DISABLE_AUTH is set to 1 by default in the /device/stm/stm32mp2-bootloader/source/build-bootloader.sh - DYN_DISABLE_AUTH: Provides the capability to dynamically disable Trusted Board Boot authentication at runtime. This option is meant to be enabled only for development platforms. TRUSTED_BOARD_BOOT flag must be set if this flag has to be enabled. To be set to 0 for production phase. |
To take into account the secrets programmed in the OTP by the M33 TF-M, load and rebuild the system firmwares with options "-si":
load_system build_system -si
Update the flag BOARD_SECURE_BOOT to "on" in the makefile /device/stm/stm32mp2/dk/aosk_dk.mk for the STM32MP257F-DK
or in the makefile /device/stm/stm32mp2/eval/aosk_eval.mk for the STM32MP257F-EV1
Then to update Android images execute the command:
make -j
The OpenSTDroid distribution include some scripts to sign the binaries, the keys used are defined in the scripts.
The keys used are the ones created in the /device/stm/stm32/security/keys folder, so you need to update the following script with your key identifiers:
/device/stm/stm32mp2/scripts/signing/sign_firmware.sh
According to the paragraph Create signature keys you should update the file as defined below.
KEY_FILE0="a35_OEM-KEY1_publicKey00.pem" KEY_FILE1="a35_OEM-KEY1_publicKey01.pem" KEY_FILE2="a35_OEM-KEY1_publicKey02.pem" KEY_FILE3="a35_OEM-KEY1_publicKey03.pem" KEY_FILE4="a35_OEM-KEY1_publicKey04.pem" KEY_FILE5="a35_OEM-KEY1_publicKey05.pem" KEY_FILE6="a35_OEM-KEY1_publicKey06.pem" KEY_FILE7="a35_OEM-KEY1_publicKey07.pem" # The privateKey00.pem is used for signed # # !!! BE CAREFUL : # Use always the first key in the list # When secureboot is activated, # all keys with index lower that the key used for signing are automatically and permanently revoked for the board. PRIV_KEY_FILE="a35_OEM-KEY1_privateKey00.pem" KEY_PWD="password1" # keys used in case of TFM_DUMMY_PROVISIONING , NO PASWWORD M33_DUMMY_KEY_DDR="root-ec-p256_1.pem" M33_DUMMY_KEY_TFM="root-ec-p256.pem" M33_KEY_DDR=*"m33_FSBLM-DDR-FW-PKH_privateKey.pem"* M33_KEY_TFM="m33_FSBLM-M33-FW-PKH_privateKey.pem" M33_KEY_PWD="password1"
Executes the command below to generate the signed binaries:
sign_firmware
Then flash the board
flash_device --signed
6. Check the set up[edit | edit source]
The ROM code authentication result transmitted is not enough to confirm if an authentication is correct; some additional code is mandatory.
.
To enable this code, TF-A must be compiled with the DYN_DISABLE_AUTH flag at first (set by default), then the following trace should appear during the TF-A boot sequence:
NOTICE: Bootrom authentication succeeded or NOTICE: Bootrom authentication failed.
Example:
NOTICE: CPU: STM32MP257FAK Rev.X NOTICE: Model: STMicroelectronics STM32MP257F-DK EMMC CM33TDCID OSTL Discovery Board NOTICE: Reset reason: D1 domain exits from DStandby (0x402020). NOTICE: Bootrom authentication succeeded NOTICE: BL2: v2.10-stm32mp2-r2.0(release):lts-v2.10.24-9-g7ec987986(7ec98798) NOTICE: BL2: Built : 11:05:34, Oct 27 2026 NOTICE: TRUSTED_BOARD_BOOT support enabled (M33TD) NOTICE: BL2: Booting BL31 NOTICE: BL31: v2.10-stm32mp2-r2.0(release):lts-v2.10.24-9-g7ec987986(7ec98798) NOTICE: BL31: Built : 11:05:34, Oct 27 2026 FAKE RNG implementation MUST be replaced with the REAL one
After this verification is done, TF-A must be recompiled without the DYN_DISABLE_AUTH flag, as this flag provides the capability to dynamically disable Trusted Board Boot authentication at runtime and is meant to be enabled only for development purposes.
7. Close the device[edit | edit source]
For the process and information refer to How_to_perform_Secure_Boot_from_Distribution_Package#Close_the_device
8. References[edit | edit source]