From 7c1332d95fbaea2e0a5029947a2b8d3d43c171b4 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sat, 29 Dec 2018 19:25:00 +0100 Subject: [PATCH] ramips: consolidate seama image build code Create a common template which has the required image build code defined. Add some new variables to pass individual parts to the seama recipes. Signed-off-by: Mathias Kresin --- target/linux/ramips/image/Makefile | 23 +++++++++++++++++++++-- target/linux/ramips/image/mt7620.mk | 13 ++----------- target/linux/ramips/image/mt7621.mk | 13 ++----------- target/linux/ramips/image/rt305x.mk | 13 ++----------- target/linux/ramips/image/rt3883.mk | 26 ++++---------------------- 5 files changed, 31 insertions(+), 57 deletions(-) diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index 5718558e91..3c30702ea7 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -9,6 +9,7 @@ include $(INCLUDE_DIR)/image.mk DEVICE_VARS += DTS IMAGE_SIZE NETGEAR_BOARD_ID NETGEAR_HW_ID DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR +DEVICE_VARS += SEAMA_SIGNATURE SEAMA_MTDBLOCK loadaddr-y := 0x80000000 loadaddr-$(CONFIG_TARGET_ramips_rt288x) := 0x88000000 @@ -29,6 +30,21 @@ define Device/Default IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) endef +define Device/seama + SEAMA_MTDBLOCK := 2 + IMAGES += factory.bin + + # 64 bytes offset: + # - 28 bytes seama_header + # - 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_SIZE) + IMAGE/factory.bin := \ + $$(IMAGE/default) | pad-rootfs -x 64 | seama | seama-seal | check-size $$$$(IMAGE_SIZE) + SEAMA_SIGNATURE := +endef + define Build/patch-dtb $(call Image/BuildDTB,../dts/$(DTS).dts,$@.dtb) $(STAGING_DIR_HOST)/bin/patch-dtb $@ $@.dtb @@ -86,12 +102,15 @@ define Build/poray-header endef define Build/seama - $(STAGING_DIR_HOST)/bin/seama -i $@ $(1) + $(STAGING_DIR_HOST)/bin/seama -i $@ \ + -m "dev=/dev/mtdblock/$(SEAMA_MTDBLOCK)" -m "type=firmware" mv $@.seama $@ endef define Build/seama-seal - $(call Build/seama,-s $@.seama $(1)) + $(STAGING_DIR_HOST)/bin/seama -i $@ -s $@.seama \ + -m "signature=$(SEAMA_SIGNATURE)" + mv $@.seama $@ endef define Build/wrg-header diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 6b65856281..e487f529d6 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -135,20 +135,11 @@ endef TARGET_DEVICES += db-wrt01 define Device/dch-m225 + $(Device/seama) DTS := DCH-M225 BLOCKSIZE := 4k - IMAGES += factory.bin + SEAMA_SIGNATURE := wapn22_dlink.2013gui_dap1320b IMAGE_SIZE := 6848k - IMAGE/sysupgrade.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) - IMAGE/factory.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ - append-rootfs | pad-rootfs -x 64 | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - seama-seal -m "signature=wapn22_dlink.2013gui_dap1320b" | \ - check-size $$$$(IMAGE_SIZE) DEVICE_TITLE := D-Link DCH-M225 DEVICE_PACKAGES := kmod-sound-core kmod-sound-mt7620 kmod-i2c-ralink endef diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 810890acfa..0edc8afcae 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -93,21 +93,12 @@ endef TARGET_DEVICES += 11acnas define Device/dir-860l-b1 + $(Device/seama) DTS := DIR-860L-B1 BLOCKSIZE := 64k - IMAGES += factory.bin + SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb KERNEL := kernel-bin | patch-dtb | relocate-kernel | lzma | uImage lzma IMAGE_SIZE := $(ralink_default_fw_size_16M) - IMAGE/sysupgrade.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) - IMAGE/factory.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ - append-rootfs | pad-rootfs -x 64 | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - seama-seal -m "signature=wrgac13_dlink.2013gui_dir860lb" | \ - check-size $$$$(IMAGE_SIZE) DEVICE_TITLE := D-Link DIR-860L B1 DEVICE_PACKAGES := kmod-mt76x2 kmod-usb3 kmod-usb-ledtrig-usbport wpad-basic endef diff --git a/target/linux/ramips/image/rt305x.mk b/target/linux/ramips/image/rt305x.mk index 5f514290dc..163726e1e1 100644 --- a/target/linux/ramips/image/rt305x.mk +++ b/target/linux/ramips/image/rt305x.mk @@ -262,21 +262,12 @@ endef TARGET_DEVICES += dir-600-b1 define Device/dir-610-a1 + $(Device/seama) DTS := DIR-610-A1 BLOCKSIZE := 4k - IMAGES += factory.bin + SEAMA_SIGNATURE := wrgn59_dlob.hans_dir610 KERNEL := $(KERNEL_DTB) IMAGE_SIZE := $(ralink_default_fw_size_4M) - IMAGE/sysupgrade.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) - IMAGE/factory.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ - append-rootfs | pad-rootfs -x 64 | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - seama-seal -m "signature=wrgn59_dlob.hans_dir610" | \ - check-size $$$$(IMAGE_SIZE) DEVICE_TITLE := D-Link DIR-610 A1 DEVICE_PACKAGES := kmod-ledtrig-netdev kmod-ledtrig-timer endef diff --git a/target/linux/ramips/image/rt3883.mk b/target/linux/ramips/image/rt3883.mk index f90fc6154f..abee533d01 100644 --- a/target/linux/ramips/image/rt3883.mk +++ b/target/linux/ramips/image/rt3883.mk @@ -18,20 +18,11 @@ endef TARGET_DEVICES += br-6475nd define Device/cy-swr1100 + $(Device/seama) DTS := CY-SWR1100 BLOCKSIZE := 64k KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) - IMAGE/factory.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ - append-rootfs | pad-rootfs -x 64 | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - seama-seal -m "signature=wrgnd10_samsung_ss815" | \ - check-size $$$$(IMAGE_SIZE) + SEAMA_SIGNATURE := wrgnd10_samsung_ss815 DEVICE_TITLE := Samsung CY-SWR1100 DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 swconfig endef @@ -39,20 +30,11 @@ TARGET_DEVICES += cy-swr1100 define Device/dir-645 + $(Device/seama) DTS := DIR-645 BLOCKSIZE := 4k KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) - IMAGE/factory.bin := \ - append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ - append-rootfs | pad-rootfs -x 64 | \ - seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \ - seama-seal -m "signature=wrgn39_dlob.hans_dir645" | \ - check-size $$$$(IMAGE_SIZE) + SEAMA_SIGNATURE := wrgn39_dlob.hans_dir645 DEVICE_TITLE := D-Link DIR-645 DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 swconfig endef