Skip to content

Commit

Permalink
treewide: call check-size before append-metadata
Browse files Browse the repository at this point in the history
sysupgrade metadata is not flashed to the device, so check-size
should be called _before_ adding metadata to the image.

While at it, do some obvious wrapping improvements.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Acked-by: Paul Spooren <mail@aparcar.org>
  • Loading branch information
adschm committed Jul 10, 2021
1 parent 918908f commit cce8d16
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 75 deletions.
2 changes: 1 addition & 1 deletion target/linux/ath79/image/Makefile
Expand Up @@ -81,7 +81,7 @@ define Device/Default
COMPILE :=
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | \
append-rootfs | pad-rootfs | append-metadata | check-size
append-rootfs | pad-rootfs | check-size | append-metadata
endef

include $(SUBTARGET).mk
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ath79/image/common-mikrotik.mk
Expand Up @@ -9,7 +9,7 @@ define Device/mikrotik_nor
$(Device/mikrotik)
IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 -e | \
pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
endef

define Device/mikrotik_nand
Expand Down
10 changes: 4 additions & 6 deletions target/linux/ath79/image/common-netgear.mk
Expand Up @@ -32,10 +32,8 @@ define Device/netgear_generic
KERNEL := kernel-bin | append-dtb | lzma -d20 | uImage lzma
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma -d20 | uImage lzma
IMAGES += factory.img
IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | netgear-squashfs | \
append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | \
check-size
IMAGE/factory.img := $$(IMAGE/default) | netgear-dni | \
check-size
IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | \
netgear-squashfs | append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
IMAGE/factory.img := $$(IMAGE/default) | netgear-dni | check-size
endef
5 changes: 2 additions & 3 deletions target/linux/ath79/image/common-tp-link.mk
Expand Up @@ -22,8 +22,7 @@ define Device/tplink-v2
TPLINK_HVERSION := 3
KERNEL := kernel-bin | append-dtb | lzma
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | tplink-v2-header
IMAGE/sysupgrade.bin := tplink-v2-image -s | append-metadata | \
check-size
IMAGE/sysupgrade.bin := tplink-v2-image -s | check-size | append-metadata
endef

define Device/tplink-nolzma
Expand Down Expand Up @@ -74,7 +73,7 @@ define Device/tplink-safeloader
KERNEL := kernel-bin | append-dtb | lzma | tplink-v1-header -O
KERNEL_INITRAMFS := $$(KERNEL)
IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \
append-metadata | check-size
check-size | append-metadata
IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
endef

Expand Down
2 changes: 1 addition & 1 deletion target/linux/ath79/image/generic-tp-link.mk
Expand Up @@ -692,7 +692,7 @@ define Device/tplink_tl-wr2543-v1
DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport
TPLINK_HWID := 0x25430001
IMAGE/sysupgrade.bin := tplink-v1-image sysupgrade -v 3.13.99 | \
append-metadata | check-size
check-size | append-metadata
IMAGE/factory.bin := tplink-v1-image factory -v 3.13.99
SUPPORTED_DEVICES += tl-wr2543n
endef
Expand Down
4 changes: 2 additions & 2 deletions target/linux/ath79/image/generic-ubnt.mk
Expand Up @@ -128,7 +128,7 @@ define Device/ubnt-unifi-jffs2
KERNEL := kernel-bin | append-dtb | lzma | uImage lzma | jffs2 kernel0
IMAGES := sysupgrade.bin factory.bin
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs |\
pad-rootfs | append-metadata | check-size
pad-rootfs | check-size | append-metadata
IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | mkubntimage2
endef

Expand Down Expand Up @@ -373,7 +373,7 @@ define Device/ubnt_routerstation_common
IMAGE/factory.bin := append-rootfs | pad-rootfs | mkubntimage | \
check-size
IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | combined-image | \
append-metadata | check-size
check-size | append-metadata
KERNEL := kernel-bin | append-dtb | lzma | pad-to $$(BLOCKSIZE)
KERNEL_INITRAMFS := kernel-bin | append-dtb
endef
Expand Down
36 changes: 15 additions & 21 deletions target/linux/ath79/image/generic.mk
Expand Up @@ -172,7 +172,7 @@ define Device/seama
# - 36 bytes of META data (4-bytes aligned)
IMAGE/default := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | seama | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
IMAGE/factory.bin := $$(IMAGE/default) | pad-rootfs -x 64 | seama | \
seama-seal | check-size
SEAMA_SIGNATURE :=
Expand Down Expand Up @@ -336,7 +336,7 @@ define Device/avm
KERNEL_INITRAMFS := $$(KERNEL)
IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | \
append-squashfs-fakeroot-be | pad-to 256 | append-rootfs | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
DEVICE_PACKAGES := fritz-tffs
endef

Expand Down Expand Up @@ -777,7 +777,7 @@ define Device/dlink_dap-2xxx
IMAGE/factory.img := append-kernel | pad-offset 6144k 160 | \
append-rootfs | wrgg-pad-rootfs | mkwrggimg | check-size
IMAGE/sysupgrade.bin := append-kernel | mkwrggimg | \
pad-to $$$$(BLOCKSIZE) | append-rootfs | append-metadata | check-size
pad-to $$$$(BLOCKSIZE) | append-rootfs | check-size | append-metadata
KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma
KERNEL_INITRAMFS := $$(KERNEL) | mkwrggimg
endef
Expand Down Expand Up @@ -829,7 +829,7 @@ define Device/dlink_dap-2695-a1
IMAGE/factory.img := $$(IMAGE/default) | append-rootfs | wrgg-pad-rootfs | \
mkwrggimg | check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | mkwrggimg | append-rootfs | \
wrgg-pad-rootfs | append-metadata | check-size
wrgg-pad-rootfs | check-size | append-metadata
KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma
KERNEL_INITRAMFS := $$(KERNEL) | mkwrggimg
DAP_SIGNATURE := wapac02_dkbs_dap2695
Expand Down Expand Up @@ -891,7 +891,7 @@ define Device/dlink_dir-825-b1
DEVICE_VARIANT := B1
IMAGE_SIZE := 6208k
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport \
kmod-leds-reset kmod-owl-loader
SUPPORTED_DEVICES += dir-825-b1
Expand All @@ -912,8 +912,7 @@ define Device/dlink_dir-825-c1
pad-rootfs
IMAGE/factory.bin := $$(IMAGE/default) | pad-offset $$$$(IMAGE_SIZE) 26 | \
append-string 00DB120AR9344-RT-101214-00 | check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | \
check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
endef
TARGET_DEVICES += dlink_dir-825-c1

Expand All @@ -930,8 +929,7 @@ define Device/dlink_dir-835-a1
pad-rootfs
IMAGE/factory.bin := $$(IMAGE/default) | pad-offset $$$$(IMAGE_SIZE) 26 | \
append-string 00DB120AR9344-RT-101214-00 | check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | \
check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
endef
TARGET_DEVICES += dlink_dir-835-a1

Expand All @@ -950,7 +948,7 @@ define Device/dlink_dir-842-c
IMAGE/default := append-kernel | uImage lzma | \
pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | seama | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
IMAGE/factory.bin := $$(IMAGE/default) | pad-rootfs -x 64 | seama | \
seama-seal | check-size
IMAGE_SIZE := 15680k
Expand Down Expand Up @@ -1363,7 +1361,7 @@ define Device/jjplus_ja76pf2
IMAGE/kernel.bin := append-kernel
IMAGE/rootfs.bin := append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | combined-image | \
append-metadata | check-size
check-size | append-metadata
KERNEL := kernel-bin | append-dtb | lzma | pad-to $$(BLOCKSIZE)
KERNEL_INITRAMFS := kernel-bin | append-dtb
IMAGE_SIZE := 16000k
Expand Down Expand Up @@ -1430,7 +1428,7 @@ define Device/nec_wx1200cr
DEVICE_VENDOR := NEC
IMAGE/default := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | seama | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca9888-ct
endef

Expand Down Expand Up @@ -1482,10 +1480,8 @@ define Device/netgear_ex6400_ex7300
IMAGE_SIZE := 15552k
IMAGE/default := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \
netgear-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | \
check-size
IMAGE/factory.img := $$(IMAGE/default) | netgear-dni | \
check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
IMAGE/factory.img := $$(IMAGE/default) | netgear-dni | check-size
DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca99x0-ct
endef

Expand Down Expand Up @@ -1868,7 +1864,7 @@ define Device/phicomm_k2t
DEVICE_MODEL := K2T
IMAGE_SIZE := 15744k
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
DEVICE_PACKAGES := kmod-leds-reset kmod-ath10k-ct-smallbuffers ath10k-firmware-qca9888-ct
endef
TARGET_DEVICES += phicomm_k2t
Expand Down Expand Up @@ -2230,8 +2226,7 @@ define Device/teltonika_rut955
pad-rootfs | teltonika-fw-fake-checksum 20 | append-string master |\
append-md5sum-bin | check-size
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) |\
append-rootfs | pad-rootfs | append-metadata |\
check-size
append-rootfs | pad-rootfs | check-size | append-metadata
endef
TARGET_DEVICES += teltonika_rut955

Expand All @@ -2254,8 +2249,7 @@ define Device/trendnet_tew-823dru
pad-rootfs
IMAGE/factory.bin := $$(IMAGE/default) | pad-offset $$$$(IMAGE_SIZE) 26 | \
append-string 00AP135AR9558-RT-131129-00 | check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | \
check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
endef
TARGET_DEVICES += trendnet_tew-823dru

Expand Down
3 changes: 1 addition & 2 deletions target/linux/ath79/image/nand.mk
Expand Up @@ -166,8 +166,7 @@ define Device/netgear_ath79_nand
IMAGES := sysupgrade.bin factory.img
IMAGE/factory.img := append-kernel | append-ubi | netgear-dni | \
check-size
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | \
check-size
IMAGE/sysupgrade.bin := sysupgrade-tar | check-size | append-metadata
UBINIZE_OPTS := -E 5
endef

Expand Down
3 changes: 1 addition & 2 deletions target/linux/ath79/image/tiny.mk
Expand Up @@ -21,8 +21,7 @@ define Device/dlink_dir-615-e4
FACTORY_IMAGE_SIZE := 3456k
IMAGES += factory.bin
IMAGE/default := append-kernel | append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | \
check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
IMAGE/factory.bin := $$(IMAGE/default) | \
check-size $$$$(FACTORY_IMAGE_SIZE) | pad-to $$$$(FACTORY_IMAGE_SIZE) | \
append-string "AP99-AR7240-RT-091105-05"
Expand Down
8 changes: 4 additions & 4 deletions target/linux/ipq40xx/image/generic.mk
Expand Up @@ -35,7 +35,7 @@ define Device/DniImage
IMAGES += factory.img
IMAGE/factory.img := append-kernel | pad-offset 64k 64 | append-uImage-fakehdr filesystem | append-rootfs | pad-rootfs | netgear-dni
IMAGE/sysupgrade.bin := append-kernel | pad-offset 64k 64 | append-uImage-fakehdr filesystem | \
append-rootfs | pad-rootfs | append-metadata | check-size
append-rootfs | pad-rootfs | check-size | append-metadata
endef

define Build/append-rootfshdr
Expand Down Expand Up @@ -106,7 +106,7 @@ define Device/8dev_habanero-dvk
IMAGE_SIZE := 30976k
SOC := qcom-ipq4019
DEVICE_PACKAGES := ipq-wifi-8dev_habanero-dvk
IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | pad-rootfs | append-metadata | check-size
IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | pad-rootfs | check-size | append-metadata
endef
TARGET_DEVICES += 8dev_habanero-dvk

Expand Down Expand Up @@ -207,7 +207,7 @@ define Device/avm_fritzbox-4040
UBOOT_PARTITION_SIZE := 524288
IMAGES += eva.bin
IMAGE/eva.bin := append-uboot | pad-to $$$$(UBOOT_PARTITION_SIZE) | append-kernel | append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata
DEVICE_PACKAGES := fritz-tffs fritz-caldata
endef
TARGET_DEVICES += avm_fritzbox-4040
Expand Down Expand Up @@ -822,7 +822,7 @@ define Device/zyxel_wre6606
DEVICE_DTS_CONFIG := config@4
SOC := qcom-ipq4018
IMAGE_SIZE := 13184k
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata
DEVICE_PACKAGES := -kmod-ath10k-ct kmod-ath10k-ct-smallbuffers
endef
TARGET_DEVICES += zyxel_wre6606
2 changes: 1 addition & 1 deletion target/linux/ipq40xx/image/mikrotik.mk
Expand Up @@ -7,7 +7,7 @@ define Device/mikrotik_nor
IMAGES = sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 | \
pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \
append-metadata | check-size
check-size | append-metadata
endef

define Device/mikrotik_hap-ac2
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ipq806x/image/Makefile
Expand Up @@ -401,7 +401,7 @@ define Device/ubnt_unifi-ac-hd
BLOCKSIZE := 64k
IMAGE_SIZE := 14784k
DEVICE_PACKAGES := ath10k-firmware-qca9984-ct
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | append-metadata | check-size
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size | append-metadata
endef
TARGET_DEVICES += ubnt_unifi-ac-hd

Expand Down
4 changes: 2 additions & 2 deletions target/linux/lantiq/image/Makefile
Expand Up @@ -63,7 +63,7 @@ define Device/Default
SOC := $(DEFAULT_SOC)
DEVICE_DTS = $$(SOC)_$(1)
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata
endef

define Device/NAND/xway
Expand Down Expand Up @@ -102,7 +102,7 @@ define Device/AVM
KERNEL := kernel-bin | append-dtb | lzma | eva-image
KERNEL_INITRAMFS := $$(KERNEL)
IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-avm-fakeroot | \
append-rootfs | pad-rootfs | append-metadata | check-size
append-rootfs | pad-rootfs | check-size | append-metadata
endef

ifeq ($(SUBTARGET),ase)
Expand Down
6 changes: 3 additions & 3 deletions target/linux/lantiq/image/ar9.mk
Expand Up @@ -90,10 +90,10 @@ define Device/netgear_dgn3500
factory-na.img factory.img
IMAGE/sysupgrade-na.bin := \
append-kernel | append-rootfs | dgn3500-sercom-footer 0x0 "NA" | \
pad-rootfs | append-metadata | check-size
pad-rootfs | check-size | append-metadata
IMAGE/sysupgrade.bin := \
append-kernel | append-rootfs | dgn3500-sercom-footer 0x0 "WW" | \
pad-rootfs | append-metadata | check-size
pad-rootfs | check-size | append-metadata
IMAGE/factory-na.img := \
pad-extra $(DGN3500_KERNEL_OFFSET_DEC) | append-kernel | append-rootfs | \
dgn3500-sercom-footer $(DGN3500_KERNEL_OFFSET_HEX) "NA" | pad-rootfs | \
Expand All @@ -119,7 +119,7 @@ define Device/netgear_dgn3500b
IMAGES += factory.img
IMAGE/sysupgrade.bin := \
append-kernel | append-rootfs | dgn3500-sercom-footer 0x0 "DE" | \
pad-rootfs | append-metadata | check-size
pad-rootfs | check-size | append-metadata
IMAGE/factory.img := \
pad-extra $(DGN3500_KERNEL_OFFSET_DEC) | append-kernel | append-rootfs | \
dgn3500-sercom-footer $(DGN3500_KERNEL_OFFSET_HEX) "DE" | pad-rootfs | \
Expand Down
2 changes: 1 addition & 1 deletion target/linux/lantiq/image/tp-link.mk
Expand Up @@ -14,7 +14,7 @@ define Device/lantiqTpLink
tplink-v2-header -s -V "ver. 1.0"
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := tplink-v2-image -s -V "ver. 1.0" | \
append-metadata | check-size
check-size | append-metadata
endef

define Device/tplink_tdw8970
Expand Down
2 changes: 1 addition & 1 deletion target/linux/lantiq/image/vr9.mk
Expand Up @@ -253,7 +253,7 @@ define Device/netgear_dm200
IMAGE/sysupgrade.bin := append-kernel | \
pad-offset 64k 64 | append-uImage-fakehdr filesystem | \
pad-offset 64k 64 | append-uImage-fakehdr filesystem | \
append-rootfs | pad-rootfs | append-metadata | check-size
append-rootfs | pad-rootfs | check-size | append-metadata
IMAGE/factory.img := $$(IMAGE/sysupgrade.bin) | netgear-dni
IMAGE_SIZE := 7872k
NETGEAR_BOARD_ID := DM200
Expand Down
6 changes: 3 additions & 3 deletions target/linux/ramips/image/Makefile
Expand Up @@ -166,7 +166,7 @@ define Device/Default
IMAGES := sysupgrade.bin
COMPILE :=
sysupgrade_bin := append-kernel | append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata
endef

define Device/netgear_sercomm_nor
Expand All @@ -175,7 +175,7 @@ define Device/netgear_sercomm_nor
IMAGES += factory.img
IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \
pad-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | check-size
IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata
IMAGE/factory.img := pad-extra $$$$(SERCOMM_PAD) | $$(IMAGE/default) | \
pad-to $$$$(BLOCKSIZE) | sercom-footer | pad-to 128 | \
zip $$$$(SERCOMM_HWNAME).bin | sercom-seal
Expand All @@ -190,7 +190,7 @@ define Device/seama
# - 36 bytes of META data (4-bytes aligned)
IMAGE/default := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs
IMAGE/sysupgrade.bin := \
$$(IMAGE/default) | seama | pad-rootfs | append-metadata | check-size
$$(IMAGE/default) | seama | pad-rootfs | check-size | append-metadata
IMAGE/factory.bin := \
$$(IMAGE/default) | pad-rootfs -x 64 | seama | seama-seal | check-size
SEAMA_SIGNATURE :=
Expand Down

0 comments on commit cce8d16

Please sign in to comment.