Merge "Don't reserve size for bad blocks when checking image size" into oc-mr1-dev-plus-aosp

This commit is contained in:
TreeHugger Robot 2017-10-05 22:18:25 +00:00 committed by Android (Google) Code Review
commit 2224b84cd3
3 changed files with 8 additions and 44 deletions

View file

@ -1310,12 +1310,12 @@ endif
.PHONY: recoveryimage
recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
ifeq ($(BOARD_NAND_PAGE_SIZE),)
BOARD_NAND_PAGE_SIZE := 2048
ifneq ($(BOARD_NAND_PAGE_SIZE),)
$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
endif
ifeq ($(BOARD_NAND_SPARE_SIZE),)
BOARD_NAND_SPARE_SIZE := 64
ifneq ($(BOARD_NAND_SPARE_SIZE),)
$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
endif
# -----------------------------------------------------------------

View file

@ -2754,39 +2754,16 @@ ifndef get-file-size
$(error HOST_OS must define get-file-size)
endif
# Convert a partition data size (eg, as reported in /proc/mtd) to the
# size of the image used to flash that partition (which includes a
# spare area for each page).
# $(1): the partition data size
define image-size-from-data-size
$(strip $(eval _isfds_value := $$(shell echo $$$$(($(1) / $(BOARD_NAND_PAGE_SIZE) * \
($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE))))))\
$(if $(filter 0, $(_isfds_value)),$(shell echo $$(($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE)))),$(_isfds_value))\
$(eval _isfds_value :=))
endef
# $(1): The file(s) to check (often $@)
# $(2): The maximum total image size, in decimal bytes.
# Make sure to take into account any reserved space needed for the FS.
#
# If $(2) is empty, evaluates to "true"
#
# Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks)
# is left over after the image has been flashed. Round the 1% up to the
# next whole flash block size.
define assert-max-file-size
# $(2): The partition size.
define assert-max-image-size
$(if $(2), \
size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \
total=$$(( $$( echo "$$size" ) )); \
printname=$$(echo -n "$(1)" | tr " " +); \
img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \
twoblocks=$$((img_blocksize * 2)); \
onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \
reserve=$$((twoblocks > onepct ? twoblocks : onepct)); \
maxsize=$$(($(2) - reserve)); \
echo "$$printname maxsize=$$maxsize blocksize=$$img_blocksize total=$$total reserve=$$reserve"; \
maxsize=$(2); \
if [ "$$total" -gt "$$maxsize" ]; then \
echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \
echo "error: $$printname too large ($$total > $$maxsize)"; \
false; \
elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \
echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \
@ -2796,17 +2773,6 @@ $(if $(2), \
)
endef
# Like assert-max-file-size, but the second argument is a partition
# size, which we'll convert to a max image size before checking it
# against the files.
#
# $(1): The file(s) to check (often $@)
# $(2): The partition size.
define assert-max-image-size
$(if $(2), \
$(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2))))
endef
###########################################################
## Define device-specific radio files

View file

@ -54,8 +54,6 @@ TARGET_USES_HWC2 := true
# Set emulator framebuffer display device buffer count to 3
NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
# TODO(b/35790399): remove when b/35790399 is fixed.
BOARD_NAND_SPARE_SIZE := 0
BOARD_FLASH_BLOCK_SIZE := 512
# b/64700195: add minimum support for odm.img