]> git.sur5r.net Git - u-boot/blobdiff - tools/dtoc/fdt_normal.py
dtoc: Support packing the device tree
[u-boot] / tools / dtoc / fdt_normal.py
index 52d80555ab9c8eec53ce3a710684084846f5b0c1..f2cf608b1e881c7e778844251f39c055bd96cfe9 100644 (file)
@@ -140,6 +140,17 @@ class FdtNormal(Fdt):
         """
         return self._fdt
 
+    def Flush(self):
+        """Flush device tree changes back to the file"""
+        with open(self._fname, 'wb') as fd:
+            fd.write(self._fdt)
+
+    def Pack(self):
+        """Pack the device tree down to its minimum size"""
+        CheckErr(libfdt.fdt_pack(self._fdt), 'pack')
+        fdt_len = libfdt.fdt_totalsize(self._fdt)
+        del self._fdt[fdt_len:]
+
     def GetProps(self, node, path):
         """Get all properties from a node.