mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
binman: Add a null entry
It is sometimes useful to define an entry which does not have its own contents but does appear in the image. The contents are set by the section which contains it, even though it appears as an entry in the fdtmap. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4331d66661
commit
62ef2f7bf3
6 changed files with 71 additions and 2 deletions
|
@ -1278,6 +1278,19 @@ This will pass in u-boot-spl as the input data and the .cfgout file as the
|
|||
|
||||
|
||||
|
||||
.. _etype_null:
|
||||
|
||||
Entry: null: An entry which has no contents of its own
|
||||
------------------------------------------------------
|
||||
|
||||
Note that the size property must be set since otherwise this entry does not
|
||||
know how large it should be.
|
||||
|
||||
The contents are set by the containing section, e.g. the section's pad
|
||||
byte.
|
||||
|
||||
|
||||
|
||||
.. _etype_opensbi:
|
||||
|
||||
Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
|
||||
|
|
|
@ -454,7 +454,7 @@ class Entry(object):
|
|||
|
||||
Returns:
|
||||
True if the contents were found, False if another call is needed
|
||||
after the other entries are processed.
|
||||
after the other entries are processed, None if there is no contents
|
||||
"""
|
||||
# No contents by default: subclasses can implement this
|
||||
return True
|
||||
|
@ -583,7 +583,8 @@ class Entry(object):
|
|||
Returns:
|
||||
bytes content of the entry, excluding any padding. If the entry is
|
||||
compressed, the compressed data is returned. If the entry data
|
||||
is not yet available, False can be returned
|
||||
is not yet available, False can be returned. If the entry data
|
||||
is null, then None is returned.
|
||||
"""
|
||||
self.Detail('GetData: size %s' % to_hex_size(self.data))
|
||||
return self.data
|
||||
|
|
25
tools/binman/etype/null.py
Normal file
25
tools/binman/etype/null.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# SPDX-License-Identifier: GPL-2.0+
|
||||
# Copyright 2023 Google LLC
|
||||
# Written by Simon Glass <sjg@chromium.org>
|
||||
#
|
||||
|
||||
from binman.entry import Entry
|
||||
from dtoc import fdt_util
|
||||
from patman import tools
|
||||
|
||||
class Entry_null(Entry):
|
||||
"""An entry which has no contents of its own
|
||||
|
||||
Note that the size property must be set since otherwise this entry does not
|
||||
know how large it should be.
|
||||
|
||||
The contents are set by the containing section, e.g. the section's pad
|
||||
byte.
|
||||
"""
|
||||
def __init__(self, section, etype, node):
|
||||
super().__init__(section, etype, node)
|
||||
self.required_props = ['size']
|
||||
|
||||
def ObtainContents(self):
|
||||
# null contents
|
||||
return None
|
|
@ -320,6 +320,12 @@ class Entry_section(Entry):
|
|||
# earlier in the image description. See testCollectionSection().
|
||||
if not required and entry_data is None:
|
||||
return None
|
||||
|
||||
if entry_data is None:
|
||||
pad_byte = (entry._pad_byte if isinstance(entry, Entry_section)
|
||||
else self._pad_byte)
|
||||
entry_data = tools.get_bytes(self._pad_byte, entry.size)
|
||||
|
||||
data = self.GetPaddedDataForEntry(entry, entry_data)
|
||||
# Handle empty space before the entry
|
||||
pad = (entry.offset or 0) - self._skip_at_start - len(section_data)
|
||||
|
|
|
@ -6194,6 +6194,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||
expected = U_BOOT_DATA + tools.get_bytes(0, 12)
|
||||
self.assertEqual(expected, data)
|
||||
|
||||
def testNull(self):
|
||||
"""Test an image with a null entry"""
|
||||
data = self._DoReadFile('268_null.dts')
|
||||
self.assertEqual(U_BOOT_DATA + b'\xff\xff\xff\xff' + U_BOOT_IMG_DATA, data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
19
tools/binman/test/268_null.dts
Normal file
19
tools/binman/test/268_null.dts
Normal file
|
@ -0,0 +1,19 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
binman {
|
||||
pad-byte = <0xff>;
|
||||
u-boot {
|
||||
};
|
||||
null {
|
||||
size = <4>;
|
||||
};
|
||||
u-boot-img {
|
||||
};
|
||||
};
|
||||
};
|
Loading…
Reference in a new issue