ath79: use ARTIFACTS for initramfs-factory of ELECOM devices
authorINAGAKI Hiroshi <musashino.open@gmail.com>
Mon, 1 Aug 2022 04:40:10 +0000 (13:40 +0900)
committerHauke Mehrtens <hauke@hauke-m.de>
Wed, 19 Oct 2022 20:58:12 +0000 (22:58 +0200)
Use ARTIFACTS to generate factory image of the following ELECOM devices
instead of redundant recipe which generate on KERNEL_INITRAMFS.

- ELECOM WRC-300GHBK2-I
- ELECOM WRC-1750GHBK2-I/C

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
target/linux/ath79/image/generic.mk

index 9d8b70712de1ee01139ae5acef5500c95df37e06..7b760abc3e8930c710fd15dbdf63ff5a76837ad7 100644 (file)
@@ -11,24 +11,6 @@ DEVICE_VARS += KERNEL_INITRAMFS_PREFIX DAP_SIGNATURE
 DEVICE_VARS += EDIMAX_HEADER_MAGIC EDIMAX_HEADER_MODEL
 DEVICE_VARS += OPENMESH_CE_TYPE ZYXEL_MODEL_STRING
 
-define Build/add-elecom-factory-initramfs
-  $(eval edimax_model=$(word 1,$(1)))
-  $(eval product=$(word 2,$(1)))
-
-  $(STAGING_DIR_HOST)/bin/mkedimaximg \
-       -b -s CSYS -m $(edimax_model) \
-       -f 0x70000 -S 0x01100000 \
-       -i $@ -o $@.factory
-
-  $(call Build/elecom-product-header,$(product) $@.factory)
-
-  if [ "$$(stat -c%s $@.factory)" -le $$(($(subst k,* 1024,$(subst m, * 1024k,$(IMAGE_SIZE))))) ]; then \
-       mv $@.factory $(BIN_DIR)/$(KERNEL_INITRAMFS_PREFIX)-factory.bin; \
-  else \
-       echo "WARNING: initramfs kernel image too big, cannot generate factory image" >&2; \
-  fi
-endef
-
 define Build/addpattern
        -$(STAGING_DIR_HOST)/bin/addpattern -B $(ADDPATTERN_ID) \
                -v v$(ADDPATTERN_VERSION) -i $@ -o $@.new
@@ -1106,8 +1088,12 @@ define Device/elecom_wrc-1750ghbk2-i
   DEVICE_VENDOR := ELECOM
   DEVICE_MODEL := WRC-1750GHBK2-I/C
   IMAGE_SIZE := 15808k
-  KERNEL_INITRAMFS := $$(KERNEL) | pad-to 2 | \
-       add-elecom-factory-initramfs RN68 WRC-1750GHBK2
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+  ARTIFACTS := initramfs-factory.bin
+  ARTIFACT/initramfs-factory.bin := append-image initramfs-kernel.bin | \
+       pad-to 2 | edimax-header -b -s CSYS -m RN68 -f 0x70000 -S 0x01100000 | \
+       elecom-product-header WRC-1750GHBK2 | check-size
+endif
   DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca988x-ct
 endef
 TARGET_DEVICES += elecom_wrc-1750ghbk2-i
@@ -1117,8 +1103,12 @@ define Device/elecom_wrc-300ghbk2-i
   DEVICE_VENDOR := ELECOM
   DEVICE_MODEL := WRC-300GHBK2-I
   IMAGE_SIZE := 7616k
-  KERNEL_INITRAMFS := $$(KERNEL) | pad-to 2 | \
-       add-elecom-factory-initramfs RN51 WRC-300GHBK2-I
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+  ARTIFACTS := initramfs-factory.bin
+  ARTIFACT/initramfs-factory.bin := append-image initramfs-kernel.bin | \
+       pad-to 2 | edimax-header -b -s CSYS -m RN51 -f 0x70000 -S 0x01100000 | \
+       elecom-product-header WRC-300GHBK2-I | check-size
+endif
 endef
 TARGET_DEVICES += elecom_wrc-300ghbk2-i