Revert "scripts/assemble: Rework to use EDT library to get devicetree data"

This reverts commit 45b00acf0fa5e89880407b639578066cefcd41fa.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/scripts/assemble.py b/scripts/assemble.py
index e895ee7..d8c824b 100755
--- a/scripts/assemble.py
+++ b/scripts/assemble.py
@@ -23,14 +23,6 @@
 import io
 import re
 import os.path
-import sys
-
-ZEPHYR_BASE = os.getenv("ZEPHYR_BASE")
-if not ZEPHYR_BASE:
-    sys.exit("$ZEPHYR_BASE environment variable undefined")
-
-sys.path.insert(0, os.path.join(ZEPHYR_BASE, "scripts", "dts"))
-import edtlib
 
 def same_keys(a, b):
     """Determine if the dicts a and b have the same keys in them"""
@@ -46,8 +38,8 @@
 size_re   = re.compile(r"^#define DT_FLASH_AREA_([0-9A-Z_]+)_SIZE(_0)?\s+(0x[0-9a-fA-F]+|[0-9]+)$")
 
 class Assembly():
-    def __init__(self, output, bootdir, edt):
-        self.find_slots(edt)
+    def __init__(self, output, bootdir):
+        self.find_slots(bootdir)
         try:
             os.unlink(output)
         except OSError as e:
@@ -55,29 +47,29 @@
                 raise
         self.output = output
 
-    def find_slots(self, edt):
+    def find_slots(self, bootdir):
         offsets = {}
         sizes = {}
-
-        part_nodes = edt.compat2nodes["fixed-partitions"]
-        for node in part_nodes:
-            for child in node.children.values():
-                if "label" in child.props:
-                    label = child.props["label"].val
-                    offsets[label] = child.regs[0].addr
-                    sizes[label] = child.regs[0].size
+        with open(os.path.join(bootdir, 'zephyr', 'include', 'generated', 'devicetree_legacy_unfixed.h'), 'r') as fd:
+            for line in fd:
+                m = offset_re.match(line)
+                if m is not None:
+                    offsets[m.group(1)] = int(m.group(3), 0)
+                m = size_re.match(line)
+                if m is not None:
+                    sizes[m.group(1)] = int(m.group(3), 0)
 
         if not same_keys(offsets, sizes):
             raise Exception("Inconsistent data in devicetree.h")
 
-        # We care about the mcuboot, image-0, and image-1 partitions.
-        if 'mcuboot' not in offsets:
+        # We care about the MCUBOOT, IMAGE_0, and IMAGE_1 partitions.
+        if 'MCUBOOT' not in offsets:
             raise Exception("Board partition table does not have mcuboot partition")
 
-        if 'image-0' not in offsets:
+        if 'IMAGE_0' not in offsets:
             raise Exception("Board partition table does not have image-0 partition")
 
-        if 'image-1' not in offsets:
+        if 'IMAGE_1' not in offsets:
             raise Exception("Board partition table does not have image-1 partition")
 
         self.offsets = offsets
@@ -111,21 +103,12 @@
             help='Filename to write full image to')
 
     args = parser.parse_args()
+    output = Assembly(args.output, args.bootdir)
 
-    # Extract board name from path
-    board = os.path.split(os.path.split(args.bootdir)[0])[1]
-
-    dts_path = os.path.join(args.bootdir, "zephyr", board + ".dts.pre.tmp")
-
-    edt = edtlib.EDT(dts_path, [os.path.join(ZEPHYR_BASE, "dts", "bindings")],
-            warn_reg_unit_address_mismatch=False)
-
-    output = Assembly(args.output, args.bootdir, edt)
-
-    output.add_image(os.path.join(args.bootdir, 'zephyr', 'zephyr.bin'), 'mcuboot')
-    output.add_image(args.primary, "image-0")
+    output.add_image(os.path.join(args.bootdir, 'zephyr', 'zephyr.bin'), 'MCUBOOT')
+    output.add_image(args.primary, "IMAGE_0")
     if args.secondary is not None:
-        output.add_image(args.secondary, "image-1")
+        output.add_image(args.secondary, "IMAGE_1")
 
 if __name__ == '__main__':
     main()