Skip to content

Commit

Permalink
build: move mktplinkfw2 related commands to image-commands.mk
Browse files Browse the repository at this point in the history
There are already two targets (lantiq, ramips) which use mktplinkfw2
tool for creating images. This de-duplicates code, introduces two new
build commands: tplink-v2-header, tplink-v2-image and makes use of
them in place of old, (sub)target specific ones.

Signed-off-by: Piotr Dymacz <[email protected]>
  • Loading branch information
pepe2k committed Jun 29, 2017
1 parent 7d6c63d commit 5b7f592
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
14 changes: 14 additions & 0 deletions include/image-commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,20 @@ define Build/sysupgrade-tar
$@
endef

define Build/tplink-v2-header
$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
-c -V "ver. 2.0" -B $(TPLINK_BOARD_ID) $(1) -k $@ -o $@.new
@mv $@.new $@
endef

define Build/tplink-v2-image
$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
-a 0x4 -j -V "ver. 2.0" -B $(TPLINK_BOARD_ID) $(1) \
-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o $@.new
cat $@.new >> $@
rm -rf $@.new
endef

json_quote=$(subst ','\'',$(subst ",\",$(1)))
#")')
metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
Expand Down
25 changes: 8 additions & 17 deletions target/linux/lantiq/image/tp-link.mk
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
define Build/tplink-fw
mktplinkfw2 -c -B $(BOARD_ID) -s \
-k $@ -o $@.new
mv $@.new $@
endef

define Build/mktplinkfw2
mktplinkfw2 -B $(BOARD_ID) -s -a 0x4 -j \
-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) \
-o $@
endef
DEVICE_VARS += BOARD_ID
DEVICE_VARS += TPLINK_BOARD_ID

define Device/lantiqTpLink
KERNEL := kernel-bin | append-dtb | lzma
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | tplink-fw
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | \
tplink-v2-header -s -V "ver. 1.0"
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := mktplinkfw2 | append-metadata | check-size $$$$(IMAGE_SIZE)
IMAGE/sysupgrade.bin := tplink-v2-image -s -V "ver. 1.0" | \
append-metadata | check-size $$$$(IMAGE_SIZE)
endef

define Device/TDW8970
$(Device/lantiqTpLink)
DEVICE_PROFILE := TDW8970
BOARD_ID := TD-W8970v1
TPLINK_BOARD_ID := TD-W8970v1
IMAGE_SIZE := 7680k
DEVICE_TITLE := TP-LINK TD-W8970
DEVICE_PACKAGES:= kmod-ath9k wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
Expand All @@ -30,7 +21,7 @@ endef
define Device/TDW8980
$(Device/lantiqTpLink)
DEVICE_PROFILE := TDW8980
BOARD_ID := TD-W8980v1
TPLINK_BOARD_ID := TD-W8980v1
IMAGE_SIZE := 7680k
DEVICE_TITLE := TP-LINK TD-W8980
DEVICE_PACKAGES:= kmod-ath9k kmod-owl-loader wpad-mini kmod-usb-dwc2 kmod-usb-ledtrig-usbport
Expand All @@ -39,7 +30,7 @@ endef
define Device/VR200v
$(Device/lantiqTpLink)
DEVICE_PROFILE := VR200v
BOARD_ID := ArcherVR200V
TPLINK_BOARD_ID := ArcherVR200V
IMAGE_SIZE := 15808k
DEVICE_TITLE := TP-LINK Archer VR200v
DEVICE_PACKAGES:= kmod-usb-dwc2 kmod-usb-ledtrig-usbport
Expand Down
24 changes: 12 additions & 12 deletions target/linux/ramips/image/mt7620.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# MT7620A Profiles
#

define Build/tplink-header
$(STAGING_DIR_HOST)/bin/mktplinkfw2 -a 0x4 -V "ver. 2.0" -B $(1) \
-o $@.new -k $@ -r $(IMAGE_ROOTFS) && mv $@.new $@
endef
DEVICE_VARS += TPLINK_BOARD_ID

define Build/elecom-header
cp $@ $(KDIR)/v_0.0.0.bin
Expand All @@ -31,10 +28,11 @@ TARGET_DEVICES += ai-br100
define Device/ArcherC20i
DTS := ArcherC20i
SUPPORTED_DEVICES := c20i
TPLINK_BOARD_ID := ArcherC20i
KERNEL := $(KERNEL_DTB)
KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherC20i -c
IMAGE/factory.bin := append-kernel | tplink-header ArcherC20i -j
IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC20i -j -s | append-metadata
KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-v2-header
IMAGE/factory.bin := tplink-v2-image
IMAGE/sysupgrade.bin := tplink-v2-image -s | append-metadata
IMAGES += factory.bin
DEVICE_TITLE := TP-Link ArcherC20i
endef
Expand All @@ -43,10 +41,11 @@ TARGET_DEVICES += ArcherC20i
define Device/ArcherC50
DTS := ArcherC50
SUPPORTED_DEVICES := c50
TPLINK_BOARD_ID := ArcherC50
KERNEL := $(KERNEL_DTB)
KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherC50 -c
IMAGE/factory.bin := append-kernel | tplink-header ArcherC50 -j
IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC50 -j -s | append-metadata
KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-v2-header
IMAGE/factory.bin := tplink-v2-image
IMAGE/sysupgrade.bin := tplink-v2-image -s | append-metadata
IMAGES += factory.bin
DEVICE_TITLE := TP-Link ArcherC50
endef
Expand All @@ -55,9 +54,10 @@ TARGET_DEVICES += ArcherC50
define Device/ArcherMR200
DTS := ArcherMR200
SUPPORTED_DEVICES := mr200
TPLINK_BOARD_ID := ArcherMR200
KERNEL := $(KERNEL_DTB)
KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherMR200 -c
IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherMR200 -j -s | append-metadata
KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-v2-header
IMAGE/sysupgrade.bin := tplink-v2-image -s | append-metadata
DEVICE_PACKAGES := kmod-usb2 kmod-usb-net kmod-usb-net-rndis kmod-usb-serial kmod-usb-serial-option adb-enablemodem
DEVICE_TITLE := TP-Link ArcherMR200
endef
Expand Down

0 comments on commit 5b7f592

Please sign in to comment.