summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-08 23:25:42 +0300
committerSimon Glass <sjg@chromium.org>2019-07-24 22:54:08 +0300
commit8a1ad068deef6228fd501992bdb347ecad9da067 (patch)
tree3ed2dee476c0732ea17f750c024ea6a26ff140b2
parent69f7cb31a083c697ef0a4180a30219d2258b3662 (diff)
downloadu-boot-8a1ad068deef6228fd501992bdb347ecad9da067.tar.xz
binman: Detect bad CBFS file types
Detect when an unknown or unsupported file type is specified and report an error. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/binman/etype/cbfs.py3
-rw-r--r--tools/binman/ftest.py6
-rw-r--r--tools/binman/test/126_cbfs_bad_type.dts17
3 files changed, 26 insertions, 0 deletions
diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py
index a46bb98a03..175ecae158 100644
--- a/tools/binman/etype/cbfs.py
+++ b/tools/binman/etype/cbfs.py
@@ -190,6 +190,9 @@ class Entry_cbfs(Entry):
elif entry._type == 'stage':
cfile = cbfs.add_file_stage(entry._cbfs_name, data,
entry._cbfs_offset)
+ else:
+ entry.Raise("Unknown cbfs-type '%s' (use 'raw', 'stage')" %
+ entry._type)
if cfile:
entry._cbfs_file = cfile
entry.size = cfile.data_len
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 999d8884ac..21bea6c9d1 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -2185,6 +2185,12 @@ class TestFunctional(unittest.TestCase):
'cbfs/u-boot-dtb:image-pos': 0xb8,
}, props)
+ def testCbfsBadType(self):
+ """Test an image header with a no specified location is detected"""
+ with self.assertRaises(ValueError) as e:
+ self._DoReadFile('126_cbfs_bad_type.dts')
+ self.assertIn("Unknown cbfs-type 'badtype'", str(e.exception))
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/test/126_cbfs_bad_type.dts b/tools/binman/test/126_cbfs_bad_type.dts
new file mode 100644
index 0000000000..2cd6fc6d52
--- /dev/null
+++ b/tools/binman/test/126_cbfs_bad_type.dts
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ cbfs {
+ size = <0x100>;
+ u-boot {
+ cbfs-type = "badtype";
+ };
+ };
+ };
+};