binman: Allow disabling symbol writing
Some boards don't use symbol writing but do access the symbols in SPL. Provide an option to work around this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -831,6 +831,13 @@ write-symbols:
|
|||||||
binman. This is automatic for certain entry types, e.g. `u-boot-spl`. See
|
binman. This is automatic for certain entry types, e.g. `u-boot-spl`. See
|
||||||
binman_syms_ for more information.
|
binman_syms_ for more information.
|
||||||
|
|
||||||
|
no-write-symbols:
|
||||||
|
Disables symbol writing for this entry. This can be used in entry types
|
||||||
|
where symbol writing is automatic. For example, if `u-boot-spl` refers to
|
||||||
|
the `u_boot_any_image_pos` symbol but U-Boot is not available in the image
|
||||||
|
containing SPL, this can be used to disable the writing. Quite likely this
|
||||||
|
indicates a bug in your setup.
|
||||||
|
|
||||||
elf-filename:
|
elf-filename:
|
||||||
Sets the file name of a blob's associated ELF file. For example, if the
|
Sets the file name of a blob's associated ELF file. For example, if the
|
||||||
blob is `zephyr.bin` then the ELF file may be `zephyr.elf`. This allows
|
blob is `zephyr.bin` then the ELF file may be `zephyr.elf`. This allows
|
||||||
|
@@ -158,6 +158,7 @@ class Entry(object):
|
|||||||
self.offset_from_elf = None
|
self.offset_from_elf = None
|
||||||
self.preserve = False
|
self.preserve = False
|
||||||
self.build_done = False
|
self.build_done = False
|
||||||
|
self.no_write_symbols = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def FindEntryClass(etype, expanded):
|
def FindEntryClass(etype, expanded):
|
||||||
@@ -321,6 +322,7 @@ class Entry(object):
|
|||||||
'offset-from-elf')
|
'offset-from-elf')
|
||||||
|
|
||||||
self.preserve = fdt_util.GetBool(self._node, 'preserve')
|
self.preserve = fdt_util.GetBool(self._node, 'preserve')
|
||||||
|
self.no_write_symbols = fdt_util.GetBool(self._node, 'no-write-symbols')
|
||||||
|
|
||||||
def GetDefaultFilename(self):
|
def GetDefaultFilename(self):
|
||||||
return None
|
return None
|
||||||
@@ -695,7 +697,7 @@ class Entry(object):
|
|||||||
Args:
|
Args:
|
||||||
section: Section containing the entry
|
section: Section containing the entry
|
||||||
"""
|
"""
|
||||||
if self.auto_write_symbols:
|
if self.auto_write_symbols and not self.no_write_symbols:
|
||||||
# Check if we are writing symbols into an ELF file
|
# Check if we are writing symbols into an ELF file
|
||||||
is_elf = self.GetDefaultFilename() == self.elf_fname
|
is_elf = self.GetDefaultFilename() == self.elf_fname
|
||||||
elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage(),
|
elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage(),
|
||||||
|
@@ -52,3 +52,8 @@ class Entry_blob_phase(Entry_section):
|
|||||||
|
|
||||||
# Read entries again, now that we have some
|
# Read entries again, now that we have some
|
||||||
self.ReadEntries()
|
self.ReadEntries()
|
||||||
|
|
||||||
|
# Propagate the no-write-symbols property
|
||||||
|
if self.no_write_symbols:
|
||||||
|
for entry in self._entries.values():
|
||||||
|
entry.no_write_symbols = True
|
||||||
|
@@ -1452,7 +1452,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
self.assertEqual(U_BOOT_SPL_NODTB_DATA, data[:len(U_BOOT_SPL_NODTB_DATA)])
|
self.assertEqual(U_BOOT_SPL_NODTB_DATA, data[:len(U_BOOT_SPL_NODTB_DATA)])
|
||||||
|
|
||||||
def checkSymbols(self, dts, base_data, u_boot_offset, entry_args=None,
|
def checkSymbols(self, dts, base_data, u_boot_offset, entry_args=None,
|
||||||
use_expanded=False):
|
use_expanded=False, no_write_symbols=False):
|
||||||
"""Check the image contains the expected symbol values
|
"""Check the image contains the expected symbol values
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1481,9 +1481,14 @@ class TestFunctional(unittest.TestCase):
|
|||||||
sym_values = struct.pack('<LLQLL', elf.BINMAN_SYM_MAGIC_VALUE,
|
sym_values = struct.pack('<LLQLL', elf.BINMAN_SYM_MAGIC_VALUE,
|
||||||
0x00, u_boot_offset + len(U_BOOT_DATA),
|
0x00, u_boot_offset + len(U_BOOT_DATA),
|
||||||
0x10 + u_boot_offset, 0x04)
|
0x10 + u_boot_offset, 0x04)
|
||||||
expected = (sym_values + base_data[24:] +
|
if no_write_symbols:
|
||||||
tools.get_bytes(0xff, 1) + U_BOOT_DATA + sym_values +
|
expected = (base_data +
|
||||||
base_data[24:])
|
tools.get_bytes(0xff, 0x38 - len(base_data)) +
|
||||||
|
U_BOOT_DATA + base_data)
|
||||||
|
else:
|
||||||
|
expected = (sym_values + base_data[24:] +
|
||||||
|
tools.get_bytes(0xff, 1) + U_BOOT_DATA + sym_values +
|
||||||
|
base_data[24:])
|
||||||
self.assertEqual(expected, data)
|
self.assertEqual(expected, data)
|
||||||
|
|
||||||
def testSymbols(self):
|
def testSymbols(self):
|
||||||
@@ -6676,6 +6681,21 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
['fit'])
|
['fit'])
|
||||||
self.assertIn("Node '/fit': Missing tool: 'mkimage'", str(e.exception))
|
self.assertIn("Node '/fit': Missing tool: 'mkimage'", str(e.exception))
|
||||||
|
|
||||||
|
def testSymbolNoWrite(self):
|
||||||
|
"""Test disabling of symbol writing"""
|
||||||
|
self.checkSymbols('282_symbols_disable.dts', U_BOOT_SPL_DATA, 0x1c,
|
||||||
|
no_write_symbols=True)
|
||||||
|
|
||||||
|
def testSymbolNoWriteExpanded(self):
|
||||||
|
"""Test disabling of symbol writing in expanded entries"""
|
||||||
|
entry_args = {
|
||||||
|
'spl-dtb': '1',
|
||||||
|
}
|
||||||
|
self.checkSymbols('282_symbols_disable.dts', U_BOOT_SPL_NODTB_DATA +
|
||||||
|
U_BOOT_SPL_DTB_DATA, 0x38,
|
||||||
|
entry_args=entry_args, use_expanded=True,
|
||||||
|
no_write_symbols=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
25
tools/binman/test/282_symbols_disable.dts
Normal file
25
tools/binman/test/282_symbols_disable.dts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
binman {
|
||||||
|
pad-byte = <0xff>;
|
||||||
|
u-boot-spl {
|
||||||
|
no-write-symbols;
|
||||||
|
};
|
||||||
|
|
||||||
|
u-boot {
|
||||||
|
offset = <0x38>;
|
||||||
|
no-expanded;
|
||||||
|
};
|
||||||
|
|
||||||
|
u-boot-spl2 {
|
||||||
|
type = "u-boot-spl";
|
||||||
|
no-write-symbols;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
Reference in New Issue
Block a user