summaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt_util.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-17 13:25:40 -0600
committerSimon Glass <sjg@chromium.org>2018-08-01 16:30:48 -0600
commit3af8e49ceff044021725fc547b19ebac22d0b0f7 (patch)
treee0d82e9e4a9e94f1ffe36da7fa4ba78a4da213c7 /tools/dtoc/fdt_util.py
parentec127af0429ad6f9818297f9c3ee77edb2154182 (diff)
binman: Add an entry filled with a repeating byte
It is sometimes useful to have an area of the image which is all zeroes, or all 0xff. This can often be achieved by padding the size of an an existing entry and setting the pad byte for an entry or image. But it is useful to have an explicit means of adding blocks of repeating data to the image. Add a 'fill' entry type to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt_util.py')
-rw-r--r--tools/dtoc/fdt_util.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index b229038569..d762f93a9a 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -148,6 +148,29 @@ def GetBool(node, propname, default=False):
return True
return default
+def GetByte(node, propname, default=None):
+ """Get an byte from a property
+
+ Args:
+ node: Node object to read from
+ propname: property name to read
+ default: Default value to use if the node/property do not exist
+
+ Returns:
+ Byte value read, or default if none
+ """
+ prop = node.props.get(propname)
+ if not prop:
+ return default
+ value = prop.value
+ if isinstance(value, list):
+ raise ValueError("Node '%s' property '%s' has list value: expecting "
+ "a single byte" % (node.name, propname))
+ if len(value) != 1:
+ raise ValueError("Node '%s' property '%s' has length %d, expecting %d" %
+ (node.name, propname, len(value), 1))
+ return ord(value[0])
+
def GetDatatype(node, propname, datatype):
"""Get a value of a given type from a property