From: "Jérémie Dautheribes (Schneider Electric)" <jeremie.dautheribes@bootlin.com>
To: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
u-boot@lists.u-boot-project.org
Cc: "Jérémie Dautheribes (Schneider Electric)"
<jeremie.dautheribes@bootlin.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tom Rini" <trini@konsulko.com>, "Simon Glass" <sjg@chromium.org>,
"Alper Nebi Yasak" <alpernebiyasak@gmail.com>,
"Stefano Babic" <sbabic@nabladev.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Marek Vasut" <marex@nabladev.com>,
"Denis Mukhin" <dmukhin@ford.com>,
"Rasmus Villemoes" <rv@rasmusvillemoes.dk>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Krzysztof Drobiński" <krzysztof@kd-solutions.pl>,
"Peng Fan" <peng.fan@nxp.com>, "Alice Guo" <alice.guo@nxp.com>,
"Simona Toaca" <simona.toaca@nxp.com>, "Ye Li" <ye.li@nxp.com>,
"Quentin Schulz" <quentin.schulz@cherry.de>,
"Christophe Guerreiro" <christophe.guerreiro@non.se.com>
Subject: [PATCH v2 2/7] binman: nxp_imx8mcst: use the nxp_imxcst base etype
Date: Wed, 02 Sep 2026 15:41:29 +0200 [thread overview]
Message-ID: <20260902-imx93-secureboot-v2-2-5947b92a5072@bootlin.com> (raw)
In-Reply-To: <20260902-imx93-secureboot-v2-0-5947b92a5072@bootlin.com>
Use the freshly introduced new nxp_imxcst base etype and remove
dupplicated code.
This should not have any functional impact.
Signed-off-by: Jérémie Dautheribes (Schneider Electric) <jeremie.dautheribes@bootlin.com>
---
tools/binman/etype/nxp_imx8mcst.py | 60 +++++++-------------------------------
1 file changed, 10 insertions(+), 50 deletions(-)
diff --git a/tools/binman/etype/nxp_imx8mcst.py b/tools/binman/etype/nxp_imx8mcst.py
index 29a7451678d..3f81b9f83c6 100644
--- a/tools/binman/etype/nxp_imx8mcst.py
+++ b/tools/binman/etype/nxp_imx8mcst.py
@@ -7,16 +7,10 @@
# input configuration file and input data to be signed.
#
-import configparser
import os
import struct
-from collections import OrderedDict
-
-from binman.entry import Entry
-from binman.etype.mkimage import Entry_mkimage
-from binman.etype.section import Entry_section
-from binman import elf
+from binman.etype.nxp_imxcst import Entry_nxp_imxcst
from dtoc import fdt_util
from u_boot_pylib import tools
@@ -61,7 +55,8 @@ CSF_CONFIG_TEMPLATE = f'''
Blocks = 0x1234 0x78 0xabcd "data.bin"
'''
-class Entry_nxp_imx8mcst(Entry_mkimage):
+
+class Entry_nxp_imx8mcst(Entry_nxp_imxcst):
"""NXP i.MX8M CST .cfg file generator and cst invoker
Properties / Entry arguments:
@@ -82,9 +77,6 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
def ReadNode(self):
super().ReadNode()
self.loader_address = fdt_util.GetInt(self._node, 'nxp,loader-address')
- self.srk_table = os.getenv(
- 'SRK_TABLE', fdt_util.GetString(self._node, 'nxp,srk-table',
- 'SRK_1_2_3_4_table.bin'))
self.fast_auth = fdt_util.GetBool(self._node, 'nxp,fast-auth')
if not self.fast_auth:
self.csf_crt = os.getenv(
@@ -158,17 +150,11 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
return data
# Write out customized data to be signed
- output_dname = tools.get_output_filename(f'nxp.cst-input-data.{uniq}')
- tools.write_file(output_dname, data)
+ output_dname = self.write_input_data(data, uniq)
# Generate CST configuration file used to sign payload
- cfg_fname = tools.get_output_filename(f'nxp.csf-config-txt.{uniq}')
- config = configparser.ConfigParser()
- # Do not make key names lowercase
- config.optionxform = str
- # Load configuration template and modify keys of interest
- config.read_string(CSF_CONFIG_TEMPLATE)
- config['Install SRK']['File'] = f'"{self.srk_table}"'
+ config = self.get_config(CSF_CONFIG_TEMPLATE)
+ config['Install SRK']['File'] = f'"{self.srk_table}"'
if not self.fast_auth:
config.remove_section('Install NOCAK')
config['Install CSFK']['File'] = f'"{self.csf_crt}"'
@@ -184,8 +170,7 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
if not self.unlock:
config.remove_section('Unlock')
- with open(cfg_fname, 'w') as cfgf:
- config.write(cfgf)
+ cfg_fname = self.write_config(config, uniq)
# SSL is the default backend, PKCS11 backend is optional
if self.backend == "pkcs11":
@@ -193,34 +178,9 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
else:
cst_backend = "ssl"
- output_fname = tools.get_output_filename(f'nxp.csf-output-blob.{uniq}')
- args = ['-i', cfg_fname, '-o', output_fname, '-b', cst_backend]
- if self.cst.run_cmd(*args) is not None:
- outdata = tools.read_file(output_fname)
+ outdata = self.run_cst(cfg_fname, uniq, cst_backend)
+ if outdata is not None:
# fixme: 0x2000 should be CONFIG_CSF_SIZE
outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
return data + outdata
- else:
- # Bintool is missing; just use the input data as the output
- self.record_missing_bintool(self.cst)
- return data
-
- def SetImagePos(self, image_pos):
- # Customized SoC specific SetImagePos which skips the mkimage etype
- # implementation and removes the 0x48 offset introduced there. That
- # offset is only used for uImage/fitImage, which is not the case in
- # here.
- upto = 0x00
- for entry in super().GetEntries().values():
- entry.SetOffsetSize(upto, None)
-
- # Give up if any entries lack a size
- if entry.size is None:
- return
- upto += entry.size
-
- Entry_section.SetImagePos(self, image_pos)
-
- def AddBintools(self, btools):
- super().AddBintools(btools)
- self.cst = self.AddBintool(btools, 'cst')
+ return data
--
2.55.0
next prev parent reply other threads:[~2026-09-02 13:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 13:41 [PATCH v2 0/7] binman: add nxp_imx93cst etype for i.MX93 flash.bin signing Jérémie Dautheribes (Schneider Electric)
2026-09-02 13:41 ` [PATCH v2 1/7] binman: add nxp_imxcst base etype for i.MX CST signing Jérémie Dautheribes (Schneider Electric)
2026-09-02 13:41 ` Jérémie Dautheribes (Schneider Electric) [this message]
2026-09-02 13:41 ` [PATCH v2 3/7] tools: binman: add nxp_imx93cst etype for i.MX93 flash.bin signing Jérémie Dautheribes (Schneider Electric)
2026-09-02 13:41 ` [PATCH v2 4/7] imx93-u-boot: wrap SPL and U-Boot nodes in a CST node if AHAB_BOOT enabled Jérémie Dautheribes (Schneider Electric)
2026-09-02 13:41 ` [PATCH v2 5/7] doc: imx: ahab: add AHAB introduction Jérémie Dautheribes (Schneider Electric)
2026-09-02 13:41 ` [PATCH v2 6/7] doc: imx: ahab: add i.MX93 secure boot guide Jérémie Dautheribes (Schneider Electric)
2026-09-02 13:41 ` [PATCH v2 7/7] binman: test: add code coverage for nxp_imx93cst etype Jérémie Dautheribes (Schneider Electric)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902-imx93-secureboot-v2-2-5947b92a5072@bootlin.com \
--to=jeremie.dautheribes@bootlin.com \
--cc=alice.guo@nxp.com \
--cc=alpernebiyasak@gmail.com \
--cc=christophe.guerreiro@non.se.com \
--cc=dmukhin@ford.com \
--cc=festevam@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=krzysztof@kd-solutions.pl \
--cc=marex@nabladev.com \
--cc=miquel.raynal@bootlin.com \
--cc=peng.fan@nxp.com \
--cc=quentin.schulz@cherry.de \
--cc=rv@rasmusvillemoes.dk \
--cc=sbabic@nabladev.com \
--cc=simona.toaca@nxp.com \
--cc=sjg@chromium.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=uboot-imx@nxp.com \
--cc=ye.li@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.