summaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt_normal.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-07-25 18:59:15 -0600
committerSimon Glass <sjg@chromium.org>2016-09-18 21:04:39 -0600
commitda5f74998b9e5e6b706608a4ca625ef0ee195150 (patch)
tree2c628a3eafc53e5976da64efef57569462595ab5 /tools/dtoc/fdt_normal.py
parent2a70d897ed68fd521411a10831ac05e1ffdd3d41 (diff)
downloadu-boot-imx-da5f74998b9e5e6b706608a4ca625ef0ee195150.zip
u-boot-imx-da5f74998b9e5e6b706608a4ca625ef0ee195150.tar.gz
u-boot-imx-da5f74998b9e5e6b706608a4ca625ef0ee195150.tar.bz2
dtoc: Support packing the device tree
After any node/property deletion the device tree can be packed to remove spare space. Add a way to perform this operation. Note that for fdt_fallback, fdtput automatically packs the device tree after deletion, so no action is required here. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt_normal.py')
-rw-r--r--tools/dtoc/fdt_normal.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/dtoc/fdt_normal.py b/tools/dtoc/fdt_normal.py
index 52d8055..f2cf608 100644
--- a/tools/dtoc/fdt_normal.py
+++ b/tools/dtoc/fdt_normal.py
@@ -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.