ipq40xx: RT-AC58U: "easy install" factory.trx
[openwrt/staging/chunkeey.git] / target / linux / ipq40xx / image / Makefile
index 51e8bcc7e36df300debbea28845e70fb06388e60..54b3e8c1e4ecb622a1ffeea4cb54a506f384a947 100644 (file)
@@ -75,6 +75,11 @@ define Build/mkmylofw_32m
                -s 0x2000000 -p0x180000:$$newsize:al:0x80208000:"OpenWrt":$@ \
                $@.new
        @mv $@.new $@
+
+define Build/prepend-factory-uboot
+       mv $@ $@.bak
+       dd if=$(UBOOT_PATH) bs=1M count=1 conv=sync > $@
+       cat $@.bak >> $@
 endef
 
 define Build/qsdk-ipq-factory-nand-askey
@@ -197,8 +202,15 @@ define Device/asus_rt-ac58u
 #      to add a version... or we are very careful not to add '\0' into that
 #      string and call it a day.... Yeah, we do the latter!
        UIMAGE_NAME:=$(shell echo -e '\03\01\01\01RT-AC58U')
+       IMAGES := sysupgrade.bin factory.trx
        DEVICE_PACKAGES := -kmod-ath10k-ct kmod-ath10k-ct-smallbuffers \
                kmod-usb-ledtrig-usbport
+#      The factory image uses a legacy uImage to wrap the firmware
+#      That's why we need two uImage headers at the back.
+       UBOOT_PATH := $(STAGING_DIR_IMAGE)/uboot-rt-ac58u.bin
+       IMAGE/factory.trx := sysupgrade-tar | append-metadata | uImage none | \
+            prepend-factory-uboot | uImage none | uImage none | \
+            check-size $$$$(IMAGE_SIZE)
 endef
 TARGET_DEVICES += asus_rt-ac58u