From patchwork Mon Mar 4 14:14:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1051123 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=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O6Gezw9w"; 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 44Chnx6rpWz9s6w for ; Tue, 5 Mar 2019 01:13:25 +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:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fZo307cSDVFrU143/Do3JnzmLmAqt69YVolqYo//YV0=; b=O6Gezw9wtthNjx iVxe3f5ABO+7qs5tgh223obfMcX63glJ9NJJNreC3yDb1b2pZjIh4iEOixnwvi9+TNzRr6hwCrpQp a8d4eKtrZJY4i3hmbt+OxqcWtGJpJKR1sdI8+QiyMQSowKQnO1oU7KYAE01fhZNEXspS1UedPtJsp FC3PGqN1J7o1T/Ks8yd8jMJD8P8+lWhuarI58PiJg62d28WqX3aLrbvElfigfqiPuMwUAQRXjEJDV c80MQJuQDvM9rCk01oQz6BNxbYRcNI5mwKsM0J1EzlxKatMPA0RfjDeAIE+oLNS1ZNa1y70OMBiQq bAKMWW6JZqke2iFBHX4g==; 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 1h0oL7-00072d-Bj; Mon, 04 Mar 2019 14:13:09 +0000 Received: from mx-out.tlen.pl ([193.222.135.148]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0oL2-00071n-Qx for openwrt-devel@lists.openwrt.org; Mon, 04 Mar 2019 14:13:07 +0000 Received: (wp-smtpd smtp.tlen.pl 12768 invoked from network); 4 Mar 2019 15:12:57 +0100 Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 4 Mar 2019 15:12:57 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Mon, 4 Mar 2019 15:14:18 +0100 Message-Id: <20190304141418.7038-1-tomek_n@o2.pl> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-WP-MailID: f246e2cfa937fb93a2aa4e8e85d1f526 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 000000A [geME] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190304_061305_034816_A1749D40 X-CRM114-Status: UNSURE ( 9.37 ) 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 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH] ath79: routerstation: prepare to use sysupgrade-tar format image 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: Matt Merhar , Mathias Kresin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org In PR [1] introducing initial support for Ubiquiti RouterStation boards, Mathias Kresin suggested to replace the combined sysupgrade image with tarball generated by sysupgrade-tar.sh. This would simplify deployment of sysupgrade as the kernel size (needed to update FIS partition) could be simply calculated on the fly instead of reading value from combined image header. Unfortunately this would break sysupgrade compatibility between ar71xx image and ath79 image. Therefore this commit creates migration path to use new sysuprade image, it adds code to accept both of them at this moment. The plan is to keep it until new stable version is released. Then the image recipe should be changed to new format and compatibility code for old image removed. 1. https://github.com/openwrt/openwrt/pull/1237 Signed-off-by: Tomasz Maciej Nowak --- .../ath79/base-files/lib/upgrade/platform.sh | 25 ++++++++++++++++--- target/linux/ath79/image/generic-ubnt.mk | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/target/linux/ath79/base-files/lib/upgrade/platform.sh b/target/linux/ath79/base-files/lib/upgrade/platform.sh index a7cb455b8e..bc19149d5c 100644 --- a/target/linux/ath79/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/base-files/lib/upgrade/platform.sh @@ -7,11 +7,28 @@ REQUIRE_IMAGE_METADATA=1 routerstation_do_upgrade() { local append - local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null) + local sysup_file="$1" + local magic=$(get_magic_word "$sysup_file") - [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" - dd if="$1" bs=64k skip=1 2>/dev/null | \ - mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs + if [ "$magic" = "4349" ]; then + local kern_length=0x$(dd if="$sysup_file" bs=2 skip=1 count=4 2>/dev/null) + + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + dd if="$sysup_file" bs=64k skip=1 2>/dev/null | \ + mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs + + elif [ "$magic" = "7379" ]; then + local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$') + local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c) + + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \ + mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs + + else + echo "Unknown image, aborting!" + return 1 + fi } platform_check_image() { diff --git a/target/linux/ath79/image/generic-ubnt.mk b/target/linux/ath79/image/generic-ubnt.mk index 681c14dfb6..89b50de92f 100644 --- a/target/linux/ath79/image/generic-ubnt.mk +++ b/target/linux/ath79/image/generic-ubnt.mk @@ -189,7 +189,8 @@ define Device/ubnt_routerstation_common IMAGE_SIZE := 16128k IMAGES += factory.bin IMAGE/factory.bin := append-rootfs | pad-rootfs | mkubntimage | check-size $$$$(IMAGE_SIZE) - IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | combined-image | check-size $$$$(IMAGE_SIZE) | append-metadata + IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | combined-image | check-size $$$$(IMAGE_SIZE) +# IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) | sysupgrade-tar rootfs=$$$$@ | append-metadata KERNEL := kernel-bin | append-dtb | lzma | pad-to $$(BLOCKSIZE) KERNEL_INITRAMFS := kernel-bin | append-dtb endef