From 05b978be5f5c5494044bd749f9b6b38f2bb5e0cc Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 25 Feb 2023 19:01:33 +0000 Subject: binman: Add support for a rockchip-tpl entry The rockchip-tpl entry can be used when an external TPL binary should be used instead of the normal U-Boot TPL. Signed-off-by: Jonas Karlman Reviewed-by: Simon Glass Reviewed-by: Kever Yang Tested-by: Eugen Hristev --- tools/binman/entries.rst | 14 ++++++++++++++ tools/binman/etype/rockchip_tpl.py | 20 ++++++++++++++++++++ tools/binman/ftest.py | 7 +++++++ tools/binman/missing-blob-help | 5 +++++ tools/binman/test/277_rockchip_tpl.dts | 16 ++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 tools/binman/etype/rockchip_tpl.py create mode 100644 tools/binman/test/277_rockchip_tpl.dts (limited to 'tools') diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 7a04a61..e177860 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -1386,6 +1386,20 @@ For example, this creates an image with a pre-load header and a binary:: +.. _etype_rockchip_tpl: + +Entry: rockchip-tpl: Rockchip TPL binary +---------------------------------------- + +Properties / Entry arguments: + - rockchip-tpl-path: Filename of file to read into the entry, + typically _ddr_.bin + +This entry holds an external TPL binary used by some Rockchip SoCs +instead of normal U-Boot TPL, typically to initialize DRAM. + + + .. _etype_scp: Entry: scp: System Control Processor (SCP) firmware blob diff --git a/tools/binman/etype/rockchip_tpl.py b/tools/binman/etype/rockchip_tpl.py new file mode 100644 index 0000000..74f58ba --- /dev/null +++ b/tools/binman/etype/rockchip_tpl.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for Rockchip TPL binary +# + +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg + +class Entry_rockchip_tpl(Entry_blob_named_by_arg): + """Rockchip TPL binary + + Properties / Entry arguments: + - rockchip-tpl-path: Filename of file to read into the entry, + typically _ddr_.bin + + This entry holds an external TPL binary used by some Rockchip SoCs + instead of normal U-Boot TPL, typically to initialize DRAM. + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node, 'rockchip-tpl') + self.external = True diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 062f54a..48ac154 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -90,6 +90,7 @@ TEE_OS_DATA = b'this is some tee OS data' ATF_BL2U_DATA = b'bl2u' OPENSBI_DATA = b'opensbi' SCP_DATA = b'scp' +ROCKCHIP_TPL_DATA = b'rockchip-tpl' TEST_FDT1_DATA = b'fdt1' TEST_FDT2_DATA = b'test-fdt2' ENV_DATA = b'var1=1\nvar2="2"' @@ -205,6 +206,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('bl2u.bin', ATF_BL2U_DATA) TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA) TestFunctional._MakeInputFile('scp.bin', SCP_DATA) + TestFunctional._MakeInputFile('rockchip-tpl.bin', ROCKCHIP_TPL_DATA) # Add a few .dtb files for testing TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR, @@ -6386,6 +6388,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(['u-boot', 'atf-2'], fdt_util.GetStringList(node, 'loadables')) + def testPackRockchipTpl(self): + """Test that an image with a Rockchip TPL binary can be created""" + data = self._DoReadFile('277_rockchip_tpl.dts') + self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)]) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help index 4448ac9..f3a44d0 100644 --- a/tools/binman/missing-blob-help +++ b/tools/binman/missing-blob-help @@ -34,6 +34,11 @@ If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for the R5F core(s) to trigger the system reset. One possible source is https://github.com/siemens/k3-rti-wdt. +rockchip-tpl: +An external TPL is required to initialize DRAM. Get the external TPL +binary and build with ROCKCHIP_TPL=/path/to/ddr.bin. One possible source +for the external TPL binary is https://github.com/rockchip-linux/rkbin. + tee-os: See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.bin diff --git a/tools/binman/test/277_rockchip_tpl.dts b/tools/binman/test/277_rockchip_tpl.dts new file mode 100644 index 0000000..269f56e --- /dev/null +++ b/tools/binman/test/277_rockchip_tpl.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + rockchip-tpl { + filename = "rockchip-tpl.bin"; + }; + }; +}; -- cgit v1.1 From ed8d09830048221d1e20b8c2ffcc1ce707d84606 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 25 Feb 2023 19:01:34 +0000 Subject: rockchip: mkimage: Update init size limit for RK3328 Latest vendor TPL for RK3328 has grown past the current init size limit of 28KiB, sync the init size limit from vendor u-boot to fix this. Set init size limit to 30KiB (+2KiB) for RK3328. This makes it possible to use latest vendor TPL on RK3328 without getting a size limit error running the mkimage command. Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 1f1eaa1..70bc66f 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -129,7 +129,7 @@ static struct spl_info spl_infos[] = { { "rk322x", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 }, { "rk3288", "RK32", 0x8000, false, RK_HEADER_V1 }, { "rk3308", "RK33", 0x40000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3328", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 }, + { "rk3328", "RK32", 0x8000 - 0x800, false, RK_HEADER_V1 }, { "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1 }, { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 }, { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 }, -- cgit v1.1 From 5fc5a840d4cf189616aba3a4a7bf10c4ac8edc83 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 25 Feb 2023 19:01:34 +0000 Subject: rockchip: mkimage: Update init size limit for RK3568 The current init size limit of 76KiB is too big to fit in the 64KiB SRAM on RK3568, sync init size limit from vendor u-boot to fix this. Set init size limit to 60KiB (-16KiB) for RK3568. Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 70bc66f..0d29110 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -134,7 +134,7 @@ static struct spl_info spl_infos[] = { { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 }, { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 }, { "rv1126", "110B", 0x10000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3568", "RK35", 0x14000 - 0x1000, false, RK_HEADER_V2 }, + { "rk3568", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 }, }; /** -- cgit v1.1 From 40389c2a462256da7f2348bed791c8ba2ae6eec6 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 25 Feb 2023 19:01:35 +0000 Subject: binman: Mark mkimage entry missing when its subnodes is missing Using the mkimage entry with the multiple-data-files prop and having a missing external blob result in an unexpected ValueError exception using the --allow-missing flag. ValueError: Filename 'missing.bin' not found in input path (...) Fix this by using _pathname that is resolved by ObtainContents for blob entries, ObtainContents also handles allow missing for external blobs. Mark mkimage entry as missing and return without running mkimage when missing entries is reported by CheckMissing. Signed-off-by: Jonas Karlman Reviewed-by: Simon Glass Reviewed-by: Kever Yang --- tools/binman/etype/mkimage.py | 24 +++++++++++++++++++++- tools/binman/ftest.py | 11 ++++++++++ tools/binman/test/278_mkimage_missing_multiple.dts | 19 +++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts (limited to 'tools') diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index cb264c3c..8a13d5e 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -156,7 +156,8 @@ class Entry_mkimage(Entry): for entry in self._mkimage_entries.values(): if not entry.ObtainContents(fake_size=fake_size): return False - fnames.append(tools.get_input_filename(entry.GetDefaultFilename())) + if entry._pathname: + fnames.append(entry._pathname) input_fname = ":".join(fnames) else: data, input_fname, uniq = self.collect_contents_to_file( @@ -171,6 +172,13 @@ class Entry_mkimage(Entry): outfile = self._filename if self._filename else 'mkimage-out.%s' % uniq output_fname = tools.get_output_filename(outfile) + missing_list = [] + self.CheckMissing(missing_list) + self.missing = bool(missing_list) + if self.missing: + self.SetContents(b'') + return self.allow_missing + args = ['-d', input_fname] if self._data_to_imagename: args += ['-n', input_fname] @@ -216,6 +224,20 @@ class Entry_mkimage(Entry): if self._imagename: self._imagename.SetAllowFakeBlob(allow_fake) + def CheckMissing(self, missing_list): + """Check if any entries in this section have missing external blobs + + If there are missing (non-optional) blobs, the entries are added to the + list + + Args: + missing_list: List of Entry objects to be added to + """ + for entry in self._mkimage_entries.values(): + entry.CheckMissing(missing_list) + if self._imagename: + self._imagename.CheckMissing(missing_list) + def CheckFakedBlobs(self, faked_blobs_list): """Check if any entries in this section have faked external blobs diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 48ac154..d74aa90 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6393,6 +6393,17 @@ fdt fdtmap Extract the devicetree blob from the fdtmap data = self._DoReadFile('277_rockchip_tpl.dts') self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)]) + def testMkimageMissingBlobMultiple(self): + """Test missing blob with mkimage entry and multiple-data-files""" + with test_util.capture_sys_output() as (stdout, stderr): + self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=True) + err = stderr.getvalue() + self.assertIn("is missing external blobs and is non-functional", err) + + with self.assertRaises(ValueError) as e: + self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=False) + self.assertIn("not found in input path", str(e.exception)) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/278_mkimage_missing_multiple.dts b/tools/binman/test/278_mkimage_missing_multiple.dts new file mode 100644 index 0000000..f84aea4 --- /dev/null +++ b/tools/binman/test/278_mkimage_missing_multiple.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + mkimage { + args = "-n test -T script"; + multiple-data-files; + + blob-ext { + filename = "missing.bin"; + }; + }; + }; +}; -- cgit v1.1 From 826d0484f048e85da83b9be6bd6f54fc58feb575 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Mon, 30 Jan 2023 20:27:32 +0530 Subject: rockchip: mkimage: Add rk3588 support Add support for rk3588 package header in mkimage tool. Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- tools/rkcommon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 0d29110..96efc11 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -135,6 +135,7 @@ static struct spl_info spl_infos[] = { { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 }, { "rv1126", "110B", 0x10000 - 0x1000, false, RK_HEADER_V1 }, { "rk3568", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 }, + { "rk3588", "RK35", 0x100000 - 0x1000, false, RK_HEADER_V2 }, }; /** -- cgit v1.1 From abe2a16aa52ea21acb435e9f1d9c85f5ac4e7794 Mon Sep 17 00:00:00 2001 From: Ralph Siemsen Date: Wed, 22 Feb 2023 15:56:59 -0500 Subject: tools: binman: minor formatting fix in docs This should fix a rendering oddity when viewing the docs online at https://u-boot.readthedocs.io/en/latest/develop/package/binman.html Signed-off-by: Ralph Siemsen Reviewed-by: Simon Glass --- tools/binman/binman.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 03a99a1..0921e31 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -393,9 +393,9 @@ system-library directory, replace the last line with: Running binman -------------- -Type:: +Type: -.. code-block: bash +.. code-block:: bash make NO_PYTHON=1 PREFIX=/ install binman build -b -- cgit v1.1