Hi Marek,
On 2026-07-15T13:37:04, Marek Vasut <[email protected]> wrote:
> binman: nxp_imx8mcst: Handle FCFB header during SPI NOR boot
>
> In case the image that is wrapped in the nxp_imx8mcst already contains
> an FCFB header which is mandatory for SPI NOR boot, then the IVT is at
> offset 0x1000 instead of offset 0x0, but the whole image including the
> FCFB header must be signed to prevent attacker from tampering with any
> of the headers. Add the FCFB handling.
>
> Signed-off-by: Marek Vasut <[email protected]>
>
> tools/binman/etype/nxp_imx8mcst.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
> diff --git a/tools/binman/etype/nxp_imx8mcst.py
> b/tools/binman/etype/nxp_imx8mcst.py
> @@ -114,6 +115,13 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
> + elif signtype == MAGIC_NXP_IMX_FCFB: # SPL/imx8mimage with FCFB
> + # Sign the payload including FCFB and imx8mimage headers
> + # (extra 0x1000 and 0x40 bytes before the payload)
> + signbase -= 0x1040
> + signsize = struct.unpack('<I', data[4120:4124])[0] - signbase
Please see below for test ideas.
Also, 4120 is quite obscure as a decimal literal. Since this branch is
the IVT one shifted by 0x1000, perhaps the two could be merged, e.g.:
if signtype in (MAGIC_NXP_IMX_IVT, MAGIC_NXP_IMX_FCFB):
off = 0x1000 if signtype == MAGIC_NXP_IMX_FCFB else 0
signbase -= off + 0x40
signsize = struct.unpack(
'<I', data[off + 24:off + 28])[0] - signbase
data = data[:signsize]
That makes it clear the value being read is the csf pointer at IVT
offset 24, same as the existing case. What do you think?
> diff --git a/tools/binman/etype/nxp_imx8mcst.py
> b/tools/binman/etype/nxp_imx8mcst.py
> @@ -114,6 +115,13 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
> + elif signtype == MAGIC_NXP_IMX_FCFB: # SPL/imx8mimage with FCFB
Please can you also update the block comment above this code ("Parse
the input data and figure out what it is that is being signed") to
mention the FCFB case?
Here is my attempt at a test (it doesn't actually check the output though):
def testNxpImx8mCSTFcfb(self):
"""Test CST signing with an FCFB header (SPI NOR boot)
When the payload is wrapped for SPI NOR boot it starts with an FCFB
header, so the imx8mimage IVT sits at offset 0x1000 and the size word it
carries is at offset 0x1018 (4120). Build a fake blob with the FCFB magic
and that size word so the FCFB branch is exercised.
"""
fcfb_data = struct.pack('<I', 0x42464346)
fcfb_data += b'\x00' * (4120 - 4)
fcfb_data += struct.pack('<I', 0)
self._MakeInputFile('imx8m-ivt.bin', fcfb_data)
with terminal.capture() as (_, stderr):
self._DoTestFile('vendor/nxp_imx8_csf.dts',
force_missing_bintools='cst')
err = stderr.getvalue()
self.assertRegex(err, "Image 'image'.*missing bintools.*: cst")
Regards,
Simon