[U-Boot] [PATCH 01/12] binman: Allow unit addresses for binaries
Simon Glass
sjg at chromium.org
Wed May 16 01:52:47 UTC 2018
Allow the same binary to appear multiple times in an image by using the
device-tree unit-address feature (u-boot at 0, u-boot at 1).
Signed-off-by: Simon Glass <sjg at chromium.org>
---
tools/binman/README | 4 ++++
tools/binman/etype/entry.py | 5 +++++
tools/binman/ftest.py | 5 +++++
tools/binman/test/54_unit_address.dts | 13 +++++++++++++
4 files changed, 27 insertions(+)
create mode 100644 tools/binman/test/54_unit_address.dts
diff --git a/tools/binman/README b/tools/binman/README
index b20098177ee..196dda1fb4c 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -387,6 +387,10 @@ end-at-4gb:
Examples of the above options can be found in the tests. See the
tools/binman/test directory.
+It is possible to have the same binary appear multiple times in the image,
+either by using a unit number suffix (u-boot at 0, u-boot at 1) or by using a
+different name for each and specifying the type with the 'type' attribute.
+
Special properties
------------------
diff --git a/tools/binman/etype/entry.py b/tools/binman/etype/entry.py
index c331312c491..23e436a2e9d 100644
--- a/tools/binman/etype/entry.py
+++ b/tools/binman/etype/entry.py
@@ -72,7 +72,12 @@ class Entry(object):
"""
if not etype:
etype = fdt_util.GetString(node, 'type', node.name)
+
+ # Convert something like 'u-boot at 0' to 'u_boot' since we are only
+ # interested in the type.
module_name = etype.replace('-', '_')
+ if '@' in module_name:
+ module_name = module_name.split('@')[0]
module = modules.get(module_name)
# Import the module if we have not already done so.
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a3abbc4b84b..b5e8736fbb5 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -909,6 +909,11 @@ class TestFunctional(unittest.TestCase):
sym_values + U_BOOT_SPL_DATA[16:])
self.assertEqual(expected, data)
+ def testPackUnitAddress(self):
+ """Test that we support multiple binaries with the same name"""
+ data = self._DoReadFile('54_unit_address.dts')
+ self.assertEqual(U_BOOT_DATA + U_BOOT_DATA, data)
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/test/54_unit_address.dts b/tools/binman/test/54_unit_address.dts
new file mode 100644
index 00000000000..81cb63e98f8
--- /dev/null
+++ b/tools/binman/test/54_unit_address.dts
@@ -0,0 +1,13 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ u-boot at 0 {
+ };
+ u-boot at 1 {
+ };
+ };
+};
--
2.17.0.441.gb46fe60e1d-goog
More information about the U-Boot
mailing list