summaryrefslogtreecommitdiffstats
path: root/include/image-commands.mk
diff options
context:
space:
mode:
authorTony Ambardar <itugrok@yahoo.com>2023-11-11 04:46:14 -0800
committerHauke Mehrtens <hauke@hauke-m.de>2023-11-26 18:37:20 +0100
commitfc16df9fdd596d1a3f5c3be897dc0cf69c84c469 (patch)
tree58345a15e8f516b44c0baf2fa46ba641693e4bb9 /include/image-commands.mk
parentcd5e0134b6bd2e34ad237d985da99c5307816c93 (diff)
downloadopenwrt-fc16df9fdd596d1a3f5c3be897dc0cf69c84c469.tar.gz
openwrt-fc16df9fdd596d1a3f5c3be897dc0cf69c84c469.tar.bz2
openwrt-fc16df9fdd596d1a3f5c3be897dc0cf69c84c469.zip
image: improve UBI image sizing on NAND devices
Many NAND devices use a build recipe with "append-ubi | check-size" to ensure factory images don't exceed the target flash partition size. However, UBI reserves space for bad block handling and other operational overhead, and thus 'check-size' can overestimate the space available by several MB. In practice, this means a failed check is definitely a failure, while a passing check is only probably a pass. Improve the situation by teaching 'Build/append-ubi' to check image sizes while accounting for UBI reserved blocks. Add new device variable NAND_SIZE and use with existing IMAGE_SIZE to derate the available space. Each UBI device reserves 20 PEBs per 1024 PEBs of the entire NAND device for bad blocks, plus an additional 4 PEBs overhead. Many devices can transparently enable this check by setting NAND_SIZE based on their flash storage, and may then remove any unneeded 'check-size'. Link: http://www.linux-mtd.infradead.org/doc/ubi.html#L_overhead Suggested-by: Shiji Yang <yangshiji66@qq.com> Suggested-by: Robert Marko <robimarko@gmail.com> Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Diffstat (limited to 'include/image-commands.mk')
-rw-r--r--include/image-commands.mk4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 7d9f93fed7..41a5e1198a 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -133,6 +133,8 @@ define Build/append-md5sum-ascii-salted
rm $@.salted
endef
+UBI_NAND_SIZE_LIMIT = $(IMAGE_SIZE) - ($(NAND_SIZE)*20/1024 + 4*$(BLOCKSIZE))
+
define Build/append-ubi
sh $(TOPDIR)/scripts/ubinize-image.sh \
$(if $(UBOOTENV_IN_UBI),--uboot-env) \
@@ -146,6 +148,8 @@ define Build/append-ubi
$(UBINIZE_OPTS)
cat $@.tmp >> $@
rm $@.tmp
+ $(if $(and $(IMAGE_SIZE),$(NAND_SIZE)),\
+ $(call Build/check-size,$(UBI_NAND_SIZE_LIMIT)))
endef
define Build/ubinize-kernel