cros_bundle_firmware: Remove hard-coded exynos addresses

Move the BL1/BL2 and U-Boot addresses to the device tree so that we can
adjust them when needed. This is required for early-firmware-selection.
So that upstream U-Boot still boots, add a default memory map to the
default device tree.

BUG=chrome-os-partner:21115
TEST=FEATURES=test sudo -E  emerge cros-devutils
manual:

Boot upstream U-Boot on snow with:

$ crosfw -b daisy

Change-Id: Ifd83126159d9c942bb4d3e7fc6c00267f8b7a7c0
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62966
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index cf73204..fe6ded4 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -79,6 +79,18 @@
         'path' : '/flash',
         'reg' : [0, 0x400000],
     }, {
+        'path' : '/memory',
+        'reg' : [0x40000000, 0x80000000],
+    }, {
+        'path' : '/iram',
+        'reg' : [0x02020000, 384 << 10],
+    }, {
+        'path' : '/config',
+        'samsung,bl1-offset' : 0x1400,
+        'samsung,bl2-offset' : 0x3400,
+        'u-boot-memory' : '/memory',
+        'u-boot-offset' : [0x3e00000, 0x100000],
+    }, {
         'path' : '/flash/pre-boot',
         'label' : "bl1 pre-boot",
         'reg' : [0, 0x2000],
@@ -127,6 +139,18 @@
         'path' : '/flash',
         'reg' : [0, 0x400000],
     }, {
+        'path' : '/memory',
+        'reg' : [0x20000000, 0x80000000],     # Assume 2GB of RAM
+    }, {
+        'path' : '/iram',
+        'reg' : [0x02020000, 384 << 10],
+    }, {
+        'path' : '/config',
+        'samsung,bl1-offset' : 0x2400,
+        'samsung,bl2-offset' : 0x4400,
+        'u-boot-memory' : '/memory',
+        'u-boot-offset' : [0x3e00000, 0x100000],
+    }, {
         'path' : '/flash/pre-boot',
         'label' : "bl1 pre-boot",
         'reg' : [0, 0x2000],
@@ -905,7 +929,7 @@
     pack = PackFirmware(self._tools, self._out)
     # Get the flashmap so we know what to build. For board variants use the
     # main board name as the key (drop the _<variant> suffix).
-    default_flashmap = default_flashmaps.get(self._board.split('_')[0])
+    default_flashmap = default_flashmaps.get(self._board.split('_')[0], [])
     if self._force_rw:
       fdt.PutInteger('/flash/rw-a-vblock', 'preamble-flags', 0)
       fdt.PutInteger('/flash/rw-b-vblock', 'preamble-flags', 0)
@@ -915,6 +939,21 @@
     if not fdt.GetProp('/flash', 'reg', ''):
       fdt.InsertNodes(default_flashmap)
 
+    # Insert default values for any essential properties that are missing.
+    # This should only happen for upstream U-Boot, until our changes are
+    # upstreamed.
+    if not fdt.GetProp('/iram', 'reg', ''):
+      self._out.Warning('Cannot find /iram, using default')
+      fdt.InsertNodes([i for i in default_flashmap if i['path'] == '/iram'])
+
+    if not fdt.GetProp('/memory', 'reg', ''):
+      self._out.Warning('Cannot find /memory, using default')
+      fdt.InsertNodes([i for i in default_flashmap if i['path'] == '/memory'])
+
+    if not fdt.GetProp('/config', 'samsung,bl1-offset', ''):
+      self._out.Warning('Missing properties in /config, using defaults')
+      fdt.InsertNodes([i for i in default_flashmap if i['path'] == '/config'])
+
     pack.SelectFdt(fdt, self._board)
 
     # Get all our blobs ready