diff options
Diffstat (limited to 'tools/binman')
-rw-r--r-- | tools/binman/README.entries | 33 | ||||
-rwxr-xr-x | tools/binman/binman.py | 2 | ||||
-rwxr-xr-x | tools/binman/cbfs_util_test.py | 2 | ||||
-rw-r--r-- | tools/binman/elf.py | 4 | ||||
-rw-r--r-- | tools/binman/entry.py | 25 | ||||
-rw-r--r-- | tools/binman/entry_test.py | 15 | ||||
-rw-r--r-- | tools/binman/etype/intel_fit.py | 2 | ||||
-rw-r--r-- | tools/binman/etype/intel_fsp_m.py | 2 | ||||
-rw-r--r-- | tools/binman/etype/intel_fsp_s.py | 27 | ||||
-rw-r--r-- | tools/binman/etype/intel_fsp_t.py | 26 | ||||
-rw-r--r-- | tools/binman/ftest.py | 29 | ||||
-rw-r--r-- | tools/binman/test/153_intel_fsp_s.dts | 14 | ||||
-rw-r--r-- | tools/binman/test/154_intel_fsp_t.dts | 14 | ||||
-rw-r--r-- | tools/binman/test/u_boot_binman_syms.lds | 2 |
14 files changed, 151 insertions, 46 deletions
diff --git a/tools/binman/README.entries b/tools/binman/README.entries index bce2244596..1099433521 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -444,6 +444,39 @@ See README.x86 for information about x86 binary blobs. +Entry: intel-fsp-s: Entry containing Intel Firmware Support Package (FSP) silicon init +-------------------------------------------------------------------------------------- + +Properties / Entry arguments: + - filename: Filename of file to read into entry + +This file contains a binary blob which is used on some devices to set up +the silicon. U-Boot executes this code in U-Boot proper after SDRAM is +running, so that it can make full use of memory. Documentation is typically +not available in sufficient detail to allow U-Boot do this this itself. + +An example filename is 'fsp_s.bin' + +See README.x86 for information about x86 binary blobs. + + + +Entry: intel-fsp-t: Entry containing Intel Firmware Support Package (FSP) temp ram init +--------------------------------------------------------------------------------------- + +Properties / Entry arguments: + - filename: Filename of file to read into entry + +This file contains a binary blob which is used on some devices to set up +temporary memory (Cache-as-RAM or CAR). U-Boot executes this code in TPL so +that it has access to memory for its stack and initial storage. + +An example filename is 'fsp_t.bin' + +See README.x86 for information about x86 binary blobs. + + + Entry: intel-ifwi: Entry containing an Intel Integrated Firmware Image (IFWI) file ---------------------------------------------------------------------------------- diff --git a/tools/binman/binman.py b/tools/binman/binman.py index 8bd5868df2..9e6fd72117 100755 --- a/tools/binman/binman.py +++ b/tools/binman/binman.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2016 Google, Inc diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py index 772c794ece..ddc2e09e35 100755 --- a/tools/binman/cbfs_util_test.py +++ b/tools/binman/cbfs_util_test.py @@ -56,7 +56,7 @@ class TestCbfs(unittest.TestCase): cls.have_lz4 = True try: tools.Run('lz4', '--no-frame-crc', '-c', - tools.GetInputFilename('u-boot.bin')) + tools.GetInputFilename('u-boot.bin'), binary=True) except: cls.have_lz4 = False diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 7bc7cf61b5..0c1a5b44b6 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -135,9 +135,7 @@ def LookupAndWriteSymbols(elf_fname, entry, section): # Look up the symbol in our entry tables. value = section.LookupSymbol(name, sym.weak, msg) - if value is not None: - value += base.address - else: + if value is None: value = -1 pack_string = pack_string.lower() value_bytes = struct.pack(pack_string, value) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 409c0dca93..b6f1b2c93f 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -7,16 +7,7 @@ from __future__ import print_function from collections import namedtuple - -# importlib was introduced in Python 2.7 but there was a report of it not -# working in 2.7.12, so we work around this: -# http://lists.denx.de/pipermail/u-boot/2016-October/269729.html -try: - import importlib - have_importlib = True -except: - have_importlib = False - +import importlib import os import sys @@ -56,6 +47,8 @@ class Entry(object): offset: Offset of entry within the section, None if not known yet (in which case it will be calculated by Pack()) size: Entry size in bytes, None if not known + pre_reset_size: size as it was before ResetForPack(). This allows us to + keep track of the size we started with and detect size changes uncomp_size: Size of uncompressed data in bytes, if the entry is compressed, else None contents_size: Size of contents in bytes, 0 by default @@ -80,6 +73,7 @@ class Entry(object): self.name = node and (name_prefix + node.name) or 'none' self.offset = None self.size = None + self.pre_reset_size = None self.uncomp_size = None self.data = None self.contents_size = 0 @@ -119,10 +113,7 @@ class Entry(object): old_path = sys.path sys.path.insert(0, os.path.join(our_path, 'etype')) try: - if have_importlib: - module = importlib.import_module(module_name) - else: - module = __import__(module_name) + module = importlib.import_module(module_name) except ImportError as e: raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" % (etype, node_path, module_name, e)) @@ -326,6 +317,7 @@ class Entry(object): self.Detail('ResetForPack: offset %s->%s, size %s->%s' % (ToHex(self.offset), ToHex(self.orig_offset), ToHex(self.size), ToHex(self.orig_size))) + self.pre_reset_size = self.size self.offset = self.orig_offset self.size = self.orig_size @@ -769,7 +761,10 @@ features to produce new behaviours. True if the data did not result in a resize of this entry, False if the entry must be resized """ - self.contents_size = self.size + if self.size is not None: + self.contents_size = self.size + else: + self.contents_size = self.pre_reset_size ok = self.ProcessContentsUpdate(data) self.Detail('WriteData: size=%x, ok=%s' % (len(data), ok)) section_ok = self.section.WriteChildData(self) diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py index 13f5864516..277e10b585 100644 --- a/tools/binman/entry_test.py +++ b/tools/binman/entry_test.py @@ -39,21 +39,6 @@ class TestEntry(unittest.TestCase): else: import entry - def test1EntryNoImportLib(self): - """Test that we can import Entry subclassess successfully""" - sys.modules['importlib'] = None - global entry - self._ReloadEntry() - entry.Entry.Create(None, self.GetNode(), 'u-boot') - self.assertFalse(entry.have_importlib) - - def test2EntryImportLib(self): - del sys.modules['importlib'] - global entry - self._ReloadEntry() - entry.Entry.Create(None, self.GetNode(), 'u-boot-spl') - self.assertTrue(entry.have_importlib) - def testEntryContents(self): """Test the Entry bass class""" import entry diff --git a/tools/binman/etype/intel_fit.py b/tools/binman/etype/intel_fit.py index 23606d27d0..2a34a05f95 100644 --- a/tools/binman/etype/intel_fit.py +++ b/tools/binman/etype/intel_fit.py @@ -27,6 +27,6 @@ class Entry_intel_fit(Entry_blob): self.align = 16 def ObtainContents(self): - data = struct.pack('<8sIHBB', '_FIT_ ', 1, 0x100, 0x80, 0x7d) + data = struct.pack('<8sIHBB', b'_FIT_ ', 1, 0x100, 0x80, 0x7d) self.SetContents(data) return True diff --git a/tools/binman/etype/intel_fsp_m.py b/tools/binman/etype/intel_fsp_m.py index 2d6b2b6621..bb1de73e41 100644 --- a/tools/binman/etype/intel_fsp_m.py +++ b/tools/binman/etype/intel_fsp_m.py @@ -2,7 +2,7 @@ # Copyright 2019 Google LLC # Written by Simon Glass <sjg@chromium.org> # -# Entry-type module for Intel Firmware Support Package binary blob (T section) +# Entry-type module for Intel Firmware Support Package binary blob (M section) # from entry import Entry diff --git a/tools/binman/etype/intel_fsp_s.py b/tools/binman/etype/intel_fsp_s.py new file mode 100644 index 0000000000..3d6900d1fb --- /dev/null +++ b/tools/binman/etype/intel_fsp_s.py @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2019 Google LLC +# Written by Simon Glass <sjg@chromium.org> +# +# Entry-type module for Intel Firmware Support Package binary blob (S section) +# + +from entry import Entry +from blob import Entry_blob + +class Entry_intel_fsp_s(Entry_blob): + """Entry containing Intel Firmware Support Package (FSP) silicon init + + Properties / Entry arguments: + - filename: Filename of file to read into entry + + This file contains a binary blob which is used on some devices to set up + the silicon. U-Boot executes this code in U-Boot proper after SDRAM is + running, so that it can make full use of memory. Documentation is typically + not available in sufficient detail to allow U-Boot do this this itself. + + An example filename is 'fsp_s.bin' + + See README.x86 for information about x86 binary blobs. + """ + def __init__(self, section, etype, node): + Entry_blob.__init__(self, section, etype, node) diff --git a/tools/binman/etype/intel_fsp_t.py b/tools/binman/etype/intel_fsp_t.py new file mode 100644 index 0000000000..813a81f2e6 --- /dev/null +++ b/tools/binman/etype/intel_fsp_t.py @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2019 Google LLC +# Written by Simon Glass <sjg@chromium.org> +# +# Entry-type module for Intel Firmware Support Package binary blob (T section) +# + +from entry import Entry +from blob import Entry_blob + +class Entry_intel_fsp_t(Entry_blob): + """Entry containing Intel Firmware Support Package (FSP) temp ram init + + Properties / Entry arguments: + - filename: Filename of file to read into entry + + This file contains a binary blob which is used on some devices to set up + temporary memory (Cache-as-RAM or CAR). U-Boot executes this code in TPL so + that it has access to memory for its stack and initial storage. + + An example filename is 'fsp_t.bin' + + See README.x86 for information about x86 binary blobs. + """ + def __init__(self, section, etype, node): + Entry_blob.__init__(self, section, etype, node) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 7000de9d42..80df0e3ca9 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -73,6 +73,8 @@ FILES_DATA = (b"sorry I'm late\nOh, don't bother apologising, I'm " + COMPRESS_DATA = b'compress xxxxxxxxxxxxxxxxxxxxxx data' REFCODE_DATA = b'refcode' FSP_M_DATA = b'fsp_m' +FSP_S_DATA = b'fsp_s' +FSP_T_DATA = b'fsp_t' # The expected size for the device tree in some tests EXTRACT_DTB_SIZE = 0x3c9 @@ -149,6 +151,8 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('bmpblk.bin', BMPBLK_DATA) TestFunctional._MakeInputFile('refcode.bin', REFCODE_DATA) TestFunctional._MakeInputFile('fsp_m.bin', FSP_M_DATA) + TestFunctional._MakeInputFile('fsp_s.bin', FSP_S_DATA) + TestFunctional._MakeInputFile('fsp_t.bin', FSP_T_DATA) cls._elf_testdir = os.path.join(cls._indir, 'elftest') elf_test.BuildElfTestFiles(cls._elf_testdir) @@ -170,7 +174,7 @@ class TestFunctional(unittest.TestCase): cls.have_lz4 = True try: tools.Run('lz4', '--no-frame-crc', '-c', - os.path.join(cls._indir, 'u-boot.bin')) + os.path.join(cls._indir, 'u-boot.bin'), binary=True) except: cls.have_lz4 = False @@ -2109,7 +2113,7 @@ class TestFunctional(unittest.TestCase): data = self.data = self._DoReadFileRealDtb('115_fdtmap.dts') fdtmap_data = data[len(U_BOOT_DATA):] magic = fdtmap_data[:8] - self.assertEqual('_FDTMAP_', magic) + self.assertEqual(b'_FDTMAP_', magic) self.assertEqual(tools.GetBytes(0, 8), fdtmap_data[8:16]) fdt_data = fdtmap_data[16:] @@ -2152,7 +2156,7 @@ class TestFunctional(unittest.TestCase): dtb = fdt.Fdt.FromData(fdt_data) fdt_size = dtb.GetFdtObj().totalsize() hdr_data = data[-8:] - self.assertEqual('BinM', hdr_data[:4]) + self.assertEqual(b'BinM', hdr_data[:4]) offset = struct.unpack('<I', hdr_data[4:])[0] & 0xffffffff self.assertEqual(fdtmap_pos - 0x400, offset - (1 << 32)) @@ -2161,7 +2165,7 @@ class TestFunctional(unittest.TestCase): data = self.data = self._DoReadFileRealDtb('117_fdtmap_hdr_start.dts') fdtmap_pos = 0x100 + len(U_BOOT_DATA) hdr_data = data[:8] - self.assertEqual('BinM', hdr_data[:4]) + self.assertEqual(b'BinM', hdr_data[:4]) offset = struct.unpack('<I', hdr_data[4:])[0] self.assertEqual(fdtmap_pos, offset) @@ -2170,7 +2174,7 @@ class TestFunctional(unittest.TestCase): data = self.data = self._DoReadFileRealDtb('118_fdtmap_hdr_pos.dts') fdtmap_pos = 0x100 + len(U_BOOT_DATA) hdr_data = data[0x80:0x88] - self.assertEqual('BinM', hdr_data[:4]) + self.assertEqual(b'BinM', hdr_data[:4]) offset = struct.unpack('<I', hdr_data[4:])[0] self.assertEqual(fdtmap_pos, offset) @@ -2431,9 +2435,9 @@ class TestFunctional(unittest.TestCase): ' section 100 %x section 100' % section_size, ' cbfs 100 400 cbfs 0', ' u-boot 138 4 u-boot 38', -' u-boot-dtb 180 10f u-boot-dtb 80 3c9', +' u-boot-dtb 180 105 u-boot-dtb 80 3c9', ' u-boot-dtb 500 %x u-boot-dtb 400 3c9' % fdt_size, -' fdtmap %x 3b4 fdtmap %x' % +' fdtmap %x 3bd fdtmap %x' % (fdtmap_offset, fdtmap_offset), ' image-header bf8 8 image-header bf8', ] @@ -2518,7 +2522,7 @@ class TestFunctional(unittest.TestCase): data = self._RunExtractCmd('section') cbfs_data = data[:0x400] cbfs = cbfs_util.CbfsReader(cbfs_data) - self.assertEqual(['u-boot', 'u-boot-dtb', ''], cbfs.files.keys()) + self.assertEqual(['u-boot', 'u-boot-dtb', ''], list(cbfs.files.keys())) dtb_data = data[0x400:] dtb = self._decompress(dtb_data) self.assertEqual(EXTRACT_DTB_SIZE, len(dtb)) @@ -3332,6 +3336,15 @@ class TestFunctional(unittest.TestCase): data = self._DoReadFile('152_intel_fsp_m.dts') self.assertEqual(FSP_M_DATA, data[:len(FSP_M_DATA)]) + def testPackFspS(self): + """Test that an image with a FSP silicon-init binary can be created""" + data = self._DoReadFile('153_intel_fsp_s.dts') + self.assertEqual(FSP_S_DATA, data[:len(FSP_S_DATA)]) + + def testPackFspT(self): + """Test that an image with a FSP temp-ram-init binary can be created""" + data = self._DoReadFile('154_intel_fsp_t.dts') + self.assertEqual(FSP_T_DATA, data[:len(FSP_T_DATA)]) if __name__ == "__main__": diff --git a/tools/binman/test/153_intel_fsp_s.dts b/tools/binman/test/153_intel_fsp_s.dts new file mode 100644 index 0000000000..579618a8fa --- /dev/null +++ b/tools/binman/test/153_intel_fsp_s.dts @@ -0,0 +1,14 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + intel-fsp-s { + filename = "fsp_s.bin"; + }; + }; +}; diff --git a/tools/binman/test/154_intel_fsp_t.dts b/tools/binman/test/154_intel_fsp_t.dts new file mode 100644 index 0000000000..8da749c157 --- /dev/null +++ b/tools/binman/test/154_intel_fsp_t.dts @@ -0,0 +1,14 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + intel-fsp-t { + filename = "fsp_t.bin"; + }; + }; +}; diff --git a/tools/binman/test/u_boot_binman_syms.lds b/tools/binman/test/u_boot_binman_syms.lds index 926df873cb..825fc3f649 100644 --- a/tools/binman/test/u_boot_binman_syms.lds +++ b/tools/binman/test/u_boot_binman_syms.lds @@ -9,7 +9,7 @@ ENTRY(_start) SECTIONS { - . = 0x00000000; + . = 0x00000010; _start = .; . = ALIGN(4); |