kernel: bump 6.6 to 6.6.21
[openwrt/openwrt.git] / include / image-commands.mk
index 7d9f93fed741053d72574cc02124d849ab65c4b3..79a64f4bc13997d8121b8167cea6b82a04c45611 100644 (file)
@@ -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,22 @@ 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-image
+       sh $(TOPDIR)/scripts/ubinize-image.sh \
+               $(if $(UBOOTENV_IN_UBI),--uboot-env) \
+               $(foreach part,$(UBINIZE_PARTS),--part $(part)) \
+               --part $(word 1,$(1))="$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(word 2,$(1))" \
+               $@.tmp \
+               -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
+               $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
+               $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \
+               $(UBINIZE_OPTS)
+       cat $@.tmp >> $@
+       rm $@.tmp
 endef
 
 define Build/ubinize-kernel