Added writing DDR.bin to DDR partition during flo OTA

[Issue 9734870] Some devices are unstable with Elpida DDR RAM

The DDR.bin in fact are all zeros, it's meant to erase partition
DDR during each OTA update for DDR memory retraining.

Change-Id: Id23bf14344a33c437cbaf77f4fb35bf9e3663b98
diff --git a/releasetools.py b/releasetools.py
index ffb1baf..6f485c1 100644
--- a/releasetools.py
+++ b/releasetools.py
@@ -22,6 +22,12 @@
   else:
     print "no radio.img in target_files; skipping install"
 
+  DDR_img = FindDDR(info.input_zip)
+  if DDR_img:
+    WriteDDR(info, DDR_img)
+  else:
+    print "no DDR.bin in target_files; skipping install"
+
 
 def IncrementalOTA_VerifyEnd(info):
   target_radio_img = FindRadio(info.target_zip)
@@ -51,6 +57,13 @@
   except KeyError:
     print "no bootloader.img in target target_files; skipping install"
 
+  df = FindDDR(info.target_zip)
+  if not df:
+    print "no DDR.bin in target target_files; skipping install"
+  else:
+    df = common.File("DDR.bin", df)
+    WriteDDR(info, df.data)
+
   tf = FindRadio(info.target_zip)
   if not tf:
     # failed to read TARGET radio image: don't include any radio in update.
@@ -94,6 +107,18 @@
   info.script.AppendExtra(
       'package_extract_file("radio.img", "%s");' % (device,))
 
+def FindDDR(zipfile):
+  try:
+    return zipfile.read("RADIO/DDR.bin")
+  except KeyError:
+    return None
+
+
+def WriteDDR(info, DDR_img):
+  info.script.Print("Writing DDR...")
+  common.ZipWriteStr(info.output_zip, "DDR.bin", DDR_img)
+  info.script.AppendExtra(
+      'package_extract_file("DDR.bin", "/dev/block/platform/msm_sdcc.1/by-name/DDR");' )
 
 # /* msm8960 bootloader.img format */
 #