binman: Place Intel descriptor at image start

The Intel descriptor must always appear at the start of an (x86) image,
so it is supposed to position itself there always. However there is no
explicit test for this. Add one and fix a bug introduced by the recent
change to adjust Entry to read the node in a separate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2019-07-20 12:24:01 -06:00
parent 95a0f3c691
commit 27145fd3a8
3 changed files with 34 additions and 1 deletions

View File

@ -47,8 +47,12 @@ class Entry_intel_descriptor(Entry_blob):
def __init__(self, section, etype, node):
Entry_blob.__init__(self, section, etype, node)
self._regions = []
def Pack(self, offset):
"""Put this entry at the start of the image"""
if self.offset is None:
self.offset = self.section.GetStartOffset()
offset = self.section.GetStartOffset()
return Entry_blob.Pack(self, offset)
def GetOffsets(self):
offset = self.data.find(FD_SIGNATURE)

View File

@ -2975,6 +2975,15 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(U_BOOT_DATA, data[2:2 + len(U_BOOT_DATA)])
self.assertEqual(b'a\0', data[-2:])
def testDescriptorOffset(self):
"""Test that the Intel descriptor is always placed at at the start"""
data = self._DoReadFileDtb('141_descriptor_offset.dts')
image = control.images['image']
entries = image.GetEntries()
desc = entries['intel-descriptor']
self.assertEqual(0xff800000, desc.offset);
self.assertEqual(0xff800000, desc.image_pos);
if __name__ == "__main__":
unittest.main()

View File

@ -0,0 +1,20 @@
// SPDX-License-Identifier: GPL-2.0+
/dts-v1/;
/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
sort-by-offset;
end-at-4gb;
size = <0x800000>;
u-boot {
offset = <0xffff0000>;
};
intel-descriptor {
filename = "descriptor.bin";
};
};
};