aboutsummaryrefslogtreecommitdiff
path: root/tools/binman
diff options
context:
space:
mode:
Diffstat (limited to 'tools/binman')
-rw-r--r--tools/binman/etype/files.py4
-rw-r--r--tools/binman/ftest.py8
-rw-r--r--tools/binman/state.py10
-rw-r--r--tools/binman/test/084_files.dts2
-rw-r--r--tools/binman/test/190_files_align.dts12
5 files changed, 35 insertions, 1 deletions
diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py
index ce3832e..1feebd0 100644
--- a/tools/binman/etype/files.py
+++ b/tools/binman/etype/files.py
@@ -22,6 +22,7 @@ class Entry_files(Entry_section):
- files-compress: Compression algorithm to use:
none: No compression
lz4: Use lz4 compression (via 'lz4' command-line utility)
+ - files-align: Align each file to the given alignment
This entry reads a number of files and places each in a separate sub-entry
within this entry. To access these you need to enable device-tree updates
@@ -38,6 +39,7 @@ class Entry_files(Entry_section):
self.Raise("Missing 'pattern' property")
self._files_compress = fdt_util.GetString(self._node, 'files-compress',
'none')
+ self._files_align = fdt_util.GetInt(self._node, 'files-align');
self._require_matches = fdt_util.GetBool(self._node,
'require-matches')
@@ -55,6 +57,8 @@ class Entry_files(Entry_section):
state.AddString(subnode, 'type', 'blob')
state.AddString(subnode, 'filename', fname)
state.AddString(subnode, 'compress', self._files_compress)
+ if self._files_align:
+ state.AddInt(subnode, 'align', self._files_align)
# Read entries again, now that we have some
self._ReadEntries()
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 7f7827b..b31a730 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -4218,6 +4218,14 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(orig_image.GetEntries().keys(),
image.GetEntries().keys())
+ def testFilesAlign(self):
+ """Test alignment with files"""
+ data = self._DoReadFile('190_files_align.dts')
+
+ # The first string is 15 bytes so will align to 16
+ expect = FILES_DATA[:15] + b'\0' + FILES_DATA[15:]
+ self.assertEqual(expect, data)
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 36bc513..bb3e36e 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -314,6 +314,16 @@ def AddString(node, prop, value):
for n in GetUpdateNodes(node):
n.AddString(prop, value)
+def AddInt(node, prop, value):
+ """Add a new string property to affected device trees
+
+ Args:
+ prop_name: Name of property
+ val: Integer value of property
+ """
+ for n in GetUpdateNodes(node):
+ n.AddInt(prop, value)
+
def SetInt(node, prop, value, for_repack=False):
"""Update an integer property in affected device trees with an integer value
diff --git a/tools/binman/test/084_files.dts b/tools/binman/test/084_files.dts
index 83ddb78..8f09afd 100644
--- a/tools/binman/test/084_files.dts
+++ b/tools/binman/test/084_files.dts
@@ -5,7 +5,7 @@
binman {
files {
pattern = "files/*.dat";
- compress = "none";
+ files-compress = "none";
};
};
};
diff --git a/tools/binman/test/190_files_align.dts b/tools/binman/test/190_files_align.dts
new file mode 100644
index 0000000..213ba96
--- /dev/null
+++ b/tools/binman/test/190_files_align.dts
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+ binman {
+ files {
+ pattern = "files/*.dat";
+ files-compress = "none";
+ files-align = <4>;
+ };
+ };
+};