summaryrefslogtreecommitdiff
path: root/tools/dtoc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-17 13:25:32 -0600
committerSimon Glass <sjg@chromium.org>2018-08-01 16:30:47 -0600
commit53af22a9958ca93c89056ad2750ad0d46a51b6c8 (patch)
tree232abf4eb746495b01b96f3540a370ae71ac1da0 /tools/dtoc
parentdc08ecc90cc57d7ca73f837a847a81c8b1e8af79 (diff)
binman: Add support for passing arguments to entries
Sometimes it is useful to pass binman the value of an entry property from the command line. For example some entries need access to files and it is not always convenient to put these filenames in the image definition (device tree). Add a -a option which can be used like this: -a<prop>=<value> where <prop> is the property to set <value> is the value to set it to Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc')
-rw-r--r--tools/dtoc/fdt_util.py21
-rwxr-xr-xtools/dtoc/test_fdt.py8
2 files changed, 29 insertions, 0 deletions
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index 05cb9c0775..b229038569 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -147,3 +147,24 @@ def GetBool(node, propname, default=False):
if propname in node.props:
return True
return default
+
+def GetDatatype(node, propname, datatype):
+ """Get a value of a given type from a property
+
+ Args:
+ node: Node object to read from
+ propname: property name to read
+ datatype: Type to read (str or int)
+
+ Returns:
+ value read, or None if none
+
+ Raises:
+ ValueError if datatype is not str or int
+ """
+ if datatype == str:
+ return GetString(node, propname)
+ elif datatype == int:
+ return GetInt(node, propname)
+ raise ValueError("fdt_util internal error: Unknown data type '%s'" %
+ datatype)
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index f085b1dd1a..03cf4b4f7c 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -380,6 +380,14 @@ class TestFdtUtil(unittest.TestCase):
self.assertEqual(True, fdt_util.GetBool(self.node, 'missing', True))
self.assertEqual(False, fdt_util.GetBool(self.node, 'missing', False))
+ def testGetDataType(self):
+ self.assertEqual(1, fdt_util.GetDatatype(self.node, 'intval', int))
+ self.assertEqual('message', fdt_util.GetDatatype(self.node, 'stringval',
+ str))
+ with self.assertRaises(ValueError) as e:
+ self.assertEqual(3, fdt_util.GetDatatype(self.node, 'boolval',
+ bool))
+
def testFdtCellsToCpu(self):
val = self.node.props['intarray'].value
self.assertEqual(0, fdt_util.fdt_cells_to_cpu(val, 0))