Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / tools / binman / etype / fdtmap.py
index ff3f1ae..aa88079 100644 (file)
@@ -8,13 +8,9 @@ This handles putting an FDT into the image with just the information about the
 image.
 """
 
-import libfdt
-
-from entry import Entry
-from fdt import Fdt
-import state
-import tools
-import tout
+from binman.entry import Entry
+from patman import tools
+from patman import tout
 
 FDTMAP_MAGIC   = b'_FDTMAP_'
 FDTMAP_HDR_LEN = 16
@@ -80,6 +76,15 @@ class Entry_fdtmap(Entry):
     added as necessary. See the binman README.
     """
     def __init__(self, section, etype, node):
+        # Put these here to allow entry-docs and help to work without libfdt
+        global libfdt
+        global state
+        global Fdt
+
+        import libfdt
+        from binman import state
+        from dtoc.fdt import Fdt
+
         Entry.__init__(self, section, etype, node)
 
     def _GetFdtmap(self):
@@ -96,10 +101,10 @@ class Entry_fdtmap(Entry):
                 with fsw.add_node(subnode.name):
                     _AddNode(subnode)
 
-        outfdt = self.GetImage().fdtmap_dtb
+        data = state.GetFdtContents('fdtmap')[1]
         # If we have an fdtmap it means that we are using this as the
-        # read-only fdtmap for this image.
-        if not outfdt:
+        # fdtmap for this image.
+        if data is None:
             # Get the FDT data into an Fdt object
             data = state.GetFdtContents()[1]
             infdt = Fdt.FromData(data)
@@ -126,7 +131,8 @@ class Entry_fdtmap(Entry):
             # Pack this new FDT and return its contents
             fdt.pack()
             outfdt = Fdt.FromData(fdt.as_bytearray())
-        data = FDTMAP_MAGIC + tools.GetBytes(0, 8) + outfdt.GetContents()
+            data = outfdt.GetContents()
+        data = FDTMAP_MAGIC + tools.GetBytes(0, 8) + data
         return data
 
     def ObtainContents(self):