dtoc: Support adding new nodes

Add a way to add new nodes and sync them back to the blob.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 4a67f89..c94e455 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -355,6 +355,14 @@
 
     def testAddNode(self):
         self.fdt.pack()
+        self.node.AddSubnode('subnode')
+        with self.assertRaises(libfdt.FdtException) as e:
+            self.dtb.Sync(auto_resize=False)
+        self.assertIn('FDT_ERR_NOSPACE', str(e.exception))
+
+        self.dtb.Sync(auto_resize=True)
+        offset = self.fdt.path_offset('/spl-test/subnode')
+        self.assertTrue(offset > 0)
 
 
 class TestFdtUtil(unittest.TestCase):