ar71xx: ubnt-m-xw: Fix factory image flashing using TFTP recovery
[openwrt/openwrt.git] / target / linux / ar71xx / image / generic-ubnt.mk
index 5db5c878fcdfb438ad67e21899cdcd62bfed0b03..84471a5c50f31e0565bf1ce6455598d6754fb945 100644 (file)
@@ -1,4 +1,9 @@
-DEVICE_VARS += UBNT_BOARD UBNT_CHIP UBNT_TYPE
+DEVICE_VARS += UBNT_BOARD UBNT_CHIP UBNT_TYPE UBNT_VERSION UBNT_REVISION
+
+# On M (XW) devices the U-Boot as of version 1.1.4-s1039 doesn't like
+# VERSION_DIST being on the place of major(?) version number, so we need to
+# use some number.
+UBNT_REVISION := $(VERSION_DIST)-$(REVISION)
 
 # mkubntimage is using the kernel image direct
 # routerboard creates partitions out of the ubnt header
@@ -17,7 +22,7 @@ define Build/mkubntimage-split
        dd if=$@ of=$@.old1 bs=1024k count=1; \
        dd if=$@ of=$@.old2 bs=1024k skip=1; \
        $(STAGING_DIR_HOST)/bin/mkfwimage \
-               -B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-$(VERSION_DIST)-$(REVISION) \
+               -B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v$(UBNT_VERSION)-$(UBNT_REVISION) \
                -k $@.old1 \
                -r $@.old2 \
                -o $@; \
@@ -36,12 +41,14 @@ endef
 # UBNT_BOARD e.g. one of (XS2, XS5, RS, XM)
 # UBNT_TYPE e.g. one of (BZ, XM, XW)
 # UBNT_CHIP e.g. one of (ar7240, ar933x, ar934x)
+# UBNT_VERSION e.g. one of (6.0.0, 8.5.0)
 define Device/ubnt
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2
   DEVICE_PROFILE := UBNT
   IMAGE_SIZE := 7552k
   MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
   UBNT_BOARD := XM
+  UBNT_VERSION := 6.0.0
   IMAGES := sysupgrade.bin factory.bin
   IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
   IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | mkubntimage-split
@@ -60,6 +67,8 @@ define Device/ubnt-xw
   DEVICE_PACKAGES += rssileds
   UBNT_TYPE := XW
   UBNT_CHIP := ar934x
+  UBNT_VERSION := 6.0.4
+  UBNT_REVISION := 42.$(UBNT_REVISION)
 endef
 
 define Device/ubnt-bz