Merge "releasetools: Perform erase commands first." into nyc-dev

am: 25fe877c61

* commit '25fe877c6138afc122331038a271cc80bd78f394':
  releasetools: Perform erase commands first.

Change-Id: I2ea0ddf41ab5265e7840e10b4bcccec6bc69eef9
This commit is contained in:
Tao Bao 2016-05-04 22:36:28 +00:00 committed by android-build-merger
commit b7b6feb3fb
1 changed files with 13 additions and 3 deletions

View File

@ -556,12 +556,22 @@ class BlockImageDiff(object):
total += self.tgt.extended.size()
# We erase all the blocks on the partition that a) don't contain useful
# data in the new image and b) will not be touched by dm-verity.
# data in the new image; b) will not be touched by dm-verity. Out of those
# blocks, we erase the ones that won't be used in this update at the
# beginning of an update. The rest would be erased at the end. This is to
# work around the eMMC issue observed on some devices, which may otherwise
# get starving for clean blocks and thus fail the update. (b/28347095)
all_tgt = RangeSet(data=(0, self.tgt.total_blocks))
all_tgt_minus_extended = all_tgt.subtract(self.tgt.extended)
new_dontcare = all_tgt_minus_extended.subtract(self.tgt.care_map)
if new_dontcare:
out.append("erase %s\n" % (new_dontcare.to_string_raw(),))
erase_first = new_dontcare.subtract(self.touched_src_ranges)
if erase_first:
out.insert(0, "erase %s\n" % (erase_first.to_string_raw(),))
erase_last = new_dontcare.subtract(erase_first)
if erase_last:
out.append("erase %s\n" % (erase_last.to_string_raw(),))
out.insert(0, "%d\n" % (self.version,)) # format version number
out.insert(1, "%d\n" % (total,))