Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8490CC433EF for ; Wed, 6 Apr 2022 12:30:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E217383D0B; Wed, 6 Apr 2022 14:30:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="oiin3f30"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE15583DC7; Wed, 6 Apr 2022 14:30:00 +0200 (CEST) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 57D0683DB8 for ; Wed, 6 Apr 2022 14:29:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=n-francis@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 236CTbZs111257; Wed, 6 Apr 2022 07:29:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1649248177; bh=B4EHP8fezvNdRzMptyuyl2FwjdK6KuC9RRzOwgmd4+k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oiin3f30W3LVOyJKanUYHRyeSW5k1K2OpeOMvO5QebmOTh6asLS0d0Ok9lxCly2J8 /Q06EcesnLIFFxrVZDg9MIHZ84u47rj1vTDpXeD4Jkyj/TzX4pOfeGshH90v9UZnt2 ZHQE2aM9Qs4PEF1iJ02Ulhz3O+mmQz4181U5CHD4= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 236CTbD1030974 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Apr 2022 07:29:37 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 6 Apr 2022 07:29:37 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Wed, 6 Apr 2022 07:29:37 -0500 Received: from ula0497641.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 236CTJcj104086; Wed, 6 Apr 2022 07:29:32 -0500 From: Neha Malcom Francis To: CC: , , , , , , , , , , , Subject: [RESEND, RFC 2/8] binman: etype: sysfw: Add entry type for sysfw Date: Wed, 6 Apr 2022 17:59:13 +0530 Message-ID: <20220406122919.6104-3-n-francis@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220406122919.6104-1-n-francis@ti.com> References: <20220406122919.6104-1-n-francis@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean For K3 devices that require a sysfw image, add entry for SYSFW. It can contain system firmware image that can be packaged into sysfw.itb by binman. The method ReadBlobContents in sysfw.py runs the TI K3 certificate generation script to create the signed sysfw image that can be used for packaging by binman into sysfw.bin. Signed-off-by: Tarun Sahu [n-francis@ti.com: added tests for addition of etype] Signed-off-by: Neha Malcom Francis --- tools/binman/entries.rst | 11 ++++++ tools/binman/etype/sysfw.py | 60 +++++++++++++++++++++++++++++++++ tools/binman/ftest.py | 7 ++++ tools/binman/test/226_sysfw.dts | 13 +++++++ 4 files changed, 91 insertions(+) create mode 100644 tools/binman/etype/sysfw.py create mode 100644 tools/binman/test/226_sysfw.dts diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 484cde5c80..7c95bbfbec 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -1019,6 +1019,17 @@ This entry holds firmware for an external platform-specific coprocessor. +Entry: sysfw: Texas Instruments System Firmware (SYSFW) blob +------------------------------------------------------------ + +Properties / Entry arguments: + - sysfw-path: Filename of file to read into the entry, typically sysfw.bin + +This entry contains system firmware necessary for booting of K3 architecture +devices. + + + Entry: section: Entry that contains other entries ------------------------------------------------- diff --git a/tools/binman/etype/sysfw.py b/tools/binman/etype/sysfw.py new file mode 100644 index 0000000000..c73300400b --- /dev/null +++ b/tools/binman/etype/sysfw.py @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ +# +# Entry type module for TI SYSFW binary blob +# + +import struct +import zlib +import os +import sys + +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg +from dtoc import fdt_util +from patman import tools + + +class Entry_sysfw(Entry_blob_named_by_arg): + """Entry containing System Firmware (SYSFW) blob + + Properties / Entry arguments: + - sysfw-path: Filename of file to read into the entry, typically sysfw.bin + +This entry contains system firmware necessary for booting of K3 architecture devices. + """ + + def __init__(self, section, etype, node): + super().__init__(section, etype, node, 'scp') + self.core = "0" + self.missing_msg = "sysfw" + + def ReadNode(self): + self._load_addr = fdt_util.GetInt(self._node, 'load', 0) + self._args = [] + + def _SignSysfw(self, out): + """Sign the sysfw image and write it to the output directory""" + # Try running the K3 x509 certificate signing script + try: + args = [ + '-c', "0", + '-b', self._filename, + '-l', str(self._load_addr), + '-o', out + ] + k3_cert_gen_path = os.environ['srctree'] + \ + "/tools/k3_gen_x509_cert.sh" + tools.run(k3_cert_gen_path, *args) + self.SetContents(tools.read_file(out)) + return True + # If not available (example, in the case of binman tests, set entry contents as dummy binary) + except KeyError: + self.missing = True + self.SetContents(b'sysfw') + return True + + def ObtainContents(self): + self.missing = False + out = tools.get_output_filename("sysfwint") + self._SignSysfw(out) + return True diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 8f00db6945..7c12058fe4 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -87,6 +87,7 @@ ATF_BL31_DATA = b'bl31' TEE_OS_DATA = b'this is some tee OS data' ATF_BL2U_DATA = b'bl2u' OPENSBI_DATA = b'opensbi' +SYSFW_DATA = b'sysfw' SCP_DATA = b'scp' TEST_FDT1_DATA = b'fdt1' TEST_FDT2_DATA = b'test-fdt2' @@ -192,6 +193,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('tee-pager.bin', TEE_OS_DATA) TestFunctional._MakeInputFile('bl2u.bin', ATF_BL2U_DATA) TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA) + TestFunctional._MakeInputFile('sysfw.bin', SYSFW_DATA) TestFunctional._MakeInputFile('scp.bin', SCP_DATA) # Add a few .dtb files for testing @@ -5321,6 +5323,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertIn("Node '/binman/fit': Unknown operation 'unknown'", str(exc.exception)) + def testPackSysfw(self): + """Test that an image with a SYSFW binary can be created""" + data = self._DoReadFile('226_sysfw.dts') + self.assertEqual(SYSFW_DATA, data[:len(SYSFW_DATA)]) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/226_sysfw.dts b/tools/binman/test/226_sysfw.dts new file mode 100644 index 0000000000..23d64d3688 --- /dev/null +++ b/tools/binman/test/226_sysfw.dts @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + binman { + sysfw { + filename = "sysfw.bin"; + }; + }; +}; -- 2.17.1