From patchwork Tue Apr 2 11:26:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1074265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ERU0iQU7"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44YRkt4k7Fz9sTQ for ; Tue, 2 Apr 2019 22:27:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0XjtkaSRGn17e4lxZfkwciAs/CmjrLivlinb0s52OqA=; b=ERU0iQU7DMEMxJ K4S/Uk9VCaDZZ+A+ntXSCc+ganXcTJ/Pgg2ilECMu+uMlNjQ1/QogZOFCaxdivmJ/qCb+76vmqri4 jv8slpPehDWygg4iYdy9fcHikQ9/UObGna6Hyo7LXBrS8IuPUilHY8tacmHQcDL/dxypkJ9wjh6Gk tww5HOjGacYdIE4rdkQ6c3mwJKMLvXkcgTkgWtKPDYg4fFn8J7/ylAZZooen33hv0fFUIkX6LLbT1 zESdJY59vttkDEORH4bU68UHoQM3cQ/gj7MBeD5emIOv/Y9WImW/vB7f89ci4dDawHa7Jg0A4KXkp b3ziHm1P9TtdLIQ1UZQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBHZN-0006oU-R1; Tue, 02 Apr 2019 11:27:09 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBHZ3-0006Kr-Rc for openwrt-devel@lists.openwrt.org; Tue, 02 Apr 2019 11:26:53 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 0D3804C06; Tue, 2 Apr 2019 13:26:48 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 3c20c9c2; Tue, 2 Apr 2019 13:26:46 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Tue, 2 Apr 2019 13:26:41 +0200 Message-Id: <1554204403-23685-2-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1554204403-23685-1-git-send-email-ynezz@true.cz> References: <1554204403-23685-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190402_042650_272523_A645C367 X-CRM114-Status: UNSURE ( 8.70 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH 1/2] ar71xx: ubnt-m-xw: Fix factory image flashing using TFTP recovery X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This is backport of the same functionality in ath79, from commit d42a7c469 ("ath79: ubnt-m-xw: Fix factory image flashing using TFTP recovery method") Ubiquity allows flashing of unsigned factory images via TFTP recovery method[1]. They claim in airOS v6.0.7 release changelog[2] following: All future airOS versions will be signed in this way and not allow unsigned firmware to be loaded except via TFTP. U-boot bootloader on M-XW devices expects factory image revision version in specific format. On airOS v6.1.7 with `U-Boot 1.1.4-s1039 (May 24 2017 - 15:58:18)` bootloader checks if the revision major(?) number is actually a number, but in currently generated images there's OpenWrt text and so the check fails: Hit any key to stop autoboot: 0 Setting default IP 192.168.1.20 Starting TFTP server... Receiving file from 192.168.1.25:38438 Received 4981148 bytes Firmware check failed! (1) By placing arbitrary correct number first in major version, we make the bootloader happy and we can flash factory images over TFTP again: Received 3801500 bytes Firmware Version: XW.ar934x.v6.0.4-42.OpenWrt-r9766+2-be42e44 Setting U-Boot environment variables Un-Protected 1 sectors Erasing Flash.... done Patch provided by AREDN[3] project, tested on Bullet M2 XW. 1. https://help.ubnt.com/hc/en-us/articles/204910124-UniFi-TFTP-Recovery-for-Bricked-Access-Points 2. https://dl.ubnt.com/firmwares/XW-fw/v6.0.7/changelog.txt 3. https://github.com/aredn Signed-off-by: Petr Štetiar --- target/linux/ar71xx/image/generic-ubnt.mk | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/image/generic-ubnt.mk b/target/linux/ar71xx/image/generic-ubnt.mk index 5db5c87..84471a5 100644 --- a/target/linux/ar71xx/image/generic-ubnt.mk +++ b/target/linux/ar71xx/image/generic-ubnt.mk @@ -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