diff options
Diffstat (limited to 'tools/binman')
40 files changed, 762 insertions, 157 deletions
diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 84b1331df5c..392e507d449 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -1143,6 +1143,13 @@ Optional entries Some entries need to exist only if certain conditions are met. For example, an entry may want to appear in the image only if a file has a particular format. +Also, the ``optional`` property may be used to mark entries as optional:: + + tee-os { + filename = "tee.bin"; + optional; + }; + Obviously the entry must exist in the image description for it to be processed at all, so a way needs to be found to have the entry remove itself. diff --git a/tools/binman/bintool_test.py b/tools/binman/bintool_test.py index 949d6f4c8a9..7e8dafea94e 100644 --- a/tools/binman/bintool_test.py +++ b/tools/binman/bintool_test.py @@ -55,14 +55,14 @@ class TestBintool(unittest.TestCase): def test_version(self): """Check handling of a tool being present or absent""" btest = Bintool.create('_testing') - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): btest.show() self.assertFalse(btest.is_present()) self.assertIn('-', stdout.getvalue()) btest.present = True self.assertTrue(btest.is_present()) self.assertEqual('123', btest.version()) - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): btest.show() self.assertIn('123', stdout.getvalue()) @@ -90,7 +90,7 @@ class TestBintool(unittest.TestCase): col = terminal.Color() with unittest.mock.patch.object(tools, 'download', side_effect=fake_download): - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): btest.fetch_tool(method, col, False) return stdout.getvalue() @@ -144,7 +144,7 @@ class TestBintool(unittest.TestCase): with unittest.mock.patch.object(bintool.Bintool, 'tooldir', destdir): with unittest.mock.patch.object(tools, 'download', side_effect=handle_download): - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): Bintool.fetch_tools(bintool.FETCH_ANY, ['_testing'] * 2) self.assertTrue(os.path.exists(dest_fname)) data = tools.read_file(dest_fname) @@ -177,7 +177,7 @@ class TestBintool(unittest.TestCase): self.count = collections.defaultdict(int) with unittest.mock.patch.object(bintool.Bintool, 'fetch_tool', side_effect=fake_fetch): - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): Bintool.fetch_tools(method, ['all']) lines = stdout.getvalue().splitlines() self.assertIn(f'{self.count[bintool.FETCHED]}: ', lines[-2]) @@ -220,7 +220,7 @@ class TestBintool(unittest.TestCase): side_effect=[all_tools]): with unittest.mock.patch.object(bintool.Bintool, 'create', side_effect=self.btools.values()): - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): Bintool.fetch_tools(bintool.FETCH_ANY, ['missing']) lines = stdout.getvalue().splitlines() num_tools = len(self.btools) @@ -255,7 +255,7 @@ class TestBintool(unittest.TestCase): with unittest.mock.patch.object(bintool.Bintool, 'tooldir', self._indir): with unittest.mock.patch.object(tools, 'run', side_effect=fake_run): - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): btest.fetch_tool(bintool.FETCH_BUILD, col, False) fname = os.path.join(self._indir, '_testing') return fname if write_file else self.fname, stdout.getvalue() @@ -278,7 +278,7 @@ class TestBintool(unittest.TestCase): btest.install = True col = terminal.Color() with unittest.mock.patch.object(tools, 'run', return_value=None): - with test_util.capture_sys_output() as _: + with terminal.capture() as _: result = btest.fetch_tool(bintool.FETCH_BIN, col, False) self.assertEqual(bintool.FETCHED, result) @@ -287,7 +287,7 @@ class TestBintool(unittest.TestCase): btest = Bintool.create('_testing') btest.disable = True col = terminal.Color() - with test_util.capture_sys_output() as _: + with terminal.capture() as _: result = btest.fetch_tool(bintool.FETCH_BIN, col, False) self.assertEqual(bintool.FAIL, result) @@ -314,7 +314,7 @@ class TestBintool(unittest.TestCase): with unittest.mock.patch.object(tools, 'run', side_effect=fake_run): with unittest.mock.patch.object(tools, 'download', side_effect=handle_download): - with test_util.capture_sys_output() as _: + with terminal.capture() as _: for name in Bintool.get_tool_list(): btool = Bintool.create(name) for method in range(bintool.FETCH_COUNT): diff --git a/tools/binman/btool/openssl.py b/tools/binman/btool/openssl.py index c6df64c5316..b26f087c447 100644 --- a/tools/binman/btool/openssl.py +++ b/tools/binman/btool/openssl.py @@ -153,7 +153,7 @@ numFirewallRegions = INTEGER:{firewall_cert_data['num_firewalls']} def x509_cert_rom(self, cert_fname, input_fname, key_fname, sw_rev, config_fname, req_dist_name_dict, cert_type, bootcore, - bootcore_opts, load_addr, sha): + bootcore_opts, load_addr, sha, debug): """Create a certificate Args: @@ -221,9 +221,13 @@ emailAddress = {req_dist_name_dict['emailAddress']} # iterationCnt = INTEGER:TEST_IMAGE_KEY_DERIVE_INDEX # salt = FORMAT:HEX,OCT:TEST_IMAGE_KEY_DERIVE_SALT + # When debugging low level boot firmware it can be useful to have ROM or TIFS + # unlock JTAG access to the misbehaving CPUs. However in a production setting + # this can lead to code modification by outside parties after it's been + # authenticated. To gain JTAG access add the 'debug' flag to the binman config [ debug ] debugUID = FORMAT:HEX,OCT:0000000000000000000000000000000000000000000000000000000000000000 - debugType = INTEGER:4 + debugType = INTEGER:{ "4" if debug else "0" } coreDbgEn = INTEGER:0 coreDbgSecEn = INTEGER:0 ''', file=outf) @@ -238,7 +242,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} imagesize_sbl, hashval_sbl, load_addr_sysfw, imagesize_sysfw, hashval_sysfw, load_addr_sysfw_data, imagesize_sysfw_data, hashval_sysfw_data, sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block, bootcore_opts): + dm_data_ext_boot_block, bootcore_opts, debug): """Create a certificate Args: @@ -324,9 +328,13 @@ compSize = INTEGER:{imagesize_sysfw_data} shaType = OID:{sha_type} shaValue = FORMAT:HEX,OCT:{hashval_sysfw_data} +# When debugging low level boot firmware it can be useful to have ROM or TIFS +# unlock JTAG access to the misbehaving CPUs. However in a production setting +# this can lead to code modification by outside parties after it's been +# authenticated. To gain JTAG access add the 'debug' flag to the binman config [ debug ] debugUID = FORMAT:HEX,OCT:0000000000000000000000000000000000000000000000000000000000000000 -debugType = INTEGER:4 +debugType = INTEGER:{ "4" if debug else "0" } coreDbgEn = INTEGER:0 coreDbgSecEn = INTEGER:0 diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py index 4c415b7ce94..2494a6b9405 100755 --- a/tools/binman/cbfs_util_test.py +++ b/tools/binman/cbfs_util_test.py @@ -20,6 +20,7 @@ from binman import bintool from binman import cbfs_util from binman.cbfs_util import CbfsWriter from binman import elf +from u_boot_pylib import terminal from u_boot_pylib import test_util from u_boot_pylib import tools @@ -314,7 +315,7 @@ class TestCbfs(unittest.TestCase): newdata = data[:-4] + struct.pack('<I', cbw._header_offset + 1) # We should still be able to find the master header by searching - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): cbfs = cbfs_util.CbfsReader(newdata) self.assertIn('Relative offset seems wrong', stdout.getvalue()) self.assertIn('u-boot', cbfs.files) @@ -330,7 +331,7 @@ class TestCbfs(unittest.TestCase): # Drop most of the header and try reading the modified CBFS newdata = data[:cbw._header_offset + 4] - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): with self.assertRaises(ValueError) as e: cbfs_util.CbfsReader(newdata) self.assertIn('Relative offset seems wrong', stdout.getvalue()) @@ -351,7 +352,7 @@ class TestCbfs(unittest.TestCase): # Remove all but 4 bytes of the file headerm and try to read the file newdata = data[:pos + 4] - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): with io.BytesIO(newdata) as fd: fd.seek(pos) self.assertEqual(False, cbr._read_next_file(fd)) @@ -373,7 +374,7 @@ class TestCbfs(unittest.TestCase): # Create a new CBFS with only the first 16 bytes of the file name, then # try to read the file newdata = data[:pos + cbfs_util.FILE_HEADER_LEN + 16] - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): with io.BytesIO(newdata) as fd: fd.seek(pos) self.assertEqual(False, cbr._read_next_file(fd)) @@ -389,7 +390,7 @@ class TestCbfs(unittest.TestCase): try: cbfs_util.DEBUG = True - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): cbfs_util.CbfsReader(data) self.assertEqual('name u-boot\nftype 50\ndata %s\n' % U_BOOT_DATA, stdout.getvalue()) @@ -416,7 +417,7 @@ class TestCbfs(unittest.TestCase): # Create a new CBFS with the tag changed to something invalid newdata = data[:pos] + struct.pack('>I', 0x123) + data[pos + 4:] - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): cbfs_util.CbfsReader(newdata) self.assertEqual('Unknown attribute tag 123\n', stdout.getvalue()) @@ -441,7 +442,7 @@ class TestCbfs(unittest.TestCase): tag_pos = (4 + pos + cbfs_util.FILE_HEADER_LEN + cbfs_util.ATTRIBUTE_ALIGN) newdata = data[:tag_pos + 4] - with test_util.capture_sys_output() as (stdout, _stderr): + with terminal.capture() as (stdout, _stderr): with io.BytesIO(newdata) as fd: fd.seek(pos) self.assertEqual(False, cbr._read_next_file(fd)) diff --git a/tools/binman/control.py b/tools/binman/control.py index 81f61e3e152..1307222591d 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -8,12 +8,11 @@ from collections import OrderedDict import glob try: - import importlib.resources + import importlib.resources as importlib_resources except ImportError: # pragma: no cover # for Python 3.6 import importlib_resources import os -import pkg_resources import re import sys @@ -96,8 +95,8 @@ def _ReadMissingBlobHelp(): msg = '' return tag, msg - my_data = pkg_resources.resource_string(__name__, 'missing-blob-help') - re_tag = re.compile('^([-a-z0-9]+):$') + my_data = importlib_resources.files(__package__).joinpath('missing-blob-help').read_bytes() + re_tag = re.compile(r"^([-\.a-z0-9]+):$") result = {} tag = None msg = '' @@ -151,8 +150,9 @@ def GetEntryModules(include_testing=True): Returns: Set of paths to entry class filenames """ - glob_list = pkg_resources.resource_listdir(__name__, 'etype') - glob_list = [fname for fname in glob_list if fname.endswith('.py')] + entries = importlib_resources.files(__package__).joinpath('etype') + glob_list = [entry.name for entry in entries.iterdir() + if entry.name.endswith('.py') and entry.is_file()] return set([os.path.splitext(os.path.basename(item))[0] for item in glob_list if include_testing or '_testing' not in item]) @@ -530,6 +530,57 @@ def _RemoveTemplates(parent): for node in del_nodes: node.Delete() +def propagate_prop(node, prop): + """Propagate the provided property to all the parent nodes up the hierarchy + + Args: + node (fdt.Node): Node and all its parent nodes up to the root to + propagate the property. + prop (str): Boolean property to propagate + + Return: + True if any change was made, else False + """ + changed = False + while node: + if prop not in node.props: + node.AddEmptyProp(prop, 0) + changed = True + node = node.parent + return changed + +def scan_and_prop_bootph(node): + """Propagate bootph properties from children to parents + + The bootph schema indicates that bootph properties in children should be + implied in their parents, all the way up the hierarchy. This is expensive + to implement in U-Boot before relocation at runtime, so this function + explicitly propagates these bootph properties upwards during build time. + + This is used to set the bootph-all, bootph-some-ram property in the parent + node if the respective property is found in any of the parent's subnodes. + The other bootph-* properties are associated with the SPL stage and hence + handled by fdtgrep.c. + + Args: + node (fdt.Node): Node to scan for bootph-all and bootph-some-ram + property + + Return: + True if any change was made, else False + + """ + bootph_prop = {'bootph-all', 'bootph-some-ram'} + + changed = False + for prop in bootph_prop: + if prop in node.props: + changed |= propagate_prop(node.parent, prop) + + for subnode in node.subnodes: + changed |= scan_and_prop_bootph(subnode) + return changed + def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, indir): """Prepare the images to be processed and select the device tree @@ -589,6 +640,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind fname = tools.get_output_filename('u-boot.dtb.tmpl2') tools.write_file(fname, dtb.GetContents()) + if scan_and_prop_bootph(dtb.GetRoot()): + dtb.Sync(True) + images = _ReadImageDesc(node, use_expanded) if select_images: @@ -645,14 +699,27 @@ def CheckForProblems(image): _ShowHelpForMissingBlobs(tout.ERROR, missing_list) faked_list = [] + faked_optional_list = [] + faked_required_list = [] image.CheckFakedBlobs(faked_list) - if faked_list: + for e in faked_list: + if e.optional: + faked_optional_list.append(e) + else: + faked_required_list.append(e) + if faked_required_list: tout.warning( "Image '%s' has faked external blobs and is non-functional: %s\n" % (image.name, ' '.join([os.path.basename(e.GetDefaultFilename()) - for e in faked_list]))) + for e in faked_required_list]))) optional_list = [] + # For optional blobs, we should inform the user when the blob is not present. This will come as + # a warning since it may not be immediately apparent that something is missing otherwise. + # E.g. user thinks they supplied a blob, but there is no info of the contrary if they made an + # error. + # Faked optional blobs are not relevant for final images (as they are dropped anyway) so we + # will omit the message with default verbosity. image.CheckOptional(optional_list) if optional_list: tout.warning( @@ -660,6 +727,12 @@ def CheckForProblems(image): (image.name, ' '.join([e.name for e in optional_list]))) _ShowHelpForMissingBlobs(tout.WARNING, optional_list) + if faked_optional_list: + tout.info( + "Image '%s' has faked optional external blobs but is still functional: %s\n" % + (image.name, ' '.join([os.path.basename(e.GetDefaultFilename()) + for e in faked_optional_list]))) + missing_bintool_list = [] image.check_missing_bintools(missing_bintool_list) if missing_bintool_list: @@ -667,7 +740,7 @@ def CheckForProblems(image): "Image '%s' has missing bintools and is non-functional: %s\n" % (image.name, ' '.join([os.path.basename(bintool.name) for bintool in missing_bintool_list]))) - return any([missing_list, faked_list, missing_bintool_list]) + return any([missing_list, faked_required_list, missing_bintool_list]) def ProcessImage(image, update_fdt, write_map, get_contents=True, allow_resize=True, allow_missing=False, @@ -697,7 +770,6 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, image.SetAllowMissing(allow_missing) image.SetAllowFakeBlob(allow_fake_blobs) image.GetEntryContents() - image.drop_absent() image.GetEntryOffsets() # We need to pack the entries to figure out where everything @@ -736,12 +808,12 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, image.Raise('Entries changed size after packing (tried %s passes)' % passes) + has_problems = CheckForProblems(image) + image.BuildImage() if write_map: image.WriteMap() - has_problems = CheckForProblems(image) - image.WriteAlternates() return has_problems @@ -759,7 +831,7 @@ def Binman(args): global state if args.full_help: - with importlib.resources.path('binman', 'README.rst') as readme: + with importlib_resources.path('binman', 'README.rst') as readme: tools.print_full_help(str(readme)) return 0 @@ -777,7 +849,7 @@ def Binman(args): if args.cmd in ['ls', 'extract', 'replace', 'tool', 'sign']: try: - tout.init(args.verbosity) + tout.init(args.verbosity + 1) if args.cmd == 'replace': tools.prepare_output_dir(args.outdir, args.preserve) else: @@ -835,9 +907,9 @@ def Binman(args): args.indir.append(board_pathname) try: - tout.init(args.verbosity) + tout.init(args.verbosity + 1) elf.debug = args.debug - cbfs_util.VERBOSE = args.verbosity > 2 + cbfs_util.VERBOSE = args.verbosity > tout.NOTICE state.use_fake_dtb = args.fake_dtb # Normally we replace the 'u-boot' etype with 'u-boot-expanded', etc. diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index 2f22639dffc..5b173392898 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -13,6 +13,7 @@ import unittest from binman import elf from u_boot_pylib import command +from u_boot_pylib import terminal from u_boot_pylib import test_util from u_boot_pylib import tools from u_boot_pylib import tout @@ -187,7 +188,7 @@ class TestElf(unittest.TestCase): entry = FakeEntry(24) section = FakeSection() elf_fname = self.ElfTestFile('u_boot_binman_syms') - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): elf.LookupAndWriteSymbols(elf_fname, entry, section) self.assertTrue(len(stdout.getvalue()) > 0) finally: diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 4f05aa0a323..12a39d070e4 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -53,6 +53,22 @@ respecting the `bootph-xxx` tags in the devicetree. +.. _etype_atf_bl1: + +Entry: atf-bl1: AP Trusted ROM (TF-A) BL1 blob +----------------------------------------------------- + +Properties / Entry arguments: + - atf-bl1-path: Filename of file to read into entry. This is typically + called bl1.bin + +This entry holds the AP Trusted ROM firmware typically used by an SoC to +help initialize the SoC before the SPL or U-Boot is started. See +https://github.com/TrustedFirmware-A/trusted-firmware-a for more information +about Boot Loader stage 1 (BL1) or about Trusted Firmware (TF-A) + + + .. _etype_atf_bl31: Entry: atf-bl31: ARM Trusted Firmware (ATF) BL31 blob diff --git a/tools/binman/entry.py b/tools/binman/entry.py index bdc60e47fca..ce7ef28e94b 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -88,6 +88,7 @@ class Entry(object): updated with a hash of the entry contents comp_bintool: Bintools used for compress and decompress data fake_fname: Fake filename, if one was created, else None + faked (bool): True if the entry is absent and faked required_props (dict of str): Properties which must be present. This can be added to by subclasses elf_fname (str): Filename of the ELF file, if this entry holds an ELF @@ -759,7 +760,7 @@ class Entry(object): self.image_pos) # pylint: disable=assignment-from-none - def GetEntries(self): + def GetEntries(self) -> None: """Return a list of entries contained by this entry Returns: @@ -1120,7 +1121,7 @@ features to produce new behaviours. if self.missing and not self.optional: missing_list.append(self) - def check_fake_fname(self, fname, size=0): + def check_fake_fname(self, fname: str, size: int = 0) -> str: """If the file is missing and the entry allows fake blobs, fake it Sets self.faked to True if faked @@ -1130,9 +1131,7 @@ features to produce new behaviours. size (int): Size of fake file to create Returns: - tuple: - fname (str): Filename of faked file - bool: True if the blob was faked, False if not + fname (str): Filename of faked file """ if self.allow_fake and not pathlib.Path(fname).is_file(): if not self.fake_fname: @@ -1142,8 +1141,8 @@ features to produce new behaviours. tout.info(f"Entry '{self._node.path}': Faked blob '{outfname}'") self.fake_fname = outfname self.faked = True - return self.fake_fname, True - return fname, False + return self.fake_fname + return fname def CheckFakedBlobs(self, faked_blobs_list): """Check if any entries in this section have faked external blobs @@ -1352,6 +1351,10 @@ features to produce new behaviours. os.mkdir(cls.fake_dir) tout.notice(f"Fake-blob dir is '{cls.fake_dir}'") + def drop_absent_optional(self) -> None: + """Entries don't have any entries, do nothing""" + pass + def ensure_props(self): """Raise an exception if properties are missing diff --git a/tools/binman/etype/atf_bl1.py b/tools/binman/etype/atf_bl1.py new file mode 100644 index 00000000000..7adf10e693c --- /dev/null +++ b/tools/binman/etype/atf_bl1.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2025 Texas Instruments Incorporated +# +# Entry-type module for Application Processor Trusted ROM (BL1) +# + +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg + +class Entry_atf_bl1(Entry_blob_named_by_arg): + """Application Processor (AP) Trusted ROM BL1 blob + + Properties / Entry arguments: + - atf-bl1-path: Filename of file to read into entry. This is typically + called bl1.bin or bl1.elf + + This entry holds the boot code initialization like exception vectors and + processor and platform initialization. + + See https://github.com/TrustedFirmware-A/trusted-firmware-a for more information. + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node, 'atf-bl1') + self.external = True diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index 041e1122953..acd9ae34074 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -42,7 +42,7 @@ class Entry_blob(Entry): if fdt_util.GetBool(self._node, 'write-symbols'): self.auto_write_symbols = True - def ObtainContents(self, fake_size=0): + def ObtainContents(self, fake_size: int = 0) -> bool: self._filename = self.GetDefaultFilename() self._pathname = tools.get_input_filename(self._filename, self.external and (self.optional or self.section.GetAllowMissing())) @@ -50,10 +50,11 @@ class Entry_blob(Entry): if not self._pathname: if not fake_size and self.assume_size: fake_size = self.assume_size - self._pathname, faked = self.check_fake_fname(self._filename, - fake_size) + self._pathname = self.check_fake_fname(self._filename, fake_size) self.missing = True - if not faked: + if self.optional: + self.mark_absent("missing but optional") + if not self.faked: content_size = 0 if self.assume_size: # Ensure we get test coverage on next line content_size = self.assume_size diff --git a/tools/binman/etype/blob_ext_list.py b/tools/binman/etype/blob_ext_list.py index 1bfcf6733a7..a8b5a24c3a1 100644 --- a/tools/binman/etype/blob_ext_list.py +++ b/tools/binman/etype/blob_ext_list.py @@ -33,11 +33,11 @@ class Entry_blob_ext_list(Entry_blob): self._filenames = fdt_util.GetStringList(self._node, 'filenames') self._pathnames = [] - def ObtainContents(self): + def ObtainContents(self) -> bool: missing = False pathnames = [] for fname in self._filenames: - fname, _ = self.check_fake_fname(fname) + fname = self.check_fake_fname(fname) pathname = tools.get_input_filename( fname, self.external and self.section.GetAllowMissing()) # Allow the file to be missing diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py index 124fa1e4ffc..5879f377231 100644 --- a/tools/binman/etype/cbfs.py +++ b/tools/binman/etype/cbfs.py @@ -276,7 +276,8 @@ class Entry_cbfs(Entry): for entry in self._entries.values(): entry.ListEntries(entries, indent + 1) - def GetEntries(self): + def GetEntries(self) -> dict[str, Entry]: + """Returns the entries (tree children) of this section""" return self._entries def ReadData(self, decomp=True, alt_format=None): diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index ed3cac4ee7e..db40479d30e 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -557,12 +557,15 @@ class Entry_fit(Entry_section): Raises: ValueError: Filename 'rsa2048.key' not found in input path ValueError: Multiple key paths found + ValueError: 'dir/rsa2048' is a path not a filename """ def _find_keys_dir(node): for subnode in node.subnodes: if (subnode.name.startswith('signature') or subnode.name.startswith('cipher')): hint = subnode.props['key-name-hint'].value + if '/' in hint: + self.Raise(f"'{hint}' is a path not a filename") name = tools.get_input_filename( f"{hint}.key" if subnode.name.startswith('signature') else f"{hint}.bin") diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 6ae5d0c8a4f..75e59c3d3a3 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -205,7 +205,7 @@ class Entry_mkimage(Entry_section): self.record_missing_bintool(self.mkimage) return data - def GetEntries(self): + def GetEntries(self) -> dict[str, Entry]: # Make a copy so we don't change the original entries = OrderedDict(self._entries) if self._imagename: diff --git a/tools/binman/etype/renesas_rcar4_sa0.py b/tools/binman/etype/renesas_rcar4_sa0.py new file mode 100644 index 00000000000..3a7c0988fdc --- /dev/null +++ b/tools/binman/etype/renesas_rcar4_sa0.py @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2025 Marek Vasut <marek.vasut+renesas@mailbox.org> +# +# Entry-type module for generating the Renesas R-Car Gen4 SA0 header. +# + +import os +import struct + +from binman.etype.section import Entry_section +from dtoc import fdt_util +from u_boot_pylib import tools + +RCAR_GEN4_SF_HEADER_SIZE = 0x40000 +RCAR_GEN4_SF_MAX_LOAD_SIZE = 0xec000 + +class Entry_renesas_rcar4_sa0(Entry_section): + """Renesas R-Car Gen4 SA0 generator""" + + def __init__(self, section, etype, node): + super().__init__(section, etype, node) + self.required_props = ['renesas,loader-address'] + + def ReadNode(self): + self.loader_address = fdt_util.GetInt(self._node, 'renesas,loader-address') + super().ReadNode() + + def BuildSectionData(self, required): + data = super().BuildSectionData(required)[RCAR_GEN4_SF_HEADER_SIZE:] + + # Offset 0x0000 / Value 0x00000000 + header = struct.pack('<I', 0) + header += tools.get_bytes(0xff, 0x3008) + # Offset 0x300c / Value 0x00000000 + header += struct.pack('<I', 0) + header += tools.get_bytes(0xff, 0x144) + # Offset 0x3154 / Value (payload load address) + header += struct.pack('<I', self.loader_address) + header += tools.get_bytes(0xff, 0x10c) + # Offset 0x3264 / Value (payload size in 4-byte words, aligned to 4k) + header += struct.pack('<I', int(tools.align(len(data), 0x1000) / 4)) + header += tools.get_bytes(0xff, 0x3cd98) + if len(data) > RCAR_GEN4_SF_MAX_LOAD_SIZE: + self.Raise(f'SRAM data longer than {RCAR_GEN4_SF_MAX_LOAD_SIZE} Bytes') + + return header + data diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 4c4c8c417f8..03c4f7c6ec7 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -189,7 +189,7 @@ class Entry_section(Entry): self._sort = fdt_util.GetBool(self._node, 'sort-by-offset') self._end_at_4gb = fdt_util.GetBool(self._node, 'end-at-4gb') self._skip_at_start = fdt_util.GetInt(self._node, 'skip-at-start') - if self._end_at_4gb: + if self._end_at_4gb and self.GetImage().copy_to_orig: if not self.size: self.Raise("Section size must be provided when using end-at-4gb") if self._skip_at_start is not None: @@ -263,6 +263,8 @@ class Entry_section(Entry): super().AddMissingProperties(have_image_pos) if self.compress != 'none': have_image_pos = False + if self._end_at_4gb: + state.AddZeroProp(self._node, 'skip-at-start') for entry in self._entries.values(): entry.AddMissingProperties(have_image_pos) @@ -505,6 +507,8 @@ class Entry_section(Entry): def SetCalculatedProperties(self): super().SetCalculatedProperties() + if self._end_at_4gb: + state.SetInt(self._node, 'skip-at-start', self._skip_at_start) for entry in self._entries.values(): entry.SetCalculatedProperties() @@ -533,7 +537,7 @@ class Entry_section(Entry): for entry in self._entries.values(): entry.WriteMap(fd, indent + 1) - def GetEntries(self): + def GetEntries(self) -> dict[str, Entry]: return self._entries def GetContentsByPhandle(self, phandle, source_entry, required): @@ -768,9 +772,17 @@ class Entry_section(Entry): todo) return True - def drop_absent(self): - """Drop entries which are absent""" - self._entries = {n: e for n, e in self._entries.items() if not e.absent} + def drop_absent_optional(self) -> None: + """Drop entries which are absent. + Call for all nodes in the tree. Leaf nodes will do nothing per + definition. Sections however have _entries and should drop all children + which are absent. + """ + self._entries = {n: e for n, e in self._entries.items() if not (e.absent and e.optional)} + # Drop nodes first before traversing children to avoid superfluous calls + # to children of absent nodes. + for e in self.GetEntries().values(): + e.drop_absent_optional() def _SetEntryOffsetSize(self, name, offset, size): """Set the offset and size of an entry diff --git a/tools/binman/etype/ti_secure.py b/tools/binman/etype/ti_secure.py index 420ee263e4f..f6caa0286d9 100644 --- a/tools/binman/etype/ti_secure.py +++ b/tools/binman/etype/ti_secure.py @@ -124,6 +124,7 @@ class Entry_ti_secure(Entry_x509_cert): 'OU': 'Processors', 'CN': 'TI Support', 'emailAddress': 'support@ti.com'} + self.debug = fdt_util.GetBool(self._node, 'debug', False) def ReadFirewallNode(self): self.firewall_cert_data['certificate'] = "" diff --git a/tools/binman/etype/ti_secure_rom.py b/tools/binman/etype/ti_secure_rom.py index f6fc3f90f84..7e90c655940 100644 --- a/tools/binman/etype/ti_secure_rom.py +++ b/tools/binman/etype/ti_secure_rom.py @@ -87,6 +87,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): 'OU': 'Processors', 'CN': 'TI Support', 'emailAddress': 'support@ti.com'} + self.debug = fdt_util.GetBool(self._node, 'debug', False) def NonCombinedGetCertificate(self, required): """Generate certificate for legacy boot flow diff --git a/tools/binman/etype/u_boot_spl_pubkey_dtb.py b/tools/binman/etype/u_boot_spl_pubkey_dtb.py index cb196061de2..3061c4bcdc4 100644 --- a/tools/binman/etype/u_boot_spl_pubkey_dtb.py +++ b/tools/binman/etype/u_boot_spl_pubkey_dtb.py @@ -87,6 +87,8 @@ class Entry_u_boot_spl_pubkey_dtb(Entry_blob_dtb): dir=tools.get_output_dir())\ as pubkey_tdb: tools.write_file(pubkey_tdb.name, self.GetData()) + if '/' in self._key_name_hint: + self.Raise(f"'{self._key_name_hint}' is a path not a filename") keyname = tools.get_input_filename(self._key_name_hint + ".crt") self.fdt_add_pubkey.run(pubkey_tdb.name, os.path.dirname(keyname), diff --git a/tools/binman/etype/x509_cert.py b/tools/binman/etype/x509_cert.py index 25e6808b7f9..b6e8b0b4fb0 100644 --- a/tools/binman/etype/x509_cert.py +++ b/tools/binman/etype/x509_cert.py @@ -52,6 +52,7 @@ class Entry_x509_cert(Entry_collection): self.sysfw_inner_cert_ext_boot_block = None self.dm_data_ext_boot_block = None self.firewall_cert_data = None + self.debug = False def ReadNode(self): super().ReadNode() @@ -114,7 +115,8 @@ class Entry_x509_cert(Entry_collection): bootcore=self.bootcore, bootcore_opts=self.bootcore_opts, load_addr=self.load_addr, - sha=self.sha + sha=self.sha, + debug=self.debug ) elif type == 'rom-combined': stdout = self.openssl.x509_cert_rom_combined( @@ -140,7 +142,8 @@ class Entry_x509_cert(Entry_collection): hashval_sysfw_data=self.hashval_sysfw_data, sysfw_inner_cert_ext_boot_block=self.sysfw_inner_cert_ext_boot_block, dm_data_ext_boot_block=self.dm_data_ext_boot_block, - bootcore_opts=self.bootcore_opts + bootcore_opts=self.bootcore_opts, + debug=self.debug ) if stdout is not None: data = tools.read_file(output_fname) diff --git a/tools/binman/fip_util_test.py b/tools/binman/fip_util_test.py index 56aa56f4643..cb4001be020 100755 --- a/tools/binman/fip_util_test.py +++ b/tools/binman/fip_util_test.py @@ -22,6 +22,7 @@ sys.path.insert(2, os.path.join(OUR_PATH, '..')) # pylint: disable=C0413 from binman import bintool from binman import fip_util +from u_boot_pylib import terminal from u_boot_pylib import test_util from u_boot_pylib import tools @@ -215,7 +216,7 @@ toc_entry_t toc_entries[] = { macros = fip_util.parse_macros(self._indir) names = fip_util.parse_names(self._indir) - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): fip_util.create_code_output(macros, names) self.assertIn( "UUID 'UUID_TRUSTED_OS_FW_KEY_CERT' is not mentioned in tbbr_config.c file", @@ -239,7 +240,7 @@ FIP_TYPE_LIST = [ ] # end blah de blah ''', binary=False) - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): fip_util.main(self.args, self.src_file) self.assertIn('Needs update', stdout.getvalue()) @@ -256,7 +257,7 @@ FIP_TYPE_LIST = [ 0x9d, 0xf3, 0x19, 0xed, 0xa1, 0x1f, 0x68, 0x01]), ] # end blah blah''', binary=False) - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): fip_util.main(self.args, self.src_file) self.assertIn('is up-to-date', stdout.getvalue()) @@ -269,7 +270,7 @@ blah blah''', binary=False) args = self.args.copy() args.remove('-D') tools.write_file(self.src_file, '', binary=False) - with test_util.capture_sys_output(): + with terminal.capture(): fip_util.main(args, self.src_file) @unittest.skipIf(not HAVE_FIPTOOL, 'No fiptool available') @@ -389,7 +390,7 @@ Trusted Boot Firmware BL2: offset=0xC0, size=0xE, cmdline="--tb-fw" def test_fiptool_errors(self): """Check some error reporting from fiptool""" with self.assertRaises(Exception) as err: - with test_util.capture_sys_output(): + with terminal.capture(): FIPTOOL.create_bad() self.assertIn("unrecognized option '--fred'", str(err.exception)) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index fa174900014..a90db3c9351 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -36,6 +36,7 @@ from binman.etype import fdtmap from binman.etype import image_header from binman.image import Image from u_boot_pylib import command +from u_boot_pylib import terminal from u_boot_pylib import test_util from u_boot_pylib import tools from u_boot_pylib import tout @@ -83,10 +84,12 @@ FILES_DATA = (b"sorry I'm late\nOh, don't bother apologising, I'm " + b"sorry you're alive\n") COMPRESS_DATA = b'compress xxxxxxxxxxxxxxxxxxxxxx data' COMPRESS_DATA_BIG = COMPRESS_DATA * 2 +MISSING_DATA = b'missing' REFCODE_DATA = b'refcode' FSP_M_DATA = b'fsp_m' FSP_S_DATA = b'fsp_s' FSP_T_DATA = b'fsp_t' +ATF_BL1_DATA = b'bl1' ATF_BL31_DATA = b'bl31' TEE_OS_DATA = b'this is some tee OS data' TI_DM_DATA = b'tidmtidm' @@ -225,6 +228,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('compress', COMPRESS_DATA) TestFunctional._MakeInputFile('compress_big', COMPRESS_DATA_BIG) + TestFunctional._MakeInputFile('bl1.bin', ATF_BL1_DATA) TestFunctional._MakeInputFile('bl31.bin', ATF_BL31_DATA) TestFunctional._MakeInputFile('tee-pager.bin', TEE_OS_DATA) TestFunctional._MakeInputFile('dm.bin', TI_DM_DATA) @@ -247,7 +251,7 @@ class TestFunctional(unittest.TestCase): # ATF and OP_TEE TestFunctional._MakeInputFile('bl31.elf', tools.read_file(cls.ElfTestFile('elf_sections'))) - TestFunctional._MakeInputFile('tee.elf', + TestFunctional.tee_elf_path = TestFunctional._MakeInputFile('tee.elf', tools.read_file(cls.ElfTestFile('elf_sections'))) # Newer OP_TEE file in v1 binary format @@ -273,7 +277,7 @@ class TestFunctional(unittest.TestCase): @classmethod def setup_test_args(cls, preserve_indir=False, preserve_outdirs=False, - toolpath=None, verbosity=None): + toolpath=None, verbosity=None, no_capture=False): """Accept arguments controlling test execution Args: @@ -282,12 +286,13 @@ class TestFunctional(unittest.TestCase): preserve_outdir: Preserve the output directories used by tests. Each test has its own, so this is normally only useful when running a single test. - toolpath: ist of paths to use for tools + toolpath: list of paths to use for tools """ cls.preserve_indir = preserve_indir cls.preserve_outdirs = preserve_outdirs cls.toolpath = toolpath cls.verbosity = verbosity + cls.no_capture = no_capture def _CheckBintool(self, bintool): if not bintool.is_present(): @@ -510,9 +515,9 @@ class TestFunctional(unittest.TestCase): return dtb.GetContents() def _DoReadFileDtb(self, fname, use_real_dtb=False, use_expanded=False, - verbosity=None, map=False, update_dtb=False, - entry_args=None, reset_dtbs=True, extra_indirs=None, - threads=None): + verbosity=None, allow_fake_blobs=True, map=False, + update_dtb=False, entry_args=None, reset_dtbs=True, + extra_indirs=None, threads=None): """Run binman and return the resulting image This runs binman with a given test file and then reads the resulting @@ -530,6 +535,7 @@ class TestFunctional(unittest.TestCase): use_expanded: True to use expanded entries where available, e.g. 'u-boot-expanded' instead of 'u-boot' verbosity: Verbosity level to use (0-3, None=don't set it) + allow_fake_blobs: whether binman should fake missing ext blobs map: True to output map files for the images update_dtb: Update the offset and size of each entry in the device tree before packing it into the image @@ -567,7 +573,7 @@ class TestFunctional(unittest.TestCase): retcode = self._DoTestFile(fname, map=map, update_dtb=update_dtb, entry_args=entry_args, use_real_dtb=use_real_dtb, use_expanded=use_expanded, verbosity=verbosity, - extra_indirs=extra_indirs, + allow_fake_blobs=allow_fake_blobs, extra_indirs=extra_indirs, threads=threads) self.assertEqual(0, retcode) out_dtb_fname = tools.get_output_filename('u-boot.dtb.out') @@ -1796,14 +1802,14 @@ class TestFunctional(unittest.TestCase): def testEntryDocs(self): """Test for creation of entry documentation""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): control.WriteEntryDocs(control.GetEntryModules()) self.assertTrue(len(stdout.getvalue()) > 0) def testEntryDocsMissing(self): """Test handling of missing entry documentation""" with self.assertRaises(ValueError) as e: - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): control.WriteEntryDocs(control.GetEntryModules(), 'u_boot') self.assertIn('Documentation is missing for modules: u_boot', str(e.exception)) @@ -1918,7 +1924,7 @@ class TestFunctional(unittest.TestCase): entry_args = { 'keydir': 'devkeys', } - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('071_gbb.dts', force_missing_bintools='futility', entry_args=entry_args) err = stderr.getvalue() @@ -2014,7 +2020,7 @@ class TestFunctional(unittest.TestCase): entry_args = { 'keydir': 'devkeys', } - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('074_vblock.dts', force_missing_bintools='futility', entry_args=entry_args) @@ -2058,7 +2064,7 @@ class TestFunctional(unittest.TestCase): # We should only get the expected message in verbose mode for verbosity in (0, 2): - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): retcode = self._DoTestFile('006_dual_image.dts', verbosity=verbosity, images=['image2']) @@ -2247,7 +2253,7 @@ class TestFunctional(unittest.TestCase): def testExtendSizeBad(self): """Test an extending entry which fails to provide contents""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): with self.assertRaises(ValueError) as e: self._DoReadFileDtb('089_extend_size_bad.dts', map=True) self.assertIn("Node '/binman/_testing': Cannot obtain contents when " @@ -2376,7 +2382,7 @@ class TestFunctional(unittest.TestCase): def testPackOverlapMap(self): """Test that overlapping regions are detected""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): with self.assertRaises(ValueError) as e: self._DoTestFile('014_pack_overlap.dts', map=True) map_fname = tools.get_output_filename('image.map') @@ -2570,7 +2576,7 @@ class TestFunctional(unittest.TestCase): def testIfwiMissing(self): """Test that binman still produces an image if ifwitool is missing""" self._SetupIfwi('fitimage.bin') - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('111_x86_rom_ifwi.dts', force_missing_bintools='ifwitool') err = stderr.getvalue() @@ -2914,7 +2920,7 @@ class TestFunctional(unittest.TestCase): tmpdir = None try: tmpdir, updated_fname = self._SetupImageInTmpdir() - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoBinman('ls', '-i', updated_fname) finally: if tmpdir: @@ -3078,7 +3084,7 @@ class TestFunctional(unittest.TestCase): tmpdir = None try: tmpdir, updated_fname = self._SetupImageInTmpdir() - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoBinman('extract', '-i', updated_fname, 'u-boot', '-f', fname) finally: @@ -3729,7 +3735,7 @@ class TestFunctional(unittest.TestCase): u_boot_fname1 = os.path.join(outdir, 'u-boot') os.remove(u_boot_fname1) - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): control.ReplaceEntries(updated_fname, None, outdir, []) self.assertIn("Skipping entry '/u-boot' from missing file", stderr.getvalue()) @@ -3870,7 +3876,7 @@ class TestFunctional(unittest.TestCase): def testMkimageMissing(self): """Test that binman still produces an image if mkimage is missing""" self._SetupSplElf() - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('156_mkimage.dts', force_missing_bintools='mkimage') err = stderr.getvalue() @@ -3890,7 +3896,7 @@ class TestFunctional(unittest.TestCase): def testExtblobMissingOk(self): """Test an image with an missing external blob that is allowed""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): ret = self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True) self.assertEqual(103, ret) @@ -3901,7 +3907,7 @@ class TestFunctional(unittest.TestCase): def testExtblobMissingOkFlag(self): """Test an image with an missing external blob allowed with -W""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): ret = self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True, ignore_missing=True) self.assertEqual(0, ret) @@ -3912,7 +3918,7 @@ class TestFunctional(unittest.TestCase): def testExtblobMissingOkSect(self): """Test an image with an missing external blob that is allowed""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('159_blob_ext_missing_sect.dts', allow_missing=True) err = stderr.getvalue() @@ -3920,7 +3926,7 @@ class TestFunctional(unittest.TestCase): def testPackX86RomMeMissingDesc(self): """Test that an missing Intel descriptor entry is allowed""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('164_x86_rom_me_missing.dts', allow_missing=True) err = stderr.getvalue() self.assertRegex(err, "Image 'image'.*missing.*: intel-descriptor") @@ -3930,7 +3936,7 @@ class TestFunctional(unittest.TestCase): self._SetupIfwi('fitimage.bin') pathname = os.path.join(self._indir, 'fitimage.bin') os.remove(pathname) - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('111_x86_rom_ifwi.dts', allow_missing=True) err = stderr.getvalue() self.assertRegex(err, "Image 'image'.*missing.*: intel-ifwi") @@ -4013,7 +4019,7 @@ class TestFunctional(unittest.TestCase): self.assertEqual({ 'image-pos': 0, 'offset': 0, - 'size': 1890, + 'size': 1378, 'u-boot:image-pos': 0, 'u-boot:offset': 0, @@ -4021,7 +4027,7 @@ class TestFunctional(unittest.TestCase): 'fit:image-pos': 4, 'fit:offset': 4, - 'fit:size': 1840, + 'fit:size': 1328, 'fit/images/kernel:image-pos': 304, 'fit/images/kernel:offset': 300, @@ -4039,8 +4045,8 @@ class TestFunctional(unittest.TestCase): 'fit/images/fdt-1/u-boot-spl-dtb:offset': 0, 'fit/images/fdt-1/u-boot-spl-dtb:size': 6, - 'u-boot-nodtb:image-pos': 1844, - 'u-boot-nodtb:offset': 1844, + 'u-boot-nodtb:image-pos': 1332, + 'u-boot-nodtb:offset': 1332, 'u-boot-nodtb:size': 46, }, props) @@ -4152,7 +4158,7 @@ class TestFunctional(unittest.TestCase): def testFitMissingOK(self): """Test that binman still produces a FIT image if mkimage is missing""" - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('162_fit_external.dts', allow_missing=True, force_missing_bintools='mkimage') err = stderr.getvalue() @@ -4226,7 +4232,7 @@ class TestFunctional(unittest.TestCase): def testFitExtblobMissingOk(self): """Test a FIT with a missing external blob that is allowed""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('168_fit_missing_blob.dts', allow_missing=True) err = stderr.getvalue() @@ -4395,7 +4401,7 @@ class TestFunctional(unittest.TestCase): control.missing_blob_help = control._ReadMissingBlobHelp() control.missing_blob_help['wibble'] = 'Wibble test' control.missing_blob_help['another'] = 'Another test' - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('168_fit_missing_blob.dts', allow_missing=True) err = stderr.getvalue() @@ -4664,7 +4670,7 @@ class TestFunctional(unittest.TestCase): def testLz4Missing(self): """Test that binman still produces an image if lz4 is missing""" - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('185_compress_section.dts', force_missing_bintools='lz4') err = stderr.getvalue() @@ -5061,7 +5067,7 @@ class TestFunctional(unittest.TestCase): def testTiming(self): """Test output of timing information""" data = self._DoReadFile('055_sections.dts') - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): state.TimingShow() self.assertIn('read:', stdout.getvalue()) self.assertIn('compress:', stdout.getvalue()) @@ -5156,7 +5162,7 @@ class TestFunctional(unittest.TestCase): self.assertEqual(version, state.GetVersion(self._indir)) with self.assertRaises(SystemExit): - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoBinman('-V') self.assertEqual('Binman %s\n' % version, stderr.getvalue()) @@ -5176,7 +5182,7 @@ class TestFunctional(unittest.TestCase): try: tmpdir, updated_fname = self._SetupImageInTmpdir() - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): self._DoBinman('extract', '-i', updated_fname, '-F', 'list') self.assertEqual( '''Flag (-F) Entry type Description @@ -5206,21 +5212,23 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testExtblobList(self): """Test an image with an external blob list""" - data = self._DoReadFile('215_blob_ext_list.dts') - self.assertEqual(REFCODE_DATA + FSP_M_DATA, data) + data = self._DoReadFileDtb('215_blob_ext_list.dts', + allow_fake_blobs=False) + self.assertEqual(REFCODE_DATA + FSP_M_DATA, data[0]) def testExtblobListMissing(self): """Test an image with a missing external blob""" with self.assertRaises(ValueError) as e: - self._DoReadFile('216_blob_ext_list_missing.dts') + self._DoReadFileDtb('216_blob_ext_list_missing.dts', + allow_fake_blobs=False) self.assertIn("Filename 'missing-file' not found in input path", str(e.exception)) def testExtblobListMissingOk(self): """Test an image with an missing external blob that is allowed""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('216_blob_ext_list_missing.dts', - allow_missing=True) + allow_missing=True, allow_fake_blobs=False) err = stderr.getvalue() self.assertRegex(err, "Image 'image'.*missing.*: blob-ext") @@ -5295,7 +5303,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap tmpdir = None try: tmpdir, updated_fname = self._SetupImageInTmpdir() - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoBinman('ls', '-i', updated_fname) finally: if tmpdir: @@ -5378,7 +5386,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(True, fent.valid) def testFipMissing(self): - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('209_fip_missing.dts', allow_missing=True) err = stderr.getvalue() self.assertRegex(err, "Image 'image'.*missing.*: rmm-fw") @@ -5432,7 +5440,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFakeBlob(self): """Test handling of faking an external blob""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('217_fake_blob.dts', allow_missing=True, allow_fake_blobs=True) err = stderr.getvalue() @@ -5442,7 +5450,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testExtblobListFaked(self): """Test an extblob with missing external blob that are faked""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('216_blob_ext_list_missing.dts', allow_fake_blobs=True) err = stderr.getvalue() @@ -5450,7 +5458,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testListBintools(self): args = ['tool', '--list'] - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): self._DoBinman(*args) out = stdout.getvalue().splitlines() self.assertTrue(len(out) >= 2) @@ -5474,20 +5482,20 @@ fdt fdtmap Extract the devicetree blob from the fdtmap args = ['tool', '--fetch', '_testing'] with unittest.mock.patch.object(tools, 'download', side_effect=fail_download): - with test_util.capture_sys_output() as (stdout, _): + with terminal.capture() as (stdout, _): self._DoBinman(*args) self.assertIn('failed to fetch with all methods', stdout.getvalue()) def testBintoolDocs(self): """Test for creation of bintool documentation""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): control.write_bintool_docs(control.bintool.Bintool.get_tool_list()) self.assertTrue(len(stdout.getvalue()) > 0) def testBintoolDocsMissing(self): """Test handling of missing bintool documentation""" with self.assertRaises(ValueError) as e: - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): control.write_bintool_docs( control.bintool.Bintool.get_tool_list(), 'mkimage') self.assertIn('Documentation is missing for modules: mkimage', @@ -5507,7 +5515,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap tmpdir = None try: tmpdir, updated_fname = self._SetupImageInTmpdir() - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._RunBinman('ls', '-i', updated_fname) finally: if tmpdir: @@ -5532,7 +5540,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap entry_args = { 'keydir': 'devkeys', } - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('220_fit_subentry_bintool.dts', force_missing_bintools='futility', entry_args=entry_args) err = stderr.getvalue() @@ -5573,6 +5581,22 @@ fdt fdtmap Extract the devicetree blob from the fdtmap data = self._DoReadFile('225_ti_dm.dts') self.assertEqual(TI_DM_DATA, data[:len(TI_DM_DATA)]) + def testPackBl1(self): + """test if an image with a bl1 binary can be created""" + data = self._DoReadFile('347_bl1.dts') + self.assertEqual(ATF_BL1_DATA, data[:len(ATF_BL1_DATA)]) + + def testRenesasRCarGen4SA0Image(self): + """Test that binman can produce an Renesas R-Car Gen4 SA0 image""" + self._DoTestFile('348_renesas_rcar4_sa0.dts') + + def testRenesasRCarGen4SA0ImageSize(self): + """Test that binman can not produce large Renesas R-Car Gen4 SA0 image""" + with self.assertRaises(ValueError) as exc: + self._DoTestFile('349_renesas_rcar4_sa0_size.dts') + self.assertIn("Node '/binman/renesas-rcar4-sa0': SRAM data longer than 966656 Bytes", + str(exc.exception)) + def testFitFdtOper(self): """Check handling of a specified FIT operation""" entry_args = { @@ -5729,7 +5753,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'tee-os-path': 'missing.elf', } test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile( '226_fit_split_elf.dts', entry_args=entry_args, extra_indirs=[test_subdir], verbosity=3, **kwargs) @@ -5757,10 +5781,10 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfMissing(self): - """Test an split-elf FIT with a missing ELF file""" + """Test an split-elf FIT with a missing ELF file. Don't fake the file.""" if not elf.ELF_TOOLS: self.skipTest('Python elftools not available') - out, err = self.checkFitSplitElf(allow_missing=True) + out, err = self.checkFitSplitElf(allow_missing=True, allow_fake_blobs=False) self.assertRegex( err, "Image '.*' is missing external blobs and is non-functional: .*") @@ -5784,7 +5808,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testMkimageMissingBlob(self): """Test using mkimage to build an image""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('229_mkimage_missing.dts', allow_missing=True, allow_fake_blobs=True) err = stderr.getvalue() @@ -6449,16 +6473,18 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testAbsent(self): """Check handling of absent entries""" data = self._DoReadFile('262_absent.dts') - self.assertEqual(U_BOOT_DATA + U_BOOT_IMG_DATA, data) + self.assertEqual(U_BOOT_DATA + b'aa' + U_BOOT_IMG_DATA, data) - def testPackTeeOsOptional(self): - """Test that an image with an optional TEE binary can be created""" + def testPackTeeOsElf(self): + """Test that an image with a TEE elf binary can be created""" entry_args = { 'tee-os-path': 'tee.elf', } + tee_path = self.tee_elf_path data = self._DoReadFileDtb('263_tee_os_opt.dts', entry_args=entry_args)[0] - self.assertEqual(U_BOOT_DATA + U_BOOT_IMG_DATA, data) + self.assertEqual(U_BOOT_DATA + tools.read_file(tee_path) + + U_BOOT_IMG_DATA, data) def checkFitTee(self, dts, tee_fname): """Check that a tee-os entry works and returns data @@ -6497,12 +6523,15 @@ fdt fdtmap Extract the devicetree blob from the fdtmap fdt_util.fdt32_to_cpu(node.props['entry'].value)) self.assertEqual(U_BOOT_DATA, node.props['data'].bytes) - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self.checkFitTee('264_tee_os_opt_fit.dts', '') err = stderr.getvalue() self.assertRegex( err, "Image '.*' is missing optional external blobs but is still functional: tee-os") + self.assertNotRegex( + err, + "Image '.*' has faked external blobs and is non-functional: tee-os") def testFitTeeOsOptionalFitBad(self): """Test an image with a FIT with an optional OP-TEE binary""" @@ -6528,15 +6557,26 @@ fdt fdtmap Extract the devicetree blob from the fdtmap "Node '/binman/fit/images/@tee-SEQ/tee-os': Invalid OP-TEE file: size mismatch (expected 0x4, have 0xe)", str(exc.exception)) - def testExtblobOptional(self): + def testExtblobMissingOptional(self): """Test an image with an external blob that is optional""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): + data = self._DoReadFileDtb('266_blob_ext_opt.dts', + allow_fake_blobs=False)[0] + self.assertEqual(REFCODE_DATA, data) + self.assertNotIn(MISSING_DATA, data) + + def testExtblobFakedOptional(self): + """Test an image with an external blob that is optional""" + with terminal.capture() as (stdout, stderr): data = self._DoReadFile('266_blob_ext_opt.dts') self.assertEqual(REFCODE_DATA, data) err = stderr.getvalue() self.assertRegex( err, "Image '.*' is missing optional external blobs but is still functional: missing") + self.assertNotRegex( + err, + "Image '.*' has faked external blobs and is non-functional: missing") def testSectionInner(self): """Test an inner section with a size""" @@ -6686,7 +6726,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'tee-os-path': 'missing.bin', } test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): data = self._DoReadFileDtb( '276_fit_firmware_loadables.dts', entry_args=entry_args, @@ -6717,12 +6757,12 @@ fdt fdtmap Extract the devicetree blob from the fdtmap node = dtb.GetNode('/configurations/conf-missing-tee-1') self.assertEqual('atf-1', node.props['firmware'].value) - self.assertEqual(['u-boot', 'atf-2'], + self.assertEqual(['u-boot', 'tee', 'atf-2'], fdt_util.GetStringList(node, 'loadables')) def testTooldir(self): """Test that we can specify the tooldir""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self.assertEqual(0, self._DoBinman('--tooldir', 'fred', 'tool', '-l')) self.assertEqual('fred', bintool.Bintool.tooldir) @@ -6731,7 +6771,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(['fred'], tools.tool_search_paths) # Try with a few toolpaths; the tooldir should be at the end - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self.assertEqual(0, self._DoBinman( '--toolpath', 'mary', '--toolpath', 'anna', '--tooldir', 'fred', 'tool', '-l')) @@ -6836,7 +6876,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap entry_args = { 'keyfile': 'keyfile', } - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('279_x509_cert.dts', force_missing_bintools='openssl', entry_args=entry_args) @@ -6850,7 +6890,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testMkimageMissingBlobMultiple(self): """Test missing blob with mkimage entry and multiple-data-files""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('292_mkimage_missing_multiple.dts', allow_missing=True) err = stderr.getvalue() self.assertIn("is missing external blobs and is non-functional", err) @@ -7196,7 +7236,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap entry_args = { 'keyfile': keyfile, } - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('296_ti_secure.dts', force_missing_bintools='openssl', entry_args=entry_args) @@ -7281,6 +7321,13 @@ fdt fdtmap Extract the devicetree blob from the fdtmap tools.to_bytes(''.join(node.props['key'].value))) self.assertNotIn('key-source', node.props) + def testKeyNameHintIsPathSplPubkeyDtb(self): + """Test that binman errors out on key-name-hint being a path""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('348_key_name_hint_dir_spl_pubkey_dtb.dts') + self.assertIn( + 'Node \'/binman/u-boot-spl-pubkey-dtb\': \'keys/key\' is a path not a filename', + str(e.exception)) def testSplPubkeyDtb(self): """Test u_boot_spl_pubkey_dtb etype""" @@ -7372,7 +7419,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self._MakeInputFile("ssk.pem", data) self._SetupPmuFwlElf() self._SetupSplElf() - with test_util.capture_sys_output() as (_, stderr): + with terminal.capture() as (_, stderr): self._DoTestFile('307_xilinx_bootgen_sign.dts', force_missing_bintools='bootgen') err = stderr.getvalue() @@ -7575,7 +7622,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def test_assume_size_ok(self): """Test handling of the assume-size where it fits OK""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('327_assume_size_ok.dts', allow_missing=True, allow_fake_blobs=True) err = stderr.getvalue() @@ -7585,7 +7632,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def test_assume_size_no_fake(self): """Test handling of the assume-size where it fits OK""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self._DoTestFile('327_assume_size_ok.dts', allow_missing=True) err = stderr.getvalue() self.assertRegex( @@ -7817,7 +7864,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testMkeficapsuleMissingOk(self): """Test that binman deals with mkeficapsule being missing""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): ret = self._DoTestFile('311_capsule.dts', force_missing_bintools='mkeficapsule', allow_missing=True) @@ -7842,7 +7889,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testSymbolsCompressed(self): """Test binman complains about symbols from a compressed section""" - with test_util.capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): self.checkSymbols('338_symbols_comp.dts', U_BOOT_SPL_DATA, None) out = stdout.getvalue() self.assertIn('Symbol-writing: no value for /binman/section/u-boot', @@ -7954,6 +8001,24 @@ fdt fdtmap Extract the devicetree blob from the fdtmap entry_args=entry_args, extra_indirs=[test_subdir])[0] + def testKeyNameHintIsPathSimpleFit(self): + """Test that binman errors out on key-name-hint being a path""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') + entry_args = { + 'of-list': 'test-fdt1', + 'default-dt': 'test-fdt1', + 'atf-bl31-path': 'bl31.elf', + } + test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) + with self.assertRaises(ValueError) as e: + self._DoReadFileDtb( + '347_key_name_hint_dir_fit_signature.dts', + entry_args=entry_args, + extra_indirs=[test_subdir]) + self.assertIn( + 'Node \'/binman/fit\': \'keys/rsa2048\' is a path not a filename', + str(e.exception)) def testSimpleFitEncryptedData(self): """Test an image with a FIT containing data to be encrypted""" @@ -8011,5 +8076,29 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self._DoTestFile('346_remove_template.dts', force_missing_bintools='openssl',) + def testBootphPropagation(self): + """Test that bootph-* properties are propagated correctly to supernodes""" + _, _, _, out_dtb_fname = self._DoReadFileDtb( + '347_bootph_prop.dts', use_real_dtb=True, update_dtb=True) + dtb = fdt.Fdt(out_dtb_fname) + dtb.Scan() + root = dtb.GetRoot() + parent_node = root.FindNode('dummy-parent') + subnode1 = parent_node.FindNode('subnode-1') + subnode2 = subnode1.FindNode('subnode-2') + subnode3 = subnode1.FindNode('subnode-3') + subnode4 = subnode3.FindNode('subnode-4') + + self.assertIn('bootph-some-ram', subnode1.props, + "Child node is missing 'bootph-some-ram' property") + self.assertIn('bootph-all', subnode1.props, + "Child node is missing 'bootph-all' property") + self.assertIn('bootph-some-ram', parent_node.props, + "Parent node is missing 'bootph-some-ram' property") + self.assertIn('bootph-all', parent_node.props, + "Parent node is missing 'bootph-all' property") + self.assertEqual(len(subnode4.props), 0, + "subnode shouldn't have any properties") + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/image.py b/tools/binman/image.py index 24ce0af7c72..698cfa4148e 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -183,6 +183,8 @@ class Image(section.Entry_section): fname = tools.get_output_filename(self._filename) tout.info("Writing image to '%s'" % fname) with open(fname, 'wb') as fd: + # For final image, don't write absent blobs to file + self.drop_absent_optional() data = self.GetPaddedData() fd.write(data) tout.info("Wrote %#x bytes" % len(data)) diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py index 7d65e2d589a..26e161c91fc 100644 --- a/tools/binman/image_test.py +++ b/tools/binman/image_test.py @@ -7,7 +7,7 @@ import unittest from binman.image import Image -from u_boot_pylib.test_util import capture_sys_output +from u_boot_pylib import terminal class TestImage(unittest.TestCase): def testInvalidFormat(self): @@ -29,7 +29,7 @@ class TestImage(unittest.TestCase): def testMissingSymbolOptional(self): image = Image('name', 'node', test=True) image._entries = {} - with capture_sys_output() as (stdout, stderr): + with terminal.capture() as (stdout, stderr): val = image.GetSymbolValue('_binman_type_prop_pname', True, 'msg', 0) self.assertEqual(val, None) self.assertEqual("Warning: msg: Entry 'type' not found in list ()\n", diff --git a/tools/binman/main.py b/tools/binman/main.py index 326f5c93155..fa5ad79ca0e 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -77,8 +77,8 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): # Run the entry tests first ,since these need to be the first to import the # 'entry' module. result = test_util.run_test_suites( - 'binman', debug, verbosity, test_preserve_dirs, processes, test_name, - toolpath, + 'binman', debug, verbosity, False, test_preserve_dirs, processes, + test_name, toolpath, [bintool_test.TestBintool, entry_test.TestEntry, ftest.TestFunctional, fdt_test.TestFdt, elf_test.TestElf, image_test.TestImage, cbfs_util_test.TestCbfs, fip_util_test.TestFip]) diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help index ab0023eb9fb..d2ed35bef4d 100644 --- a/tools/binman/missing-blob-help +++ b/tools/binman/missing-blob-help @@ -14,15 +14,6 @@ atf-bl31-sunxi: Please read the section on ARM Trusted Firmware (ATF) in board/sunxi/README.sunxi64 -scp-sunxi: -SCP firmware is required for system suspend, but is otherwise optional. -Please read the section on SCP firmware in board/sunxi/README.sunxi64 - -iot2050-seboot: -See the documentation for IOT2050 board. Your image is missing SEBoot -which is mandatory for board startup. Prebuilt SEBoot located at -meta-iot2050/tree/master/recipes-bsp/u-boot/files/prebuild/seboot_pg*.bin. - iot2050-otpcmd: See the documentation for IOT2050 board. Your image is missing OTP command data block which is used for provisioning the customer keys to the board. @@ -31,22 +22,62 @@ meta-iot2050/tree/master/recipes-bsp/secure-boot-otp-provisioning/files/make-otp for how to generate this binary. If you are not using secure boot or do not intend to provision the keys, disable CONFIG_IOT2050_EMBED_OTPCMD. +iot2050-seboot: +See the documentation for IOT2050 board. Your image is missing SEBoot +which is mandatory for board startup. Prebuilt SEBoot located at +meta-iot2050/tree/master/recipes-bsp/u-boot/files/prebuild/seboot_pg*.bin. + k3-rti-wdt-firmware: 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. +opensbi: +See the documentation for your board. The OpenSBI git repo is at +https://github.com/riscv/opensbi.git +You may need to build fw_dynamic.bin first and re-build u-boot with +OPENSBI=/path/to/fw_dynamic.bin + 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. +scp-sunxi: +SCP firmware is required for system suspend, but is otherwise optional. +Please read the section on SCP firmware in board/sunxi/README.sunxi64 + +sysfw-inner-cert: +You are missing the inner certificate for TI's Foundational Security (TIFS) +firmware which is critical to authenticating the TIFS firmware during boot. +HS-FS and HS-SE parts will not boot without this certificate. + +Have a look at your board's documentation to find and include the latest +TIFS certificate blobs and how to include them in the build. + + https://docs.u-boot.org/en/latest/board/ti/k3.html + tee-os: See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin -opensbi: -See the documentation for your board. The OpenSBI git repo is at -https://github.com/riscv/opensbi.git -You may need to build fw_dynamic.bin first and re-build u-boot with -OPENSBI=/path/to/fw_dynamic.bin +ti-dm: +You are missing TI's Device Management (DM) firmware which is critical to +provide resource and power management services for your board. Your board +will not boot without this firmware. + +Have a look at your board's documentation to find the latest version of +the DM firmware binary and how to include it in the build. + + https://docs.u-boot.org/en/latest/board/ti/k3.html + +ti-fs-enc.bin: +You are missing TI's Foundational Security (TIFS) firmware which is +critical to provide foundational security services like authenticated boot, +and firewall management for the SoC. Your board will not boot without +this firmware. + +Have a look at your board's documentation to find the latest version of the +TIFS firmware binary and how to include them in the build. + + https://docs.u-boot.org/en/latest/board/ti/k3.html diff --git a/tools/binman/test/170_fit_fdt.dts b/tools/binman/test/170_fit_fdt.dts index 0197ffd1597..4b1e9b41ec0 100644 --- a/tools/binman/test/170_fit_fdt.dts +++ b/tools/binman/test/170_fit_fdt.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/220_fit_subentry_bintool.dts b/tools/binman/test/220_fit_subentry_bintool.dts index 6e29d41eeb3..b1d8fb0feae 100644 --- a/tools/binman/test/220_fit_subentry_bintool.dts +++ b/tools/binman/test/220_fit_subentry_bintool.dts @@ -12,7 +12,7 @@ #address-cells = <1>; images { - test { + kernel { description = "Something using a bintool"; type = "kernel"; arch = "arm"; diff --git a/tools/binman/test/223_fit_fdt_oper.dts b/tools/binman/test/223_fit_fdt_oper.dts index e630165acf4..cb3b31e36f6 100644 --- a/tools/binman/test/223_fit_fdt_oper.dts +++ b/tools/binman/test/223_fit_fdt_oper.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/284_fit_fdt_list.dts b/tools/binman/test/284_fit_fdt_list.dts index 8885313f5b8..70cdb326708 100644 --- a/tools/binman/test/284_fit_fdt_list.dts +++ b/tools/binman/test/284_fit_fdt_list.dts @@ -15,6 +15,20 @@ fit,fdt-list-val = "test-fdt1", "test-fdt2"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/333_fit_fdt_dir.dts b/tools/binman/test/333_fit_fdt_dir.dts index aa778451a4b..71971de4232 100644 --- a/tools/binman/test/333_fit_fdt_dir.dts +++ b/tools/binman/test/333_fit_fdt_dir.dts @@ -15,6 +15,20 @@ fit,fdt-list-dir = "fdts"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/334_fit_fdt_compat.dts b/tools/binman/test/334_fit_fdt_compat.dts index 3bf45c710db..bf1b5a4a94a 100644 --- a/tools/binman/test/334_fit_fdt_compat.dts +++ b/tools/binman/test/334_fit_fdt_compat.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/335_fit_fdt_phase.dts b/tools/binman/test/335_fit_fdt_phase.dts index f8d0740a394..c20bcad651a 100644 --- a/tools/binman/test/335_fit_fdt_phase.dts +++ b/tools/binman/test/335_fit_fdt_phase.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/345_fit_fdt_name.dts b/tools/binman/test/345_fit_fdt_name.dts index 631a8e5f59b..0ef2e1934a0 100644 --- a/tools/binman/test/345_fit_fdt_name.dts +++ b/tools/binman/test/345_fit_fdt_name.dts @@ -15,6 +15,20 @@ fit,fdt-list = "of-list"; images { + atf { + description = "atf firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; + uboot { + description = "U-Boot firmware"; + type = "firmware"; + compression = "none"; + load = <00000000>; + entry = <00000000>; + }; kernel { description = "Vanilla Linux kernel"; type = "kernel"; diff --git a/tools/binman/test/347_bl1.dts b/tools/binman/test/347_bl1.dts new file mode 100644 index 00000000000..1a109956204 --- /dev/null +++ b/tools/binman/test/347_bl1.dts @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + binman { + atf-bl1 { + filename = "bl1.bin"; + }; + }; +}; diff --git a/tools/binman/test/347_bootph_prop.dts b/tools/binman/test/347_bootph_prop.dts new file mode 100644 index 00000000000..91d4e4ad600 --- /dev/null +++ b/tools/binman/test/347_bootph_prop.dts @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; +/ { + dummy-parent { + subnode-1 { + subnode-2 { + bootph-all; + }; + subnode-3 { + bootph-some-ram; + subnode-4 { + }; + }; + }; + }; + + binman: binman { + }; +}; + diff --git a/tools/binman/test/347_key_name_hint_dir_fit_signature.dts b/tools/binman/test/347_key_name_hint_dir_fit_signature.dts new file mode 100644 index 00000000000..96e2126dadb --- /dev/null +++ b/tools/binman/test/347_key_name_hint_dir_fit_signature.dts @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + fit { + description = "test desc"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + fit,sign; + + images { + u-boot { + description = "test u-boot"; + type = "standalone"; + arch = "arm64"; + os = "u-boot"; + compression = "none"; + load = <0x00000000>; + entry = <0x00000000>; + + u-boot-nodtb { + }; + + hash { + algo = "sha256"; + }; + + signature { + algo = "sha256,rsa2048"; + key-name-hint = "keys/rsa2048"; + }; + }; + @atf-SEQ { + fit,operation = "split-elf"; + description = "test tf-a"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + + hash { + algo = "sha256"; + }; + + signature { + algo = "sha256,rsa2048"; + key-name-hint = "keys/rsa2048"; + }; + }; + @fdt-SEQ { + description = "test fdt"; + type = "flat_dt"; + compression = "none"; + + hash { + algo = "sha256"; + }; + + signature { + algo = "sha256,rsa2048"; + key-name-hint = "keys/rsa2048"; + }; + }; + }; + + configurations { + default = "@conf-uboot-DEFAULT-SEQ"; + @conf-uboot-SEQ { + description = "uboot config"; + fdt = "fdt-SEQ"; + fit,firmware = "u-boot"; + fit,loadables; + + hash { + algo = "sha256"; + }; + + signature { + algo = "sha256,rsa2048"; + key-name-hint = "keys/rsa2048"; + sign-images = "firmware", "loadables", "fdt"; + }; + }; + }; + }; + }; +}; diff --git a/tools/binman/test/348_key_name_hint_dir_spl_pubkey_dtb.dts b/tools/binman/test/348_key_name_hint_dir_spl_pubkey_dtb.dts new file mode 100644 index 00000000000..85ebd58b6c0 --- /dev/null +++ b/tools/binman/test/348_key_name_hint_dir_spl_pubkey_dtb.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot-spl-pubkey-dtb { + algo = "sha384,rsa4096"; + required = "conf"; + key-name-hint = "keys/key"; + }; + }; +}; diff --git a/tools/binman/test/348_renesas_rcar4_sa0.dts b/tools/binman/test/348_renesas_rcar4_sa0.dts new file mode 100644 index 00000000000..4a8717520f2 --- /dev/null +++ b/tools/binman/test/348_renesas_rcar4_sa0.dts @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + renesas-rcar4-sa0 { + filename = "sa0.bin"; + renesas,loader-address = <0x10>; + }; + }; +}; diff --git a/tools/binman/test/349_renesas_rcar4_sa0_size.dts b/tools/binman/test/349_renesas_rcar4_sa0_size.dts new file mode 100644 index 00000000000..eaf4507260b --- /dev/null +++ b/tools/binman/test/349_renesas_rcar4_sa0_size.dts @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + renesas-rcar4-sa0 { + filename = "sa0.bin"; + renesas,loader-address = <0x10>; + + fill { /* Oversize fill to cover size check */ + size = <0x140000>; + fill-byte = [ff]; + }; + }; + }; +}; |