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) <[email protected]> --- 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
