From 98ef7bb15795c6ad204eb53808a24ede2d00eccd Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 7 Jan 2022 14:41:46 -0800 Subject: [PATCH] Fix GetCareMap for small images Change-Id: Iac518e36dbb2fe9303e84d502cd7dfe74621c0af --- tools/releasetools/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 339939f85b..94ef6d8b36 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -3892,7 +3892,10 @@ def GetCareMap(which, imgname): disable_sparse = OPTIONS.info_dict.get(which + "_disable_sparse") image_blocks = int(image_size) // 4096 - 1 - assert image_blocks > 0, "blocks for {} must be positive".format(which) + # It's OK for image_blocks to be 0, because care map ranges are inclusive. + # So 0-0 means "just block 0", which is valid. + assert image_blocks >= 0, "blocks for {} must be non-negative, image size: {}".format( + which, image_size) # For sparse images, we will only check the blocks that are listed in the care # map, i.e. the ones with meaningful data.