Skip to contentSkip to conversation

binman: add nxp_imx93cst etype for i.MX93 flash.bin signing

PATCH Superseded Jérémie Dautheribes (Schneider Electric) via U-Boot 2 participants 15 messages Aug 14 – Aug 17

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover binman: add nxp_imx93cst etype for i.MX93 flash.bin signing

Hello,

This series adds support for signing i.MX93 images by leveraging binman and CST, the NXP tool used for secure boot. This introduces a new binman entry type (etype) for this purpose.

The implementation is largely derived from the existing i.MX8M support, since the two share much of the same signing infrastructure.

This procedure has been tested on the imx93-evk board, using both ECDSA and RSA-PSS keys.

Patch 1: introduces the new etype
Patch 2: updates the imx93-u-boot.dtsi description to include the new signing nodes
Patches 3-4: documentation
Patch 5: adds test coverage

---
Jérémie Dautheribes (Schneider Electric) (5):
tools: binman: add nxp_imx93cst etype for i.MX93 flash.bin signing
imx93-u-boot: wrap SPL and U-Boot nodes in a CST node if AHAB_BOOT enabled
doc: imx: ahab: add AHAB introduction
doc: imx: ahab: add i.MX93 secure boot guide
binman: test: add code coverage for nxp_imx93cst etype

 .gitignore                                         |   2 +
 arch/arm/dts/imx93-u-boot.dtsi                     |  54 ++-
 doc/imx/ahab/guides/mx93_secure_boot.txt           | 269 +++++++++++++
 doc/imx/ahab/introduction_ahab.txt                 | 445 +++++++++++++++++++++
 tools/binman/etype/nxp_imx93cst.py                 | 143 +++++++
 tools/binman/ftest.py                              |  78 ++++
 tools/binman/test/vendor/nxp_imx93_csf.dts         |  18 +
 .../binman/test/vendor/nxp_imx93_csf_imagename.dts |  24 ++
 8 files changed, 1014 insertions(+), 19 deletions(-)

---
base-commit: d3e8597e46b635ec556a057bc42f0b0859654bdf
change-id: 20260814-imx93-secureboot-b914e7b6cbbf

Best regards,

Signature · 1 line
Jérémie Dautheribes (Schneider Electric) <[email protected]>
#1 lore raw

PATCH 1/5 tools: binman: add nxp_imx93cst etype for i.MX93 flash.bin signing

Add a new binman etype which allows signing both the SPL and U-Boot proper sections of i.MX93 flash.bin using CST.
The implementation is largely derived from the nxp_imx8mcst etype, as the signing procedures for both platforms are quite similar.

---
 .gitignore                         |   2 +
 tools/binman/etype/nxp_imx93cst.py | 143 +++++++++++++++++++++++++++++++++++++
 2 files changed, 145 insertions(+)
.gitignore +2 -0
index 0e09715cc60..5cb135fc58c 100644
@@ -82,6 +82,8 @@ fit-dtb.blob*
 /keep-syms-lto.*
 /*imx8mimage*
 /*imx8mcst*
+/*imx9image*
+/*imx93cst*
 /*rcar4-sa0*
 /drivers/video/u_boot_logo.bmp.S
 /test/fdt_overlay/test-fdt-overlay-stacked.dtbo.S
tools/binman/etype/nxp_imx93cst.py new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH 1/5] tools: binman: add nxp_imx93cst etype for i.MX93 flash.bin signing

Hi Jérémie,

Quoted 13 lines · Jérémie Dautheribes

tools: binman: add nxp_imx93cst etype for i.MX93 flash.bin signing

Add a new binman etype which allows signing both the SPL and U-Boot proper sections of i.MX93 flash.bin using CST.
The implementation is largely derived from the nxp_imx8mcst etype, as the signing procedures for both platforms are quite similar.

.gitignore | 2 +

 tools/binman/etype/nxp_imx93cst.py | 143 +++++++++++++++++++++++++++++++++++++
 2 files changed, 145 insertions(+)

tools/binman/etype/nxp_imx93cst.py line 54

Quoted 5 lines
tools/binman/etype/nxp_imx93cst.py new file +5 -0
+class Entry_nxp_imx93cst(Entry_mkimage):
+    """NXP i.MX93 CST .cfg file generator and cst invoker"""
+
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)

Please expand the class docstring to document the supported properties (nxp,srk-table and nxp,srk-crt) and the SRK_TABLE / SRK_KEY environment overrides, in the same style as Entry_nxp_imx8mcst. Without that, users have no way to discover what to put in the DT node. Also, __init__() does nothing beyond calling super().__init__(), so drop it.

tools/binman/etype/nxp_imx93cst.py line 3

Quoted 5 lines
tools/binman/etype/nxp_imx93cst.py +3 -0
@@ -0,0 +1,143 @@
+        if struct.unpack("<B", data[3:4])[0] != CONTAINER_HDR_TAG:
+            # Unknown section type, pass input data through.
+            return data

struct.unpack() for a single byte is overkill - 'if data[3] != CONTAINER_HDR_TAG:' is clearer and does the same thing. Also, there is no length check on data before this slice or the flags_offset read below; a short input silently produces an empty slice and the unpack raises. A quick 'if len(data) < flags_offset + 4' guard (returning data unchanged) would fail more gracefully.

Quoted 10 lines
tools/binman/etype/nxp_imx93cst.py +8 -0
@@ -0,0 +1,143 @@
+KEY_NAME = "sha384_secp384r1_v3_usr_crt"
+
+CSF_CONFIG_TEMPLATE = f"""
+[Header]
+  Target = AHAB
+  Version = 1.0
+
+[Install SRK]

tools/binman/etype/nxp_imx93cst.py line 18

Quoted 10 lines
tools/binman/etype/nxp_imx93cst.py +10 -0
+  File = "SRK_1_2_3_4_table.bin"
+  Source = "SRK1_{KEY_NAME}.pem"
+  Source index = 0
+  Source set = OEM
+  Revocations = 0x0
+
+[Authenticate Data]
+  File = "data.bin"
+  Offsets    = 0x400        0x490
+

The Offsets line embeds a literal tab and hard-coded values that are always overwritten before the config is written. Please use plain placeholders (e.g. '0x0 0x0') with a single space, so the template does not mislead the reader into thinking those numbers matter. Please follow the prevailing single-quote convention in binman.

tools/binman/etype/nxp_imx93cst.py line 4

Quoted 6 lines
tools/binman/etype/nxp_imx93cst.py +4 -0
@@ -0,0 +1,143 @@
+    def BuildSectionData(self, required):
+        data, input_fname, uniq = self.collect_contents_to_file(
+            self._entries.values(), "input"
+        )

input_fname is unused; assign it to _ to make that explicit.

Regards,
Simon

#3 lore raw

PATCH 2/5 imx93-u-boot: wrap SPL and U-Boot nodes in a CST node if AHAB_BOOT enabled

In reply to Jérémie Dautheribes (Schneider Electric) via U-Boot

In case CONFIG_AHAB_BOOT is enabled, extend the binman image description for the i.MX93 platform with a CST wrapper node. This way, if CONFIG_AHAB_BOOT is enabled, binman will be automatically used to sign SPL and U-Boot containers.

---
 arch/arm/dts/imx93-u-boot.dtsi | 54 +++++++++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 19 deletions(-)
arch/arm/dts/imx93-u-boot.dtsi +35 -19
index bd970c955cf..569b3ef5d9c 100644
@@ -47,32 +47,48 @@
 			filename = "flash.bin";
 			pad-byte = <0x00>;
 
-			spl {
-				type = "nxp-imx9image";
-				cfg-path = "spl/u-boot-spl.cfgout";
+#ifdef CONFIG_AHAB_BOOT
+			nxp-imx93cst@0 {
+				filename = "spl.signed.bin";
 				args;
-
-				boot-from = "sd";
-				soc-type = "IMX9";
-				append = "mx93a1-ahab-container.img";
-				container;
-				image = "a55", "u-boot-spl-ddr.bin", "0x2049A000";
+#endif
+				spl {
+					type = "nxp-imx9image";
+					cfg-path = "spl/u-boot-spl.cfgout";
+					args;
+
+					boot-from = "sd";
+					soc-type = "IMX9";
+					append = "mx93a1-ahab-container.img";
+					container;
+					image = "a55", "u-boot-spl-ddr.bin", "0x2049A000";
+				};
+#ifdef CONFIG_AHAB_BOOT
 			};
+#endif
 
-			u-boot {
-				type = "nxp-imx9image";
-				cfg-path = "u-boot-container.cfgout";
+#ifdef CONFIG_AHAB_BOOT
+			nxp-imx93cst@1 {
+				filename = "u-boot-container.signed.bin";
 				args;
-
-				boot-from = "sd";
-				soc-type = "IMX9";
-				container;
-				image0 = "a55", "bl31.bin", "0x204E0000";
-				image1 = "a55", "u-boot.bin", "0x80200000";
+#endif
+				u-boot {
+					type = "nxp-imx9image";
+					cfg-path = "u-boot-container.cfgout";
+					args;
+
+					boot-from = "sd";
+					soc-type = "IMX9";
+					container;
+					image0 = "a55", "bl31.bin", "0x204E0000";
+					image1 = "a55", "u-boot.bin", "0x80200000";
 #if defined(CONFIG_OPTEE)
-				image2 = "a55", "tee.bin", "0x96000000";
+					image2 = "a55", "tee.bin", "0x96000000";
 #endif
+				};
+#ifdef CONFIG_AHAB_BOOT
 			};
+#endif
 		};
 	};
 };
Signature · 1 line
2.55.0
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] imx93-u-boot: wrap SPL and U-Boot nodes in a CST node if AHAB_BOOT enabled

Hi Jérémie,

Quoted 6 lines · Jérémie Dautheribes

imx93-u-boot: wrap SPL and U-Boot nodes in a CST node if AHAB_BOOT enabled

In case CONFIG_AHAB_BOOT is enabled, extend the binman image description for the i.MX93 platform with a CST wrapper node. This way, if CONFIG_AHAB_BOOT is enabled, binman will be automatically used to sign SPL and U-Boot containers.

The two sentences say the same thing. Please fold into one, e.g. 'When CONFIG_AHAB_BOOT is enabled, wrap the SPL and U-Boot binman nodes in a CST node so that binman signs them automatically'.

Quoted 5 lines

arch/arm/dts/imx93-u-boot.dtsi | 54 +++++++++++++++++++++++++++---------------

 1 file changed, 35 insertions(+), 19 deletions(-)

Regards,
Simon

#5 lore raw

PATCH 3/5 doc: imx: ahab: add AHAB introduction

In reply to Jérémie Dautheribes (Schneider Electric) via U-Boot

Add an introductory document describing the AHAB (Advanced High Assurance Boot) secure and encrypted boot flow, covering the following topics:
- AHAB architecture overview (SCU, SECO, PKI tree)
- AHAB secure boot and encrypted boot flow
- PKI tree generation (ahab_pki_tree.sh)
- SRK Table and SRK Hash generation (srktool)
- SRK Hash fuse programming and sanity check notes
- i.MX 8ULP/93 secure boot support

This is based on doc/imx/ahab/introduction_ahab.txt from uboot-imx (lf_v2026.04). Originally written by Breno Lima, with contributions from Ye Li, Vanessa Maegima, and Utkarsh Gupta upstream in uboot-imx.

---
 doc/imx/ahab/introduction_ahab.txt | 445 +++++++++++++++++++++++++++++++++++++
 1 file changed, 445 insertions(+)
doc/imx/ahab/introduction_ahab.txt new file +445 -0
new file mode 100644
index 00000000000..4a5b6f795c4
@@ -0,0 +1,445 @@
+          +=======================================================+
+          +       i.MX Secure and Encrypted Boot using AHAB       +
+          +=======================================================+
+
+1. Introduction
+----------------
+
+The i.MX 8/8x/8ULP/9x family of applications processors introduce a new secure
+boot concept. Due to the multi-core architecture, the Security Controller (SECO)
+and System Control Unit (SCU) in i.MX 8/8x, and Edgelock secure enclave (ELE)
+in i.MX 8ULP/9x are heavily involved in the secure boot process.
+
+Step-by-step guides are available under doc/imx/ahab/guides/ directory,
+users familiar with AHAB architecture and CST PKI tree generation should
+refer to these documents instead.
+
+1.1 The AHAB Secure Boot Architecture
+--------------------------------------
+
+The Advanced High Assurance Boot (AHAB) feature relies in digital signatures to
+prevent unauthorized software execution during the device boot sequence. In
+case a malware takes control of the boot sequence, sensitive data, services and
+network can be impacted.
+
+The AHAB authentication is based on public key cryptography in which image
+data is signed offline using one or more private keys. The resulting signed
+image data is then verified on the i.MX processor using the corresponding
+public keys. The public keys are included in the final binary and the SRK
+Hash is programmed in the SoC fuses for establishing the root of trust.
+
+In i.MX8 and i.MX8x families the SCU is responsible to interface with the boot
+media, managing the process of loading the firmware and software images in
+different partitions of the SoC. The SECO is responsible to authenticate the
+images and authorize the execution of them.
+
+1.1.1 [i.MX 8/8x] The System Control Unit (SCU)
+------------------------------------
+
+The System Control Unit SCU is a subsystem equipped with a programmable M4
+core, which is responsible to handle the resource allocation, power, clocking,
+IO configuration and muxing.
+
+The SCU is also responsible to interface between the rest of the system. In the
+secure boot flow the SCU interfaces with the Security Controller (SECO),
+requesting the image authentication.
+
+The System Control Unit FW (SCFW) is responsible to control all the
+functionalities of the SCU. This firmware is distributed in a porting kit form.
+Instructions to download the SCFW Porting Kit are available in the Linux BSP
+Release Notes.
+
+Details about SCU can be found in the processors Reference Manual (RM).
+
+1.1.2 [i.MX 8/8x] The Security Controller (SECO)
+-------------------------------------
+
+The SECO is a M0+ core dedicated to handle the SoC security subsystem. The
+controller communicates with SCU domain through a dedicate message unit (MU).
+
+The SECO has a dedicate ROM which is responsible to initialize low level
+security features and to authenticate the SECO firmware previously loaded by
+the SCU ROM.
+
+The SECO firmware provides security services at run-time to different domains
+of the SoC, one of these being the capability of authenticate images.
+
+The SECO firmware is signed and distributed by NXP and is always authenticated
+in OEM open and closed configuration, instructions to download the SECO FW are
+available in the Linux BSP Release Notes.
+
+Details about SECO can be found in the processors Security Reference Manual
+(SRM).
+
+1.1.3 [i.MX 8ULP/9x] The Edgelock secure enclave
+-------------------------------------
+
+EdgeLock™ Secure Enclave is the security subsystem based on a dedicated core
+(RISC-V) to manage security tasks with a tight control on security resources
+along with other enhancements.
+
+The secure enclave has a dedicate ROM which is responsible to initialize low
+level security features and to authenticate the secure enclave firmware
+previously loaded by the boot management core.
+
+The secure enclave firmware provides security services at run-time to different
+ domains of the SoC, one of these being the capability of authenticate images.
+
+The secure enclave firmware is signed and distributed by NXP and is always
+authenticated in OEM open and closed configuration, instructions to download
+this FW are available in the Linux BSP Release Notes.
+
+Details about Edgelock secure enclave can be found in the processors Security
+Reference Manual (SRM).
+
+NOTE: The terms Sentinel, S400, and EdgeLock secure enclave (ELE), and ELE
+are used interchangeably throughout the document.
+
+1.2 The image container
+------------------------
+
+Due to the new architecture, multiple firmwares and software are required to
+boot AHAB supporting devices. In order to store all the images in a single
+binary the container image structure is used.
+
+At least two containers are needed for the boot process, the first container
+must include only the Security Subsystem FW (SECO/ELE FW provided by NXP).
+Additional containers can contain one or multiple images, depending on the
+users specific application.
+
+The final binary is generated by the imx-mkimage tool.
+
+1.3 The i.MX8/8x secure boot flow
+----------------------------------
+
+As mentioned in the introduction, due to the multiple cores architecture the
+i.MX8 boot sequence involves SCU ROM, SCFW, SECO ROM, and SECO FW.
+
+The diagram below illustrate the secure boot flow overview:
+
+System Controller   │  Security Controller  │     Cortex-M     │   Cortex-A
+      (SCU)         │        (SECO)         │                  │
+                    │                       │                  │
+ ╔═════════════╗    │   ╔═════════════╗  ┌───────────┐       ┌─────────┐
+ ║   SCU INIT  ║    │   ║  SECO INIT  ║  │  │        │       │ │       │
+ ╚══════╤══════╝    │   ╚══════╤══════╝  │  │        v       │ │       v
+        │           │          │         │  │  ┌──────────┐  │ │ ┌────────────┐
+ ╔══════╧══════╗    │          │         │  │  │ Start M4 │  │ │ │  Start AP  │
+ ║Load SECO FW ║    │          │         │  │  │   IMG    │  │ │ │    IMG     │
+ ╚══════╤══════╝    │   ╔══════╧══════╗  │  │  └──────────┘  │ │ └─────┬──────┘
+        ├──────────────>║Auth SECO FW ║  │  │                │ │       │
+ ╔══════╧══════╗    │   ╚══════╤══════╝  │  │   ┌────────────┘ │       │
+ ║ Load SCU FW ║    │          │         │  │   │              │       │
+ ║   and DCD   ║    │          │         │  │   │              │ ┌─────┴──────┐
+ ╚══════╤══════╝    │   ┌──────┴──────┐  │  │   │              │ │    Load    │
+        ├──────────────>│ Auth SCU FW │  │  │   │              │ │ Add AP IMG │
+        │           │   │   and DCD   │  │  │   │              │ └─────┬──────┘
+ ╔══════╧══════╗    │   └──────┬──────┘  │  │   │              │       │
+ ║   Run DCD   ║<──────────────┤         │  │   │              │       │
+ ╚══════╤══════╝    │          │         │  │   │      ┌───────────────┤
+        │           │          │         │  │   │      │       │       │
+ ╔══════╧══════╗    │          │         │  │   │      │       │       │
+ ║ Load M4 IMG ║    │          │         │  │   │      │       │       │
+ ╚══════╤══════╝    │   ┌──────┴──────┐  │  │   │      │       │       │
+        ├──────────────>│ Auth M4 IMG │  │  │   │      │       │       │
+ ╔══════╧══════╗    │   └──────┬──────┘  │  │   │      │       │ ┌─────┴──────┐
+ ║ Load AP IMG ║    │          │         │  │   │      │       │ │     Run    │
+ ╚══════╤══════╝    │   ┌──────┴──────┐  │  │   │      │       │ │ Add AP IMG │
+        ├──────────────>│ Auth AP IMG │  │  │   │      │       │ └────────────┘
+ ╔══════╧══════╗    │   └─────────────┘  │  │   │      │       │
+ ║Start SCU FW ║    │ ┌──────────────────┘  │   │      │       │
+ ╚══════╤══════╝    │ │                     │   │      │       │
+        │           │ │   ┌─────────────────────┘      │       │
+ ┌──────┴──────┐    │ │   │                 │          │       │
+ │  Start M4   ├──────┘   │     ┌──────────────────────┘       │
+ └──────┬──────┘    │     │     │           │                  │
+        │           │     │     │           │                  │
+ ┌──────┴──────┐    │     │     │           │                  │
+ │  Start AP   ├──────────┘     │           │                  │
+ └─────────────┘    │           │           │                  │
+        ┌───────────────────────┘           │                  │
+        │           │                       │                  │
+        v           │                       │                  │
+ ┌─────────────┐    │   ┌─────────────┐     │                  │
+ │Request SECO ├───────>│ Auth AP IMG │     │                  │
+ └─────────────┘    │   └─────────────┘     │                  │
+                    │                       │                  │
+
+
+Notes:
+All boxes enclosed by double dash (═) are performed at SCU/SECO ROM level.
+
+The sequence below explains the i.MX8 and i.MX8x boot flow:
+
+1  - At reset, the SCU ROM and SECO ROM both start execution.
+2  - The SCU ROM reads the boot configuration and loads the SECO FW (First
+     container) from the boot media to the SECO TCM.
+3  - A message is sent by the SCU ROM via MU requesting the SECO ROM to
+     authenticate the SECO FW which is signed using NXP key.
+4  - The SCU ROM loads the second container from the boot media, this container
+     must contain at least the SCFW which is signed using the OEM keys.
+5  - The SCU ROM loads the SCFW to the SCU TCM, a message is sent via MU
+     requesting the SECO FW to authenticate the SCFW and DCD table.
+6  - The SCU ROM configures the DDR and loads the M4 and AP images included in
+     the second container to their respective load addresses.
+7  - The SCU ROM request the SECO FW to authenticate the M4 image.
+8  - The SCU ROM request the SECO FW to authenticate the AP image. This image
+     is the initial AP core software, depending in the U-Boot target it can
+     be the U-Boot and ATF or only SPL.
+9  - The SCFW is initialized and starts the ARM Cortex-M and Cortex-A cores.
+10 - From this point additional containers can be loaded by Cortex-M and
+     Cortex-A cores and authenticated by SECO, the AP SW must interface with
+     SCU by calling the sc_misc_seco_authenticate() API function. In current
+     U-Boot implementation the additional image can be the Linux Kernel binary
+     or the U-Boot proper and ATF. Details about current U-Boot implementation
+     can be found in AHAB guides included in doc/imx/ahab/guides/ directory.
+
+1.4 The i.MX 8ULP/9x secure boot flow
+----------------------------------
+
+The secure boot sequence involves multiple cores booting up at same time and
+Edgelock secure enclave ensure authentication of any boot software being loaded.
+
+The diagram below illustrate the secure boot flow overview for dual boot
+scenario in i.MX 8ULP:
+
+
+    Cortex-M(CM)     │   Edgelock Secure   │    Cortex-A(CA)   │   uPower(uP)
+                     │    Enclave(ELE)     │                   │
+          │          │          │          │         │         │        │
+   ┌┬─────┴─────┬┐   │   ┌┬─────┴─────┬┐   │         │         │ ┌┬─────┴─────┬┐
+   ││   INIT    ││   │   ││   INIT    ││   │         │         │ ││   INIT    ││
+   └┴─────┬─────┴┘   │   └┴─────┬─────┴┘   │         │         │ └┴─────┬─────┴┘
+          │          │          │          │  ┌┬─────┴─────┬┐  │        │
+   ┌┬─────┴─────┬┐   │          │          │  ││Load CA FW ││ ┌──────┐  │
+   ││Load uP FW ││   │          │          │  └┴─────┬─────┴┘ ││     │  │
+   └┴─────┬─────┴┘   │          │          │         │        ││ ┌┬──v──┴─────┬┐
+          │          │   ┌┬─────┴─────┬┐   │┌────────┤        ││ ││Load &Start││
+          ├─────────────>├│Auth uP FW ││   ││        │        ││ ││   uP FW   ││
+          │          │   └┴─────┬─────┴┘   ││        │        ││ └┴───────────┴┘
+   ┌┬─────┴─────┬┐   │          │          ││        │        ││
+   ││Load CM  FW││   │          ├────────────────────┼────────┘│
+   └┴─────┬─────┴┘   │          │          ││        │         │
+          │          │   ┌┬─────┴─────┬┐   ││        │         │
+          ├─────────────>├│Auth CM FW ││   ││ ┌┬─────┴─────┬┐  │
+          │          │   └┴─────┬─────┴┘   ││ ││Start CA FW││  │
+   ┌┬─────┴─────┬┐   │          │          ││ └┴─────┬─────┴┘  │
+   ││Load ELE FW││   │          │          ││        │         │
+   └┴─────┬─────┴┘   │          │          ││        │         │
+          │          │   ┌┬─────┴─────┬┐   ││        │         │
+          ├─────────────>├│Auth ELE FW││   ││        │         │
+          │          │   └┴─────┬─────┴┘   ││ ┌┬─────┴─────┬┐  │
+   ┌┬─────┴─────┬┐   │          │          ││ ││ Load SPL  ││  │
+   ││Start CM FW││   │          │          ││ └┴─────┬─────┴┘  │
+   └┴─────┬─────┴┘   │          │          ││        │         │
+          │          │   ┌┬─────┴─────┬┐   ││   ┌────┤         │
+          │          │   ││Auth CA FW │┤<───┘   │    │         │
+          │          │   └┴─────┬─────┴┘   │    │    │         │
+          │          │          │          │    │    │         │
+          │          │   ┌┬─────┴─────┬┐   │    │    │         │
+          │          │   ││ Auth SPL  │┤<───────┘    │         │
+          │          │   └┴─────┬─────┴┘   │         │         │
+          │          │          ├─────────────────┐  │         │
+          │          │          │          │      │  │         │
+          │          │          │          │  ┌┬──v──v─────┬┐  │
+          │          │          │          │  ││  Run SPL  ││  │
+          │          │          │          │  └┴───────────┴┘  │
+
+
+The diagram below illustrate the secure boot flow overview for single boot
+scenario in i.MX 9x:
+
+
+    Cortex-A(CA)     │   Edgelock Secure   │    Cortex-M(CM)
+                     │    Enclave(ELE)     │
+          │          │          │          │         │
+   ┌┬─────┴─────┬┐   │   ┌┬─────┴─────┬┐   │         │
+   ││   INIT    ││   │   ││   INIT    ││   │         │
+   └┴─────┬─────┴┘   │   └┴─────┬─────┴┘   │         │
+          │          │          │          │  ┌┬─────┴─────┬┐
+          │          │          │          │┌>││   INIT    ││
+          │          │          │          ││ └┴─────┬─────┴┘
+   ┌┬─────┴─────┬┐   │          │          ││        |
+   ││Load ELE FW││─────────────>│          ││        │
+   └┴─────┬─────┴┘   |          |          |│        |
+          │          │   ┌┬─────┴─────┬┐   ││ ┌┬─────┴─────┬┐
+          │          │   ├│Auth ELE FW││   ││ ││Start CM FW││
+          │          │   └┴─────┬─────┴┘   ││ └┴─────┬─────┴┘
+          |          |          |          |│        |
+   ┌┬─────┴─────┬┐   │          │          ││        │
+   ││Load CM  FW││   │          |          ││        │
+   └┴─────┬─────┴┘   │          │          ││        │
+          │          │   ┌┬─────┴─────┬┐   ││        │
+          ├─────────────>├│Auth CM FW ││   ││        │
+          │          │   └┴─────┬─────┴┘   ││        │
+          |          │          │          ││        │
+          │          │          |───────────┘        │
+   ┌┬─────┴─────┬┐   │          │          │         │
+   ││Load  CA FW││   │          │          │         │
+   └┴─────┬─────┴┘   │          │          │         │
+          │          │   ┌┬─────┴─────┬┐   │         │
+          ├─────────────>├│Auth CA  FW││   │         │
+          │          │   └┴─────┬─────┴┘   │         │
+   ┌┬─────┴─────┬┐   │          │          │         │
+   ││Start CA FW││   │          |          │         │
+   └┴─────┬─────┴┘   │          │          │         │
+          |          │          │          │         │
+          |          │          │          │         │
+          |          │          │          │         │
+
+More details on the boot flow can be found in respective Security Reference
+Manual (SRM).
+
+
+2. Generating a PKI tree
+-------------------------
+
+The first step is to generate the private keys and public keys certificates.
+The AHAB architecture is based on a Public Key Infrastructure (PKI) tree.
+
+The Code Signing Tools package contains an OpenSSL based key generation script
+under keys/ directory. The ahab_pki_tree.sh script generates a PKI tree
+containing 4 Super Root Keys (SRK), possible to also include a subordinate
+SGK key.
+
+The AHAB supports both RSA and ECC keys, a new PKI tree can be generated by
+following the example below:
+
+- Generating a P384 ECC PKI tree on CST (starting from v3.1.0):
+
+  $ ./ahab_pki_tree.sh
+  ...
+  Do you want to use an existing CA key (y/n)?: n
+  Do you want to use Elliptic Curve Cryptography (y/n)?: y
+  Enter length for elliptic curve to be used for PKI tree:
+  Possible values p256, p384, p521:  p384
+  Enter the digest algorithm to use: sha384
+  Enter PKI tree duration (years): 5
+  Do you want the SRK certificates to have the CA flag set? (y/n)?: n
+
+The diagram below illustrate the PKI tree generated:
+
+                             ┌─────────┐
+                             │   CA    │
+                             └────┬────┘
+                                  │
+                                  │
+         ┌───────────────┬────────┴────────┬───────────────┐
+         │               │                 │               │
+         │               │                 │               │
+         v               v                 v               v
+    ┌────────┐       ┌────────┐       ┌────────┐       ┌────────┐
+    │  SRK1  │       │  SRK2  │       │  SRK3  │       │  SRK4  │
+    └────────┘       └────────┘       └────────┘       └────────┘
+
+2.1 Generating a PKI tree including a subordinate SGK key
+----------------------------------------------------------
+
+The ahab_pki_tree.sh script is also able to generate a PKI tree containing a
+subordinate key of the SRK, this key can be used to verify the signature
+included in the final signed image.
+
+Users should set the CA flag when generating the SRK certificates.
+
+- Generating a P384 ECC PKI tree with a subordinate SGK key on CST (starting
+from v3.1.0):
+
+  $ ./ahab_pki_tree.sh
+  ...
+  Do you want to use an existing CA key (y/n)?: n
+  Do you want to use Elliptic Curve Cryptography (y/n)?: y
+  Enter length for elliptic curve to be used for PKI tree:
+  Possible values p256, p384, p521:  p384
+  Enter the digest algorithm to use: sha384
+  Enter PKI tree duration (years): 5
+  Do you want the SRK certificates to have the CA flag set? (y/n)?: y
+
+The diagram below illustrate the PKI tree generated:
+
+                             ┌─────────┐
+                             │   CA    │
+                             └────┬────┘
+                                  │
+                                  │
+         ┌───────────────┬────────┴────────┬───────────────┐
+         │               │                 │               │
+         v               v                 v               v
+    ┌────────┐       ┌────────┐       ┌────────┐       ┌────────┐
+    │  SRK1  │       │  SRK2  │       │  SRK3  │       │  SRK4  │
+    └────┬───┘       └───┬────┘       └────┬───┘       └───┬────┘
+         │               │                 │               │
+         v               v                 v               v
+    ┌────────┐       ┌────────┐       ┌────────┐       ┌────────┐
+    │  SGK1  │       │  SGK2  │       │  SGK3  │       │  SGK4  │
+    └────────┘       └────────┘       └────────┘       └────────┘
+
+2.2 Generating a SRK Table and SRK Hash
+----------------------------------------
+
+The next step is to generated the SRK Table and its respective SRK Table Hash
+from the SRK public key certificates created in one of the steps above.
+
+In the AHAB architecture, the SRK Table is included in the signed image and the
+SRK Hash is programmed in the SoC SRK_HASH[511:0]/SRK_HASH[255:0] fuses.
+
+On the target device during the authentication process the AHAB code verify the
+SRK Table against the SoC SRK_HASH fuses, in case the verification is successful
+the root of trust is established and the AHAB code can progress with the image
+authentication.
+
+The srktool can be used to generate the SRK Table and its respective SRK
+Table Hash.
+
+- Generating SRK Table and SRK Hash in Linux 64-bit machines:
+  - In i.MX 8/8x family, the expected SRK HASH is of 512 bit.
+    $ cd ../crts/
+    $ ../linux64/bin/srktool -a -s sha384 -t SRK_1_2_3_4_table.bin \
+	  -e SRK_1_2_3_4_fuse.bin -f 1 -c \
+	  SRK1_sha384_secp384r1_v3_usr_crt.pem,\
+	  SRK2_sha384_secp384r1_v3_usr_crt.pem,\
+	  SRK3_sha384_secp384r1_v3_usr_crt.pem,\
+	  SRK4_sha384_secp384r1_v3_usr_crt.pem
+
+  - In i.MX 8ULP/9x, the expected SRK HASH is of 256 bit.
+    $ cd ../crts/
+    $ ../linux64/bin/srktool -a -d sha256 -s sha384 -t SRK_1_2_3_4_table.bin \
+	  -e SRK_1_2_3_4_fuse.bin -f 1 -c \
+	  SRK1_sha384_secp384r1_v3_usr_crt.pem,\
+	  SRK2_sha384_secp384r1_v3_usr_crt.pem,\
+	  SRK3_sha384_secp384r1_v3_usr_crt.pem,\
+	  SRK4_sha384_secp384r1_v3_usr_crt.pem
+
+    Regenerate the SRK HASH (SRK_1_2_3_4_fuse.bin) by using SHA256 with
+    SRK_1_2_3_4_table.bin.
+    $ openssl dgst -binary -sha256 SRK_1_2_3_4_table.bin
+
+
+
+- Optionally users can check if the sha512sum/sha256sum of SRK_1_2_3_4_table
+matches with the SRK_1_2_3_4_fuse.bin:
+
+  $ od -t x4 --endian=big SRK_1_2_3_4_fuse.bin
+  0000000 01b04697 0253376b 2066fe56 aaef9a91
+  0000020 e62e09d8 14fb7e36 d5b38d05 0982edab
+  0000040 7ada6576 2f6b4f59 1fd9347e 46e7305d
+  0000060 46e34bf0 89780bd1 c809e714 a17e2f4e
+
+  $ sha512sum SRK_1_2_3_4_table.bin
+  01b046970253376b2066fe56aaef9a91\
+  e62e09d814fb7e36d5b38d050982edab\
+  7ada65762f6b4f591fd9347e46e7305d\
+  46e34bf089780bd1c809e714a17e2f4e\
+  SRK_1_2_3_4_table.bin
+
+NOTE: The commands above cannot be used as reference to program the SoC
+      SRK_HASH fuses.
+
+The SRK_1_2_3_4_table.bin and SRK_1_2_3_4_fuse.bin files can be used in further
+steps as explained in AHAB guides available under doc/imx/ahab/guides/
+directory.
+
+3 Known limitations
+----------------------------------------
+
+- Due to a limitation in i.MX8QXP B0 silicon it's not possible to use RSA
+4096-bit SRK keys with an additional subordinate SGK key.
Signature · 1 line
2.55.0
#6 lore raw

Re: [PATCH 3/5] doc: imx: ahab: add AHAB introduction

Hi Jérémie,

Quoted 12 lines · Jérémie Dautheribes

doc: imx: ahab: add AHAB introduction

Add an introductory document describing the AHAB (Advanced High Assurance Boot) secure and encrypted boot flow, covering the following topics:
- AHAB architecture overview (SCU, SECO, PKI tree)
- AHAB secure boot and encrypted boot flow
- PKI tree generation (ahab_pki_tree.sh)
- SRK Table and SRK Hash generation (srktool)
- SRK Hash fuse programming and sanity check notes
- i.MX 8ULP/93 secure boot support

Quoted 4 lines

This is based on doc/imx/ahab/introduction_ahab.txt from uboot-imx (lf_v2026.04). Originally written by Breno Lima, with contributions from Ye Li, Vanessa Maegima, and Utkarsh Gupta upstream in uboot-imx.

Firstly it's great to get some detailed documentation, thank you.

Please convert this to reStructuredText and hook it into the Sphinx tree (e.g. under doc/imx/ with an index.rst), so it is discoverable via https://docs.u-boot.org rather than being an orphan file only mailing-list readers will find. New U-Boot documentation is expected to be rst; the neighbouring habv4/introduction_habv4.txt being .txt is legacy, not a target to match.

doc/imx/ahab/introduction_ahab.txt line 79

Quoted 12 lines

doc/imx/ahab/introduction_ahab.txt | 445 +++++++++++++++++++++++++++++++++++++

 1 file changed, 445 insertions(+)

+1.1.3 [i.MX 8ULP/9x] The Edgelock secure enclave
+-------------------------------------

doc/imx/ahab/introduction_ahab.txt new file +4 -0
+
+EdgeLock™ Secure Enclave is the security subsystem based on a dedicated core
+(RISC-V) to manage security tasks with a tight control on security resources
+along with other enhancements.

Just to check - is this really verbatim from uboot-imx? The ™ is non-ASCII and will look odd in a plain-text doc and trip up some readers. Please drop it (or spell out 'EdgeLock Secure Enclave') here and anywhere else it appears.

doc/imx/ahab/introduction_ahab.txt line 96

Quoted 2 lines
doc/imx/ahab/introduction_ahab.txt new file +2 -0
+NOTE: The terms Sentinel, S400, and EdgeLock secure enclave (ELE), and ELE
+are used interchangeably throughout the document.

Nit: ELE is listed twice. Please drop one.

Quoted 9 lines
doc/imx/ahab/introduction_ahab.txt new file +3 -0
new file mode 100644
index 00000000000..4a5b6f795c4
@@ -0,0 +1,445 @@
+1.2 The image container
+------------------------
+

doc/imx/ahab/introduction_ahab.txt line 13

Quoted 10 lines
doc/imx/ahab/introduction_ahab.txt new file +10 -0
+Due to the new architecture, multiple firmwares and software are required to
+boot AHAB supporting devices. In order to store all the images in a single
+binary the container image structure is used.
+
+At least two containers are needed for the boot process, the first container
+must include only the Security Subsystem FW (SECO/ELE FW provided by NXP).
+Additional containers can contain one or multiple images, depending on the
+users specific application.
+
+The final binary is generated by the imx-mkimage tool.

Since this series adds a binman-based path for i.MX93 (patches 1 and 2), please mention that binman is now an alternative to imx-mkimage for producing the final signed binary, and cross-reference the new i.MX93 guide in patch 4/5. As written, a reader would assume imx-mkimage is the only option.

Regards,
Simon

#7 lore raw

PATCH 4/5 doc: imx: ahab: add i.MX93 secure boot guide

In reply to Jérémie Dautheribes (Schneider Electric) via U-Boot

Add a step-by-step guide describing how to securely boot an i.MX93 image using AHAB.

This guide is largely based on the following documents:
- doc/imx/ahab/guides/mx8ulp_9x_secure_boot.txt, from uboot-imx (lf_v2026.04), originally written by Utkarsh Gupta
- doc/imx/habv4/guides/mx8m_spl_secure_boot.txt, from this tree, originally written by Marek Vasut

---
 doc/imx/ahab/guides/mx93_secure_boot.txt | 269 +++++++++++++++++++++++++++++++
 1 file changed, 269 insertions(+)
doc/imx/ahab/guides/mx93_secure_boot.txt new file +269 -0
new file mode 100644
index 00000000000..45a70926d51
@@ -0,0 +1,269 @@
++=========================================================+
++       i.MX93 Secure boot guide using AHAB               +
++=========================================================+
+
+1. AHAB secure boot process
+----------------------------
+
+This document provides a step-by-step guide on how to securely boot an
+i.MX93 boot image. It is assumed that the reader is familiar with basic
+AHAB concepts and with the PKI tree generation. Details about AHAB can be
+found in the introduction_ahab.txt document and in processors Security
+Reference Manual Document (SRM). The i.MX93 signing procedure is
+integrated in the U-Boot build thanks to binman.
+
+1.1 Preparing the environment to build a secure boot image
+-----------------------------------------------------------
+
+Secure boot image preparation requires the U-Boot build system to build
+the image and the Code Signing Tool (CST) to sign it.
+
+Based on boot mode, the following files are needed to prepare the boot
+image:
+
+- All boot modes
+  - Edgelock secure enclave Firmware (ELE) (Optional).
+  - DDR PHY initialization firmware.
+  - U-Boot proper and SPL.
+  - ARM Trusted Firmware (ATF).
+  - OPTEE (Optional)
+
+The ELE FW is distributed by NXP and is already signed using NXP keys.
+In the following sections, <work> designates the repository where all
+parts have been downloaded and built.
+
+1.2 Preparing U-Boot to support AHAB secure boot features
+----------------------------------------------------------
+
+The U-Boot/SPL provides extra AHAB supported functionalities that include
+extension of Root of Trust, checking any events(issues) after image
+authentication, chip lifecycle status, securing the target etc.
+
+The support is enabled by adding CONFIG_AHAB_BOOT to the defconfig file
+used by your target:
+
+  - Defconfig:
+    CONFIG_AHAB_BOOT=y
+  - Kconfig:
+    ARM architecture -> Support i.MX9 AHAB features
+
+Enabling this feature allows the SPL and U-Boot images to extend the Root
+of Trust by using the AHAB API call via ELE FW. It also enables binman to
+automatically sign the SPL and U-Boot containers while building
+flash.bin, as described in the next sections.
+
+1.3 i.MX93 AHAB image layout
+-----------------------------
+
+The i.MX93 flash.bin image is built by binman and is composed of up to
+three containers. The ELE FW container is optional and is provided by NXP,
+it is appended at the beginning of the image when the file
+mx93a1-ahab-container.img is present in the build directory. The SPL and
+U-Boot containers are built by the nxp-imx9image etype and signed by the
+nxp-imx93cst etype.
+
+            *start ----> +---------------------------+ ---------
+                         |   1st Container header    |   ^
+                         |       and signature       |   |  Authenticated at
+                         +---------------------------+   |  ELE ROM/FW Level
+                         |          Padding          |   |
+                         +---------------------------+   |
+                         |           ELE FW          |   v
+     *start + 0x400 ---> +---------------------------+ ---------
+                         |   2nd Container header    |   ^
+                         |       and signature       |   |  Authenticated at
+                         +---------------------------+   |  ELE ROM/FW Level
+                         |          Padding          |   |
+                         +---------------------------+   |
+                         |            SPL            |   v
+                         +---------------------------+ ---------
+                         |   3rd Container header    |   ^
+                         |       and signature       |   |  Authenticated at
+                         +---------------------------+   |  SPL Level
+                         |          Padding          |   |
+                         +---------------------------+   |
+                         |    ARM Trusted FW (ATF)   |   |
+                         +---------------------------+   |
+                         |       U-Boot proper       |   |
+                         +---------------------------+   |
+                         |      OPTEE (optional)     |   v
+                         +---------------------------+ ---------
+
+The first container includes the ELE FW which is signed using NXP keys,
+this container is authenticated by ELE ROM.
+
+The second container includes the SPL which is signed using OEM keys,
+this container is authenticated at ELE FW level.
+
+The third container includes the U-Boot proper and the ATF. The SPL is in
+charge to load this container and also to interface with ELE FW to
+authenticate the additional container.
+
+The signing procedure is slightly different when compared with HABv4
+series. On AHAB the signature is directly included in the container, the
+CST is responsible to sign and handle the "Signature Block":
+
+             +----------------------------+ ---------
+             |                            |  ^
+             |                            |  |
+             |      Container header      |  |
+             |                            |  |
+             |                            |  |
+             +---+------------------------+  |
+             | S | Signature block header |  | Signed
+             | i +------------------------+  |
+             | g |                        |  |
+             | n |                        |  |
+             | a |        SRK table       |  |
+             | t |                        |  |
+             | u |                        |  v
+             | r +------------------------+ ---------
+             | e |       Signature        |
+             |   +------------------------+
+             | B |                        |
+             | l |        SGK Key         |
+             | o | Certificate (optional) |
+             | c |                        |
+             | k |                        |
+             +---+------------------------+
+
+The certificate block is divided into:
+
+                    +---------------+ ^
+                    |  Public key   | | Signed
+                    |  Permission   | |
+                    +---------------+ v
+                    |   Signature   |
+                    +---------------+
+
+The first block (public key permission) verifies the Signature block
+preceding (between SRK table and Certificate blocks), while the second
+block (signature) is verified by the SRK table block.
+
+In case not using the subordinate key, the container signature is
+verified against the SRK keys directly.
+
+1.4 Signing the images
+-----------------------
+
+Internally, Command Sequence Files (CSF) are used. The CSF files contain
+all the commands that the AHAB executes during the secure boot. These
+commands instruct the AHAB code on which memory areas of the image to
+authenticate, which keys to install, use and etc. The CSF is generated
+using the CST Code Signing Tool based on input configuration file. This
+tool input configuration file is generated using binman, and the tool
+is invoked from binman as well.
+
+The existing file structure is automatically collected by the nxp-imx93cst
+etype and submitted as a single signing operation: the container header
+and the signature block offsets are read from the i.MX container header,
+so the offsets in the CST configuration file are always correct, whether
+the ELE FW is bundled in the image or not.
+
+Per default the AHAB keys and certificates need to be located in the
+build directory, this means creating a symbolic link or copying the
+following files from the AHAB PKI tree directory into the u-boot build
+directory for the CST Code Signing Tool to locate them:
+
+- `crts/SRK_1_2_3_4_table.bin`
+- `crts/SRK1_sha384_secp384r1_v3_usr_crt.pem`
+- `keys/SRK1_sha384_secp384r1_v3_usr_key.pem`
+- `keys/key_pass.txt`
+
+See the introduction_ahab.txt document for the PKI tree generation
+procedure (ahab_pki_tree tool) and for the SRK Table generation
+(srktool, use the SHA256 variant for i.MX93).
+
+The paths to the SRK table and the certificate can be modified via
+changes to the nxp-imx93cst device tree node(s) or via the environment
+variables.
+
+The nxp-imx93cst etype is configurable using either DT properties or
+environment variables. The following DT properties and environment
+variables are supported. Note that environment variables override DT
+properties.
+
++--------------------+-------------+--------------------------------------------------------------+
+| DT property        | Variable    | Description                                                  |
++====================+=============+==============================================================+
+| nxp,srk-table      | SRK_TABLE   | full path to SRK_1_2_3_4_table.bin                           |
++--------------------+-------------+--------------------------------------------------------------+
+| nxp,srk-crt        | SRK_KEY     | full path to the SRK Key SRK1_sha384_secp384r1_v3_usr_crt.pem|
++--------------------+-------------+--------------------------------------------------------------+
+
+Environment variables can be set as follows to point the build process
+to external key material:
+
+  $ export SRK_TABLE=$CST_DIR/crts/SRK_1_2_3_4_table.bin
+  $ export SRK_KEY=$CST_DIR/crts/SRK1_sha384_secp384r1_v3_usr_crt.pem
+  $ make flash.bin
+
+1.5 Programming SRK Hash
+-------------------------
+
+As explained in introduction_ahab.txt document, the SRK Hash fuse values
+are generated by the srktool and should be programmed in the SoC
+SRK_HASH[255:0] fuses.
+
+Be careful when programming these values, as this data is the basis for
+the root of trust. An error in SRK Hash results in a part that does not
+boot.
+
+The U-Boot fuse tool can be used for programming eFuses on i.MX SoCs.
+
+- Dump SRK Hash fuses values in host machine:
+
+  On i.MX93 family, the SRK Hash uses sha256 and dump 8 words fuses
+  $ od -t x4 SRK_1_2_3_4_fuse.bin
+  0000000 db2959f2 90dfc39c 53394566 e0b75829
+  0000020 85e6f3b1 af00983d e5e804fe 7a451024
+
+- Program SRK_HASH[255:0] fuses:
+
+On i.MX93:
+
+  => fuse prog 16 0 0xdb2959f2
+  => fuse prog 16 1 0x90dfc39c
+  => fuse prog 16 2 0x53394566
+  => fuse prog 16 3 0xe0b75829
+  => fuse prog 16 4 0x85e6f3b1
+  => fuse prog 16 5 0xaf00983d
+  => fuse prog 16 6 0xe5e804fe
+  => fuse prog 16 7 0x7a451024
+
+1.6 Verify AHAB events
+-----------------------
+
+If the fuses have been burned properly, there should be no AHAB events
+after boot. To validate this, power on the board, and run ahab_status
+command on U-Boot terminal.
+
+No events should be returned after this command:
+
+  => ahab_status
+  Lifecycle: 0x00000008, OEM Open
+
+          No Events Found!
+
+1.7 Close the device
+---------------------
+
+After the device successfully boots a signed image without generating any
+AHAB security events, it is safe to close the device. The chip lifecycle
+should be changed from OEM open to OEM closed. Be aware this step can
+damage your board if a previous step failed. It is also irreversible. Run
+on the U-Boot terminal:
+
+  => ahab_close
+
+Warning: Please ensure your sample is in OEM Open state, OEM SRK hash
+has been fused, and you are able to boot a signed image successfully
+without any SECO events reported. If not, your sample will be
+unrecoverable.
+
+Now reboot the target, and run:
+
+  => ahab_status
+  Lifecycle: 0x00000020, OEM Closed
+
+          No Events Found!
Signature · 1 line
2.55.0
#8 lore raw

Re: [PATCH 4/5] doc: imx: ahab: add i.MX93 secure boot guide

Hi Jérémie,

Quoted 16 lines · Jérémie Dautheribes

doc: imx: ahab: add i.MX93 secure boot guide

Add a step-by-step guide describing how to securely boot an i.MX93 image using AHAB.

This guide is largely based on the following documents:
- doc/imx/ahab/guides/mx8ulp_9x_secure_boot.txt, from uboot-imx (lf_v2026.04), originally written by Utkarsh Gupta
- doc/imx/habv4/guides/mx8m_spl_secure_boot.txt, from this tree, originally written by Marek Vasut

doc/imx/ahab/guides/mx93_secure_boot.txt | 269 +++++++++++++++++++++++++++++++

 1 file changed, 269 insertions(+)

doc/imx/ahab/guides/mx93_secure_boot.txt line 261

Quoted 3 lines
doc/imx/ahab/guides/mx93_secure_boot.txt new file +3 -0
+Warning: Please ensure your sample is in OEM Open state, OEM SRK hash
+has been fused, and you are able to boot a signed image successfully
+without any SECO events reported. If not, your sample will be

SECO does not exist on i.MX93 - the security subsystem is ELE. This is a leftover from the mx8ulp_9x guide; please change to 'AHAB events' (or 'ELE events') to match the earlier ahab_status step.

doc/imx/ahab/guides/mx93_secure_boot.txt line 12

Quoted 4 lines
doc/imx/ahab/guides/mx93_secure_boot.txt new file +4 -0
+i.MX93 boot image. It is assumed that the reader is familiar with basic
+AHAB concepts and with the PKI tree generation. Details about AHAB can be
+found in the introduction_ahab.txt document and in processors Security
+Reference Manual Document (SRM). The i.MX93 signing procedure is

Minor: 'processors Security Reference Manual Document' reads awkwardly
- please make it 'the processor Security Reference Manual (SRM)' and drop the redundant 'Document'.

doc/imx/ahab/guides/mx93_secure_boot.txt line 152

Quoted 3 lines
doc/imx/ahab/guides/mx93_secure_boot.txt new file +3 -0
+all the commands that the AHAB executes during the secure boot. These
+commands instruct the AHAB code on which memory areas of the image to
+authenticate, which keys to install, use and etc. The CSF is generated

'install, use and etc.' is not quite English - please rephrase, e.g. 'which keys to install and use, and so on'.

Quoted 5 lines

+| DT property | Variable | Description |
++====================+=============+==============================================================+
+| nxp,srk-table | SRK_TABLE | full path to SRK_1_2_3_4_table.bin |
++--------------------+-------------+--------------------------------------------------------------+
+| nxp,srk-crt | SRK_KEY | full path to the SRK Key SRK1_sha384_secp384r1_v3_usr_crt.pem|

Just to clarify for the reader - this points at the SRK certificate (_crt.pem), not the private key. The DT property is nxp,srk-crt but the env var is SRK_KEY, which is confusing on its own; please spell out in the Description column that it is the SRK certificate. Also, the matching _key.pem file must sit next to the cert for CST to find it - worth stating explicitly, since there is no knob to point at it separately.

doc/imx/ahab/guides/mx93_secure_boot.txt line 175

Quoted 3 lines
doc/imx/ahab/guides/mx93_secure_boot.txt new file +3 -0
+See the introduction_ahab.txt document for the PKI tree generation
+procedure (ahab_pki_tree tool) and for the SRK Table generation
+(srktool, use the SHA256 variant for i.MX93).

Just to check - the default key material the etype uses is 'sha384_secp384r1' (see KEY_NAME in nxp_imx93cst.py), so telling the reader to use the SHA256 srktool variant looks inconsistent with what CST is then asked to sign with. Can you confirm which srktool hash flag matches the shipped default, and align this sentence with it?

Regards,
Simon

#9 lore raw

Re: [PATCH 4/5] doc: imx: ahab: add i.MX93 secure boot guide

Hi Simon,

On 8/14/26 23:23, Simon Glass wrote:

[..]

Quoted 10 lines

doc/imx/ahab/guides/mx93_secure_boot.txt line 175

Quoted 3 lines
doc/imx/ahab/guides/mx93_secure_boot.txt new file +3 -0
+See the introduction_ahab.txt document for the PKI tree generation
+procedure (ahab_pki_tree tool) and for the SRK Table generation
+(srktool, use the SHA256 variant for i.MX93).

Just to check - the default key material the etype uses is 'sha384_secp384r1' (see KEY_NAME in nxp_imx93cst.py), so telling the reader to use the SHA256 srktool variant looks inconsistent with what CST is then asked to sign with. Can you confirm which srktool hash flag matches the shipped default, and align this sentence with it?

I'll probably remove this mention, as I don't think it's really necessary, but to clarify, there are two different checksums at play here:
- The SRK table checksum: the i.MX93 only supports SHA256, so when
generating the table with srktool, the user must specify this algorithm.
- The signature/key checksum: the i.MX93 supports multiple key
algorithms (RSA, ECDSA, ...), each with its own associated digest.

So in my sentence, "use the SHA256 srktool variant" refers to the first case, whereas the default key name ("sha384_secp384r1") refers to the second, i.e. the digest associated with that specific key algorithm.

Best regards,
Jérémie

Signature · 3 lines
Jérémie Dautheribes, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#10 lore raw

PATCH 5/5 binman: test: add code coverage for nxp_imx93cst etype

In reply to Jérémie Dautheribes (Schneider Electric) via U-Boot

Add test methods to cover all code paths of the nxp_imx93cst etype, reusing the pattern of the nxp_imx8mcst as done in commit 0cab35362d77 ("binman: test: Fix code coverage for iMX8 and cst bintool") by Simon Glass.

This brings nxp_imx93cst to 100% coverage.

---
 tools/binman/ftest.py                              | 78 ++++++++++++++++++++++
 tools/binman/test/vendor/nxp_imx93_csf.dts         | 18 +++++
 .../binman/test/vendor/nxp_imx93_csf_imagename.dts | 24 +++++++
 3 files changed, 120 insertions(+)
tools/binman/ftest.py +78 -0
index 66695a83508..ee5c027e0ea 100644
@@ -35,6 +35,7 @@ from dtoc import fdt
 from dtoc import fdt_util
 from binman.etype import fdtmap
 from binman.etype import image_header
+from binman.etype import nxp_imx93cst
 from binman.image import Image
 from u_boot_pylib import command
 from u_boot_pylib import terminal
@@ -8152,6 +8153,83 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
             result = cst.fetch(bintool.FETCH_BUILD)
             self.assertEqual(('cst', None), result)
 
+    def testNxpImx93cstNormal(self):
+        """Test CST signing with an i.MX93 SPL container (no ELE FW)"""
+        # Create a fake AHAB SPL container: tag at offset 3, image-entry
+        # flags at offset 40 whose low byte is the A55 core/type (0x23),
+        # and the signature block offset at offset 12
+        spl_data = bytearray(64)
+        spl_data[3] = nxp_imx93cst.CONTAINER_HDR_TAG
+        spl_data[12:14] = struct.pack('<H', 0x90)
+        spl_data[40:44] = struct.pack('<I', 0x123)
+        self._MakeInputFile('imx93-container.bin', bytes(spl_data))
+
+        with terminal.capture() as (_, stderr):
+            self._DoTestFile('vendor/nxp_imx93_csf.dts',
+                             force_missing_bintools='cst')
+        err = stderr.getvalue()
+        self.assertRegex(err, "Image 'image'.*missing bintools.*: cst")
+
+    def testNxpImx93cstELE(self):
+        """Test CST signing with an i.MX93 SPL container including the ELE
+        FW"""
+        # Create a fake AHAB image starting with the NXP-signed ELE
+        # container. The low byte of the first image entry flags (0x66) is
+        # the ELE core/type, so the SPL container header is at 0x400
+        ele_data = bytearray(0x410)
+        ele_data[3] = nxp_imx93cst.CONTAINER_HDR_TAG
+        ele_data[40:44] = struct.pack('<I', 0x866)
+        ele_data[0x400 + 3] = nxp_imx93cst.CONTAINER_HDR_TAG
+        ele_data[0x400 + 12:0x400 + 14] = struct.pack('<H', 0x90)
+        self._MakeInputFile('imx93-container.bin', bytes(ele_data))
+
+        with terminal.capture() as (_, stderr):
+            self._DoTestFile('vendor/nxp_imx93_csf.dts',
+                             force_missing_bintools='cst')
+        err = stderr.getvalue()
+        self.assertRegex(err, "Image 'image'.*missing bintools.*: cst")
+
+    def testNxpImx93cstUnknownTag(self):
+        """Test CST with unknown input tag passes data through"""
+        # Trigger the pass-through path using an input without the AHAB
+        # container tag
+        data = b'\x00' * 64
+        self._MakeInputFile('imx93-container.bin', data)
+        self._DoTestFile('vendor/nxp_imx93_csf.dts',
+                         force_missing_bintools='cst')
+
+    def testNxpImx93cstSigned(self):
+        """Test CST-signing-success path with mocked cst invocation"""
+        spl_data = bytearray(64)
+        spl_data[3] = nxp_imx93cst.CONTAINER_HDR_TAG
+        spl_data[12:14] = struct.pack('<H', 0x90)
+        spl_data[40:44] = struct.pack('<I', 0x123)
+        self._MakeInputFile('imx93-container.bin', bytes(spl_data))
+
+        # Mock run_cmd() so that when cst is invoked, it creates a fake
+        # output blob and returns success, thus covering the signing path
+        original = bintool.Bintool.run_cmd
+
+        def fake_cst_run_cmd(self_tool, *args, binary=False):
+            if self_tool.name == 'cst':
+                arg_list = list(args)
+                if '-o' in arg_list:
+                    idx = arg_list.index('-o')
+                    tools.write_file(arg_list[idx + 1], b'\x00' * 32)
+                return 'fake cst output'
+            return original(self_tool, *args, binary=binary)
+
+        with unittest.mock.patch.object(bintool.Bintool, 'run_cmd',
+                                        new=fake_cst_run_cmd):
+            data = self._DoReadFile('vendor/nxp_imx93_csf.dts')
+
+    def testNxpImx93ImageSizeNone(self):
+        """Test SetImagePos() early return when an entry has no size"""
+        # The imagename entry is in GetEntries() but not packed, so has
+        # size=None, which triggers the early-return guard in SetImagePos()
+        self._DoTestFile('vendor/nxp_imx93_csf_imagename.dts',
+                         force_missing_bintools='mkimage')
+
     def testNxpImx8MFSPI(self):
         """Test that binman can produce an iMX8m FSPI image"""
         self._DoTestFile('vendor/nxp_imx8m_fspi.dts')
tools/binman/test/vendor/nxp_imx93_csf.dts new file +18 -0
new file mode 100644
index 00000000000..bbe8eda4b70
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		nxp-imx93cst {
+			args;
+
+			blob {
+				filename = "imx93-container.bin";
+			};
+		};
+	};
+};
tools/binman/test/vendor/nxp_imx93_csf_imagename.dts new file +24 -0
new file mode 100644
index 00000000000..13009438ee8
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		nxp-imx93cst {
+			args;
+
+			u-boot {
+			};
+
+			imagename {
+				type = "section";
+
+				u-boot {
+				};
+			};
+		};
+	};
+};
Signature · 1 line
2.55.0
#11 lore raw

Re: [PATCH 5/5] binman: test: add code coverage for nxp_imx93cst etype

Hi Jérémie,

Quoted 16 lines · Jérémie Dautheribes

binman: test: add code coverage for nxp_imx93cst etype

Add test methods to cover all code paths of the nxp_imx93cst etype, reusing the pattern of the nxp_imx8mcst as done in commit 0cab35362d77 ("binman: test: Fix code coverage for iMX8 and cst bintool") by Simon Glass.

This brings nxp_imx93cst to 100% coverage.

tools/binman/ftest.py | 78 ++++++++++++++++++++++

 tools/binman/test/vendor/nxp_imx93_csf.dts         | 18 +++++
 .../binman/test/vendor/nxp_imx93_csf_imagename.dts | 24 +++++++
 3 files changed, 120 insertions(+)

tools/binman/ftest.py fdt fdtmap Extract the devicetree blob from the fdtmap · line 8175

Quoted 3 lines
tools/binman/ftest.py +3 -0
+    def testNxpImx93cstELE(self):
+        """Test CST signing with an i.MX93 SPL container including the ELE
+        FW"""

Please keep the docstring on a single line to match the imx8 tests just above. It fits within 80 columns as e.g. "Test CST signing where the SPL container starts with the ELE FW".

Quoted 14 lines
tools/binman/ftest.py +14 -0
+    def testNxpImx93cstSigned(self):
+        """Test CST-signing-success path with mocked cst invocation"""
+        spl_data = bytearray(64)
+        spl_data[3] = nxp_imx93cst.CONTAINER_HDR_TAG
+        spl_data[12:14] = struct.pack('<H', 0x90)
+        spl_data[40:44] = struct.pack('<I', 0x123)
+        self._MakeInputFile('imx93-container.bin', bytes(spl_data))
+
+        # Mock run_cmd() so that when cst is invoked, it creates a fake
+        # output blob and returns success, thus covering the signing path
+        original = bintool.Bintool.run_cmd
+
+        def fake_cst_run_cmd(self_tool, *args, binary=False):
+            if self_tool.name == 'cst':

tools/binman/ftest.py fdt fdtmap Extract the devicetree blob from the fdtmap · line 8224

Quoted 10 lines
tools/binman/ftest.py +10 -0
+                arg_list = list(args)
+                if '-o' in arg_list:
+                    idx = arg_list.index('-o')
+                    tools.write_file(arg_list[idx + 1], b'\x00' * 32)
+                return 'fake cst output'
+            return original(self_tool, *args, binary=binary)
+
+        with unittest.mock.patch.object(bintool.Bintool, 'run_cmd',
+                                        new=fake_cst_run_cmd):
+            data = self._DoReadFile('vendor/nxp_imx93_csf.dts')

data is never used - drop the assignment (as testNxpImx8mCSTSigned does), or add an assertion on the returned bytes so the signing path is actually validated rather than only executed. A quick assertEqual on the length (spl_data plus fake 32-byte blob) would give real coverage rather than only line coverage.

tools/binman/ftest.py fdt fdtmap Extract the devicetree blob from the fdtmap · line 8199

Quoted 8 lines
tools/binman/ftest.py +8 -0
+    def testNxpImx93cstUnknownTag(self):
+        """Test CST with unknown input tag passes data through"""
+        # Trigger the pass-through path using an input without the AHAB
+        # container tag
+        data = b'\x00' * 64
+        self._MakeInputFile('imx93-container.bin', data)
+        self._DoTestFile('vendor/nxp_imx93_csf.dts',
+                         force_missing_bintools='cst')

Since the pass-through branch returns early before cst is invoked, please assert the produced image equals the 64 zero bytes - that way the test actually proves the pass-through behaviour rather than only that no exception is raised.

Regards,
Simon

#12 lore raw
In reply to Jérémie Dautheribes (Schneider Electric) via U-Boot

Apologies, I had a typo in the CC list, adding Marek Vasut <[email protected]> here for visibility.

Quoted 44 lines · Jérémie Dautheribes (Schneider Electric)

Hello,

This series adds support for signing i.MX93 images by leveraging binman and CST, the NXP tool used for secure boot. This introduces a new binman entry type (etype) for this purpose.

The implementation is largely derived from the existing i.MX8M support, since the two share much of the same signing infrastructure.

This procedure has been tested on the imx93-evk board, using both ECDSA and RSA-PSS keys.

Patch 1: introduces the new etype
Patch 2: updates the imx93-u-boot.dtsi description to include the new signing nodes
Patches 3-4: documentation
Patch 5: adds test coverage

---
Jérémie Dautheribes (Schneider Electric) (5):
tools: binman: add nxp_imx93cst etype for i.MX93 flash.bin signing
imx93-u-boot: wrap SPL and U-Boot nodes in a CST node if AHAB_BOOT enabled
doc: imx: ahab: add AHAB introduction
doc: imx: ahab: add i.MX93 secure boot guide
binman: test: add code coverage for nxp_imx93cst etype

  .gitignore                                         |   2 +
  arch/arm/dts/imx93-u-boot.dtsi                     |  54 ++-
  doc/imx/ahab/guides/mx93_secure_boot.txt           | 269 +++++++++++++
  doc/imx/ahab/introduction_ahab.txt                 | 445 +++++++++++++++++++++
  tools/binman/etype/nxp_imx93cst.py                 | 143 +++++++
  tools/binman/ftest.py                              |  78 ++++
  tools/binman/test/vendor/nxp_imx93_csf.dts         |  18 +
  .../binman/test/vendor/nxp_imx93_csf_imagename.dts |  24 ++
  8 files changed, 1014 insertions(+), 19 deletions(-)

---
base-commit: d3e8597e46b635ec556a057bc42f0b0859654bdf
change-id: 20260814-imx93-secureboot-b914e7b6cbbf

Best regards,
--
Jérémie Dautheribes (Schneider Electric) <[email protected]>

Signature · 3 lines
Jérémie Dautheribes, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#13 lore raw
In reply to Jérémie Dautheribes (Schneider Electric) via U-Boot

Hi Jérémie,

Quoted 5 lines · Jérémie Dautheribes

Patch 1: introduces the new etype
Patch 2: updates the imx93-u-boot.dtsi description to include the new signing nodes
Patches 3-4: documentation
Patch 5: adds test coverage

[..]

Quoted 2 lines

The implementation is largely derived from the existing i.MX8M support, since the two share much of the same signing infrastructure.

Given how close this is to nxp_imx8mcst, please say in the cover letter whether you considered factoring out a common base class rather than duplicating the etype, and why you decided against it.

Regards,
Simon

#14 lore raw

Hi Simon,

First, thank you for your thorough review!

Quoted 10 lines · Simon Glass

Hi Jérémie,

Quoted 5 lines · Jérémie Dautheribes

Patch 1: introduces the new etype
Patch 2: updates the imx93-u-boot.dtsi description to include the new signing nodes
Patches 3-4: documentation
Patch 5: adds test coverage

Quoted 7 lines

[..]

Quoted 2 lines

The implementation is largely derived from the existing i.MX8M support, since the two share much of the same signing infrastructure.

Given how close this is to nxp_imx8mcst, please say in the cover letter whether you considered factoring out a common base class rather than duplicating the etype, and why you decided against it.

On second thought, I think it makes sense to factor out a common base class shared between the two etypes, so I'll do that for v2. Thanks!

Best regards,

Jérémie

Signature · 3 lines
Jérémie Dautheribes, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com