diff --git a/Makefile b/Makefile index 3ddb6b6df..b2cd3714a 100644 --- a/Makefile +++ b/Makefile @@ -179,11 +179,16 @@ ifneq ($(wildcard $(TARGET)/images/firmware.bin),) # squashfs is: at the block right after the uImage is the split layout, at the # slot boundary fixed slots. A fixed-slot uImage ending in the slot's last block # would be both. +# +# The fixed-slot package is the extra: a build whose uImage or rootfs has +# outgrown its slot ships the split package alone rather than failing, and +# says so. Cameras on fixed slots then upgrade to the split layout, which +# sysupgrade and defib install from the -split package. ifeq ($(BR2_OPENIPC_NOR_FIXED_PACKAGE),y) ifeq ($(BR2_OPENIPC_FLASH_SIZE),"8") - @$(call PREPARE_REPACK,uImage,1983,rootfs.squashfs,5120,nor) + @$(if $(call FIXED_SLOTS_FIT,5120),$(call PREPARE_REPACK,uImage,1983,rootfs.squashfs,5120,nor),$(call FIXED_SLOTS_SKIP,5120)) else - @$(call PREPARE_REPACK,uImage,1983,rootfs.squashfs,8192,nor) + @$(if $(call FIXED_SLOTS_FIT,8192),$(call PREPARE_REPACK,uImage,1983,rootfs.squashfs,8192,nor),$(call FIXED_SLOTS_SKIP,8192)) endif endif @$(call CHECK_SIZE,firmware.bin,$(shell expr $(subst ",,$(BR2_OPENIPC_FLASH_SIZE)) \* 1024 - $$(( $(or $(BR2_OPENIPC_NOR_FIRMWARE_OFFSET),0x50000) / 1024 )) - 256)) @@ -368,6 +373,23 @@ define REPACK_FIRMWARE rm -f $(TARGET)/images/*.md5sum endef +# Whether uImage and rootfs.squashfs fit the fixed slots beside a split image: +# the uImage under 1984K (see the repack target), the rootfs within $(1) KB, +# both counted in whole KB as CHECK_SIZE counts them. "y" or empty. +FIXED_SLOTS_FIT = $(shell k=$$(( $$(stat -c %s $(TARGET)/images/uImage 2>/dev/null || echo 0) / 1024 )); \ + r=$$(( $$(stat -c %s $(TARGET)/images/rootfs.squashfs 2>/dev/null || echo 0) / 1024 )); \ + [ $$k -gt 0 ] && [ $$k -le 1983 ] && [ $$r -gt 0 ] && [ $$r -le $(1) ] && echo y) + +define FIXED_SLOTS_SKIP + k=$$(( $$(stat -c %s $(TARGET)/images/uImage) / 1024 )); \ + r=$$(( $$(stat -c %s $(TARGET)/images/rootfs.squashfs) / 1024 )); \ + over=; \ + [ $$k -le 1983 ] || over="uImage $${k}KB/1983KB"; \ + [ $$r -le $(1) ] || over="$${over:+$$over, }rootfs.squashfs $${r}KB/$(1)KB"; \ + echo "::warning::$(BR2_OPENIPC_SOC_MODEL) $(BR2_OPENIPC_VARIANT): $$over outgrew the fixed slot;" \ + "shipping the split package only" +endef + # The split NOR package: firmware.bin alone, under its own name so a sysupgrade # that predates the layout never sees it. Copies, as REPACK_NAND_FIT does. define REPACK_NOR_SPLIT