Don't reserve size for bad blocks when checking image size

When checking *.img size with the partition size, the build system
reserves additional bits for spare bits and spare bad blocks.

However, for emmc and ufs, the space bits and blocks are entirely
managed by the underlying controller and thus not visible from outside
of the controller. In fact the check routine was made for legacy MTD
storages where raw flash blocks are directly exposed.

This makes the size checking a little bit conservative in modern devices.
Builds were failed even though the *.img can actually fit into the
partition. To handle this problem, the additional size is no longer
reserved when checking *.img size with the partition size.

This change also removes following build flags that are meaningful
only for devices having MTD storages:
BOARD_NAND_PAGE_SIZE
BOARD_NAND_SPARE_SIZE
Further use of them breaks the build

Bug: 35790399
Bug: 66399382
Test: build

Merged-In: I954bf261441b53844e75d05788866f1692a2ad43
Change-Id: I954bf261441b53844e75d05788866f1692a2ad43
This commit is contained in:
Jiyong Park 2017-10-04 21:22:41 +09:00
parent b33250278b
commit 03eb06150b
5 changed files with 8 additions and 48 deletions

View file

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

View file

@ -2745,39 +2745,16 @@ ifndef get-file-size
$(error HOST_OS must define get-file-size) $(error HOST_OS must define get-file-size)
endif 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 $@) # $(1): The file(s) to check (often $@)
# $(2): The maximum total image size, in decimal bytes. # $(2): The partition size.
# Make sure to take into account any reserved space needed for the FS. define assert-max-image-size
#
# 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
$(if $(2), \ $(if $(2), \
size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \ size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \
total=$$(( $$( echo "$$size" ) )); \ total=$$(( $$( echo "$$size" ) )); \
printname=$$(echo -n "$(1)" | tr " " +); \ printname=$$(echo -n "$(1)" | tr " " +); \
img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \ maxsize=$(2); \
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"; \
if [ "$$total" -gt "$$maxsize" ]; then \ if [ "$$total" -gt "$$maxsize" ]; then \
echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \ echo "error: $$printname too large ($$total > $$maxsize)"; \
false; \ false; \
elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \ elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \
echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \ echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \
@ -2787,17 +2764,6 @@ $(if $(2), \
) )
endef 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 ## Define device-specific radio files

View file

@ -63,8 +63,6 @@ TARGET_USES_64_BIT_BINDER := true
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736 # 1.5 GB BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736 # 1.5 GB
# TODO(b/35790399): remove when b/35790399 is fixed.
BOARD_NAND_SPARE_SIZE := 0
BOARD_FLASH_BLOCK_SIZE := 512 BOARD_FLASH_BLOCK_SIZE := 512
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true

View file

@ -74,8 +74,6 @@ BOARD_ROOT_EXTRA_SYMLINKS := /vendor/lib/dsp:/dsp
# Fix this! # Fix this!
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648
# TODO(b/35790399): remove when b/35790399 is fixed.
BOARD_NAND_SPARE_SIZE := 0
BOARD_FLASH_BLOCK_SIZE := 512 BOARD_FLASH_BLOCK_SIZE := 512
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true

View file

@ -55,8 +55,6 @@ TARGET_CPU_VARIANT := generic
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736 BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
# TODO(b/35790399): remove when b/35790399 is fixed.
BOARD_NAND_SPARE_SIZE := 0
BOARD_FLASH_BLOCK_SIZE := 512 BOARD_FLASH_BLOCK_SIZE := 512
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true