cros_bundle_firmware: Don't change existing machine parameters

When we come across a machine parameter that we don't understand, leave
the value as it was rather than randomly changing it.

BUG=chromium-os:19724
TEST=manual: run cros_bundle_firmware
See that it gives a warning on the 'u' paramter but using ghex2 see that
it leaves the value as is.

Change-Id: I3f3c1cd9a9b95c2a91bd55c3459c8a94a4f590b8
Reviewed-on: https://gerrit.chromium.org/gerrit/18318
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index defcd79..02f67b8 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -457,7 +457,9 @@
       raise CmdError("Cannot update machine parameter block version '%d'" %
           version)
     if size < 0 or pos + size > len(data):
-      raise CmdError("Machine parameter block size %d is invalid" % size)
+      raise CmdError("Machine parameter block size %d is invalid: "
+            "pos=%d, size=%d, space=%d, len=%d" %
+            (size, pos, size, len(data) - pos, len(data)))
 
     # Move past the header and read the parameter list, which is terminated
     # with \0.
@@ -469,6 +471,7 @@
 
     # Work through the parameters one at a time, adding each value
     new_data = ''
+    upto = 0
     for param in param_list:
       if param == 'm' :
         mem_type = fdt.GetString('/memory', 'samsung,memtype')
@@ -481,8 +484,10 @@
         value = 31
         self._out.Info('  Memory interleave: %#0x' % value)
       else:
-        raise CmdError("Machine parameter block size %d is invalid" % size)
+        self._out.Warning("Unknown machine parameter type '%s'" % param)
+        value = struct.unpack('<1L', data[pos + upto:pos + upto + 4])[0]
       new_data += struct.pack('<L', value)
+      upto += 4
 
     # Put the data into our block.
     data = data[:pos] + new_data + data[pos + len(new_data):]