aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/dtoc')
-rw-r--r--tools/dtoc/fdt.py12
-rwxr-xr-xtools/dtoc/test_fdt.py6
2 files changed, 18 insertions, 0 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 965106a..25ce513 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -463,6 +463,18 @@ class Node:
val = bytes(val, 'utf-8')
self.AddData(prop_name, val + b'\0')
+ def AddInt(self, prop_name, val):
+ """Add a new integer property to a node
+
+ The device tree is marked dirty so that the value will be written to
+ the blob on the next sync.
+
+ Args:
+ prop_name: Name of property to add
+ val: Integer value of property
+ """
+ self.AddData(prop_name, struct.pack('>I', val))
+
def AddSubnode(self, name):
"""Add a new subnode to the node
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index dc6943f..e8fbbd5 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -397,6 +397,12 @@ class TestProp(unittest.TestCase):
data = self.fdt.getprop(self.node.Offset(), 'one')
self.assertEqual(1, fdt32_to_cpu(data))
+ val = 1234
+ self.node.AddInt('integer', val)
+ self.dtb.Sync(auto_resize=True)
+ data = self.fdt.getprop(self.node.Offset(), 'integer')
+ self.assertEqual(val, fdt32_to_cpu(data))
+
val = '123' + chr(0) + '456'
self.node.AddString('string', val)
self.dtb.Sync(auto_resize=True)