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

am: ce0c7f8840

* commit 'ce0c7f88403f2a3d8062bd9d602d45459a22cc35':
  releasetools: Perform erase commands first.

Change-Id: I5ddb2ae7e3a8f1a400e90063756bddfa87c80e4c
This commit is contained in:
Tao Bao 2016-05-04 22:38:39 +00:00 committed by android-build-merger
commit 3eac4ce4b8
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,))