From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: u-boot@lists.denx.de
Cc: Heiko Thiery <heiko.thiery@gmail.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Simon Glass <sjg@chromium.org>,
Alper Nebi Yasak <alpernebiyasak@gmail.com>
Subject: [PATCH v2 1/5] binman: Fix subentry expansion for FIT entry type
Date: Tue, 8 Feb 2022 01:08:04 +0300 [thread overview]
Message-ID: <20220207220809.4497-2-alpernebiyasak@gmail.com> (raw)
In-Reply-To: <20220207220809.4497-1-alpernebiyasak@gmail.com>
Binman tries to expand some entries into parts that make it up, e.g.
'u-boot' into a 'u-boot-expanded' section that contains 'u-boot-nodtb'
and 'u-boot-dtb'. Entries with child entries must call ExpandEntries()
on them to build a correct image, as it's possible that unexpanded child
entries have no data of their own. The FIT entry type doesn't currently
do this, which means putting a "u-boot" entry inside it doesn't work as
expected.
Implement ExpandEntries() for FIT and add a copy of a simple FIT image
test that checks subentry expansion in FIT entries.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
---
Changes in v2:
- Split reused testSimpleFit code into a helper function
tools/binman/etype/fit.py | 5 +++++
tools/binman/ftest.py | 33 ++++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 6ad4a686df55..38bc2a2d784e 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -237,6 +237,11 @@ def _AddNode(base_node, depth, node):
self._fdt = Fdt.FromData(fdt.as_bytearray())
self._fdt.Scan()
+ def ExpandEntries(self):
+ super().ExpandEntries()
+ for section in self._fit_sections.values():
+ section.ExpandEntries()
+
def ObtainContents(self):
"""Obtain the contents of the FIT
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 5400f76c676a..626df786c8c9 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -61,6 +61,9 @@
U_BOOT_NODTB_DATA = b'nodtb with microcode pointer somewhere in here'
U_BOOT_SPL_NODTB_DATA = b'splnodtb with microcode pointer somewhere in here'
U_BOOT_TPL_NODTB_DATA = b'tplnodtb with microcode pointer somewhere in here'
+U_BOOT_EXP_DATA = U_BOOT_NODTB_DATA + U_BOOT_DTB_DATA
+U_BOOT_SPL_EXP_DATA = U_BOOT_SPL_NODTB_DATA + U_BOOT_SPL_DTB_DATA
+U_BOOT_TPL_EXP_DATA = U_BOOT_TPL_NODTB_DATA + U_BOOT_TPL_DTB_DATA
FSP_DATA = b'fsp'
CMC_DATA = b'cmc'
VBT_DATA = b'vbt'
@@ -3713,13 +3716,7 @@ def testPackOverlap(self):
"""Test that zero-size overlapping regions are ignored"""
self._DoTestFile('160_pack_overlap_zero.dts')
- def testSimpleFit(self):
- """Test an image with a FIT inside"""
- data = self._DoReadFile('161_fit.dts')
- self.assertEqual(U_BOOT_DATA, data[:len(U_BOOT_DATA)])
- self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):])
- fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)]
-
+ def _CheckSimpleFitData(self, fit_data, kernel_data, fdt1_data):
# The data should be inside the FIT
dtb = fdt.Fdt.FromData(fit_data)
dtb.Scan()
@@ -3752,8 +3749,26 @@ def testSimpleFit(self):
self.assertIsNotNone(data_sizes)
self.assertEqual(2, len(data_sizes))
# Format is "4 Bytes = 0.00 KiB = 0.00 MiB" so take the first word
- self.assertEqual(len(U_BOOT_DATA), int(data_sizes[0].split()[0]))
- self.assertEqual(len(U_BOOT_SPL_DTB_DATA), int(data_sizes[1].split()[0]))
+ self.assertEqual(len(kernel_data), int(data_sizes[0].split()[0]))
+ self.assertEqual(len(fdt1_data), int(data_sizes[1].split()[0]))
+
+ def testSimpleFit(self):
+ """Test an image with a FIT inside"""
+ data = self._DoReadFile('161_fit.dts')
+ self.assertEqual(U_BOOT_DATA, data[:len(U_BOOT_DATA)])
+ self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):])
+ fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)]
+
+ self._CheckSimpleFitData(fit_data, U_BOOT_DATA, U_BOOT_SPL_DTB_DATA)
+
+ def testSimpleFitExpandsSubentries(self):
+ """Test that FIT images expand their subentries"""
+ data = self._DoReadFileDtb('161_fit.dts', use_expanded=True)[0]
+ self.assertEqual(U_BOOT_EXP_DATA, data[:len(U_BOOT_EXP_DATA)])
+ self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):])
+ fit_data = data[len(U_BOOT_EXP_DATA):-len(U_BOOT_NODTB_DATA)]
+
+ self._CheckSimpleFitData(fit_data, U_BOOT_EXP_DATA, U_BOOT_SPL_DTB_DATA)
def testFitExternal(self):
"""Test an image with an FIT with external images"""
--
2.34.1
next prev parent reply other threads:[~2022-02-07 22:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-07 22:08 [PATCH v2 0/5] binman: Improvements to FIT entry type Alper Nebi Yasak
2022-02-07 22:08 ` Alper Nebi Yasak [this message]
2022-02-08 15:05 ` [PATCH v2 1/5] binman: Fix subentry expansion for " Simon Glass
2022-02-08 20:39 ` Simon Glass
2022-02-07 22:08 ` [PATCH v2 2/5] binman: Register and check bintools from FIT subentries Alper Nebi Yasak
2022-02-08 20:39 ` Simon Glass
2022-02-07 22:08 ` [PATCH v2 3/5] binman: Check missing bintools of Section subclasses Alper Nebi Yasak
2022-02-08 20:39 ` Simon Glass
2022-02-07 22:08 ` [PATCH v2 4/5] binman: Convert FIT entry type to a subclass of Section entry type Alper Nebi Yasak
2022-02-08 20:39 ` Simon Glass
2022-02-14 9:09 ` Jan Kiszka
2022-02-15 12:27 ` Alper Nebi Yasak
2022-02-15 16:50 ` Jan Kiszka
2022-02-15 17:06 ` Jan Kiszka
2022-02-18 16:50 ` Jan Kiszka
2022-02-18 17:34 ` Alper Nebi Yasak
2022-02-19 15:53 ` Simon Glass
2022-02-21 4:40 ` Simon Glass
2022-02-22 18:58 ` Alper Nebi Yasak
2022-02-23 22:59 ` Simon Glass
2022-02-28 11:48 ` Jan Kiszka
2022-02-28 13:51 ` Alper Nebi Yasak
2022-02-28 13:56 ` Simon Glass
2022-02-28 14:14 ` Jan Kiszka
2022-02-07 22:08 ` [PATCH v2 5/5] binman: Update image positions of FIT subentries Alper Nebi Yasak
2022-02-08 20:43 ` Simon Glass
2022-02-23 2:35 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220207220809.4497-2-alpernebiyasak@gmail.com \
--to=alpernebiyasak@gmail.com \
--cc=heiko.thiery@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox