ramips: consolidate seama image build code
authorMathias Kresin <dev@kresin.me>
Sat, 29 Dec 2018 18:25:00 +0000 (19:25 +0100)
committerMathias Kresin <dev@kresin.me>
Sun, 30 Dec 2018 19:08:12 +0000 (20:08 +0100)
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 <dev@kresin.me>
target/linux/ramips/image/Makefile
target/linux/ramips/image/mt7620.mk
target/linux/ramips/image/mt7621.mk
target/linux/ramips/image/rt305x.mk
target/linux/ramips/image/rt3883.mk

index 5718558e9166c8d21e1ed71bbc45b4abef6cca43..3c30702ea73935901e9c62d1707029e92fa83f67 100644 (file)
@@ -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
index 6b65856281e18530689837b3d3a5527dff201fce..e487f529d6daf417434f73192213652f9bb1a918 100644 (file)
@@ -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
index 810890acfa1f74e97778da3550faa5c2efb6f2c8..0edc8afcaee4eb9bce433239cc55d2bb594ac65f 100644 (file)
@@ -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
index 5f514290dc7235747b901a99b7b5f0384dc8d386..163726e1e1f1ae36e160011f9f3ca2798559b1cd 100644 (file)
@@ -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
index f90fc6154fdae04f96d6faf832dbc3a7c62f375e..abee533d01019410de6bd662b5b75e9413fd6357 100644 (file)
@@ -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