[OpenWrt-Devel,1/2] build: define check-kernel-size to remove unflashable images
diff mbox series

Message ID 20191113210949.2490-1-lede@allycomm.com
State Accepted
Delegated to: John Crispin
Headers show
Series
  • [OpenWrt-Devel,1/2] build: define check-kernel-size to remove unflashable images
Related show

Commit Message

Jeff Kletsky Nov. 13, 2019, 9:09 p.m. UTC
From: Jeff Kletsky <git-commits@allycomm.com>

Certain boards have limitations on U-Boot that prevent flashing
of images where the kernel size exceeds a threshold, yet
sysupgrade can sucessfully manage larger kernels. The current
check-size will remove the target artifact if its total size
exceeds the threshold. If applied after append-kernel,
it will remove the kernel, but the remaining image-assembly
steps will continue, resulting in an image without a kernel
that is likely unbootable.

By defining check-kernel-size, it is now possible to prevent release
of such unbootable images through a construct similar to:

  IMAGE/factory.img := append-kernel | pad-to $$$$(GL_UBOOT_UBI_OFFSET) | \
    append-ubi | check-kernel-size $$$$(GL_UBOOT_UBI_OFFSET)

Cc: Chuanhong Guo <gch981213@gmail.com>

Signed-off-by: Jeff Kletsky <git-commits@allycomm.com>
---
 include/image-commands.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

John Crispin Jan. 15, 2020, 7:06 p.m. UTC | #1
On 13/11/2019 22:09, Jeff Kletsky wrote:
> From: Jeff Kletsky <git-commits@allycomm.com>
> 
> Certain boards have limitations on U-Boot that prevent flashing
> of images where the kernel size exceeds a threshold, yet
> sysupgrade can sucessfully manage larger kernels. The current
> check-size will remove the target artifact if its total size
> exceeds the threshold. If applied after append-kernel,
> it will remove the kernel, but the remaining image-assembly
> steps will continue, resulting in an image without a kernel
> that is likely unbootable.
> 
> By defining check-kernel-size, it is now possible to prevent release
> of such unbootable images through a construct similar to:
> 
>    IMAGE/factory.img := append-kernel | pad-to $$$$(GL_UBOOT_UBI_OFFSET) | \
>      append-ubi | check-kernel-size $$$$(GL_UBOOT_UBI_OFFSET)
> 
> Cc: Chuanhong Guo <gch981213@gmail.com>
> 
> Signed-off-by: Jeff Kletsky <git-commits@allycomm.com>
Merged, thanks !
> ---
>   include/image-commands.mk | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/include/image-commands.mk b/include/image-commands.mk
> index 5dfd6a2c2f..f561ad4669 100644
> --- a/include/image-commands.mk
> +++ b/include/image-commands.mk
> @@ -271,6 +271,13 @@ define Build/check-size
>   	}
>   endef
>   
> +define Build/check-kernel-size
> +	@[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $(IMAGE_KERNEL))" ] || { \
> +		echo "WARNING: Kernel for $@ is too big > $(1)" >&2; \
> +		rm -f $@; \
> +	}
> +endef
> +
>   define Build/combined-image
>   	-sh $(TOPDIR)/scripts/combined-image.sh \
>   		"$(IMAGE_KERNEL)" \
>

Patch
diff mbox series

diff --git a/include/image-commands.mk b/include/image-commands.mk
index 5dfd6a2c2f..f561ad4669 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -271,6 +271,13 @@  define Build/check-size
 	}
 endef
 
+define Build/check-kernel-size
+	@[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $(IMAGE_KERNEL))" ] || { \
+		echo "WARNING: Kernel for $@ is too big > $(1)" >&2; \
+		rm -f $@; \
+	}
+endef
+
 define Build/combined-image
 	-sh $(TOPDIR)/scripts/combined-image.sh \
 		"$(IMAGE_KERNEL)" \