[U-Boot] [PATCH v3 3/8] binman: Add a new "skip-at-start" property in Section class

Jagdish Gediya jagdish.gediya at nxp.com
Mon Sep 3 16:05:07 UTC 2018


Currently binman calculates '_skip_at_start' based on 'end-at-4gb'
property and it is used for x86 images.

For PowerPC mpc85xx based CPU, CONFIG_SYS_TEXT_BASE is the entry
offset of the first entry. It can be 0xeff40000 or 0xfff40000 for
nor flash boot, 0x201000 for sd boot etc, so "_skip_at_start"
should be set to CONFIG_SYS_TEXT_BASE.

'end-at-4gb' property is not applicable where CONFIG_SYS_TEXT_BASE +
Image size != 4gb.

Add new property 'skip-at-start' in Section class so that
'_skip_at_start' can be calculated either based on 'end-at-4gb'
or based on "skip-at-start".

Add a test case to check that 'skip-at-start' and 'end-at-4gb'
property can't be used together.

Signed-off-by: Jagdish Gediya <jagdish.gediya at nxp.com>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---
Changes for v2:
	- Renamed 'start-pos' property to 'skip-at-start'
	- Updated README

Changes for v3:
	- Modification as per Simon Glass's comments
	- Added test case for 'skip-at-start' property

 tools/binman/README                                 |  9 +++++++++
 tools/binman/bsection.py                            | 15 +++++++++++----
 tools/binman/ftest.py                               |  8 ++++++++
 .../test/80_4gb_and_skip_at_start_together.dts      | 21 +++++++++++++++++++++
 4 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 tools/binman/test/80_4gb_and_skip_at_start_together.dts

diff --git a/tools/binman/README b/tools/binman/README
index cb34171..7cd33d4 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -397,6 +397,15 @@ end-at-4gb:
 	8MB ROM, the offset of the first entry would be 0xfff80000 with
 	this option, instead of 0 without this option.
 
+skip-at-start:
+	This property specifies the entry offset of the first entry.
+
+	For PowerPC mpc85xx based CPU, CONFIG_SYS_TEXT_BASE is the entry
+	offset of the first entry. It can be 0xeff40000 or 0xfff40000 for
+	nor flash boot, 0x201000 for sd boot etc.
+
+	'end-at-4gb' property is not applicable where CONFIG_SYS_TEXT_BASE +
+	Image size != 4gb.
 
 Examples of the above options can be found in the tests. See the
 tools/binman/test directory.
diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index a0bd1b6..5910092 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -59,7 +59,7 @@ class Section(object):
         self._pad_after = 0
         self._pad_byte = 0
         self._sort = False
-        self._skip_at_start = 0
+        self._skip_at_start = None
         self._end_4gb = False
         self._name_prefix = ''
         self._entries = OrderedDict()
@@ -79,10 +79,17 @@ class Section(object):
         self._pad_byte = fdt_util.GetInt(self._node, 'pad-byte', 0)
         self._sort = fdt_util.GetBool(self._node, 'sort-by-offset')
         self._end_4gb = fdt_util.GetBool(self._node, 'end-at-4gb')
-        if self._end_4gb and not self._size:
-            self._Raise("Section size must be provided when using end-at-4gb")
+        self._skip_at_start = fdt_util.GetInt(self._node, 'skip-at-start')
         if self._end_4gb:
-            self._skip_at_start = 0x100000000 - self._size
+            if not self._size:
+                self._Raise("Section size must be provided when using end-at-4gb")
+            if self._skip_at_start is not None:
+                self._Raise("Provide either 'end-at-4gb' or 'skip-at-start'")
+            else:
+                self._skip_at_start = 0x100000000 - self._size
+        else:
+            if self._skip_at_start is None:
+                self._skip_at_start = 0
         self._name_prefix = fdt_util.GetString(self._node, 'name-prefix')
 
     def _ReadEntries(self):
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a8456c2..36519a2 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -711,6 +711,14 @@ class TestFunctional(unittest.TestCase):
         self.assertIn("Section '/binman': Section size must be provided when "
                       "using end-at-4gb", str(e.exception))
 
+    def test4gbAndSkipAtStartTogether(self):
+        """Test that the end-at-4gb and skip-at-size property can't be used
+        together"""
+        with self.assertRaises(ValueError) as e:
+            self._DoTestFile('80_4gb_and_skip_at_start_together.dts')
+        self.assertIn("Section '/binman': Provide either 'end-at-4gb' or "
+                      "'skip-at-start'", str(e.exception))
+
     def testPackX86RomOutside(self):
         """Test that the end-at-4gb property checks for offset boundaries"""
         with self.assertRaises(ValueError) as e:
diff --git a/tools/binman/test/80_4gb_and_skip_at_start_together.dts b/tools/binman/test/80_4gb_and_skip_at_start_together.dts
new file mode 100644
index 0000000..90c467d
--- /dev/null
+++ b/tools/binman/test/80_4gb_and_skip_at_start_together.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <32>;
+		sort-by-offset;
+		end-at-4gb;
+		skip-at-start = <0xffffffe0>;
+		u-boot {
+			offset = <0xffffffe0>;
+		};
+	};
+};
-- 
2.7.4



More information about the U-Boot mailing list