From patchwork Thu Jun 4 08:52:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 480562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D45DA140129 for ; Thu, 4 Jun 2015 18:53:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=OM1ujs/O; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 222F928C0AB; Thu, 4 Jun 2015 10:51:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, T_DKIM_INVALID autolearn=no version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 3BA2728C0A1 for ; Thu, 4 Jun 2015 10:51:12 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -8.5 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 4 Jun 2015 10:51:11 +0200 (CEST) Received: by wiwd19 with SMTP id d19so14102793wiw.0 for ; Thu, 04 Jun 2015 01:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=LAgULJojV3zHQbZccolvb4YFW+/Wn6acbkVyPN2sTgY=; b=OM1ujs/Op/e8c/7KNioEkV3Cmotna1lsshEubHPG0gHpHgzRVtjVtlmVLlCf9iF1UW 68xTNAKiWTGLNe3hOEmOutSFAdKi9IPIk9QmZeAIHt0OzplkeiffSwUajEurQlaAtFkb 2cWbc6P/SgbW03vUPZ8xuOnhjqXTR6kKXic/8LfWHs3KQrHrgWIpxC/8E+uFb2lDlPDo d1pOk6W3SYqi+mLY68O+KPbddUjTc7o4pKlDRNLPMbnjjpRBgJuRv+BFDwvNAOdlfKVG +0TY+R/AS8K9Ujofh5CmqOG+ZeQNPnMIvLgVSYB3YAt3OerRVnXiKKlsqeNmVpN+NJus PWNg== X-Received: by 10.180.208.7 with SMTP id ma7mr51001231wic.0.1433407966246; Thu, 04 Jun 2015 01:52:46 -0700 (PDT) Received: from linux-tdhb.lan (acyq161.neoplus.adsl.tpnet.pl. [83.11.200.161]) by mx.google.com with ESMTPSA id ul1sm4723969wjc.30.2015.06.04.01.52.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 01:52:45 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: openwrt-devel@lists.openwrt.org, Felix Fietkau , John Crispin , Jo-Philipp Wich Date: Thu, 4 Jun 2015 10:52:32 +0200 Message-Id: <1433407952-22460-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1433407952-22460-1-git-send-email-zajec5@gmail.com> References: <1433325916-24324-1-git-send-email-zajec5@gmail.com> <1433407952-22460-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 Subject: [OpenWrt-Devel] [PATCH V2 2/2] brcm47xx: extract TRX from image on the fly X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Extracting TRX to separated file in /tmp/ requires extra RAM which may not be available on some chepaer devices. Instead of that lets pass a proper extracting command to the default_do_upgrade. Signed-off-by: Rafał Miłecki --- V2: Add this patch to show why we need 1/2 :) --- target/linux/brcm47xx/base-files/lib/upgrade/platform.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh index a346933..14fd5c8 100644 --- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh @@ -133,25 +133,26 @@ platform_check_image() { return $error } -platform_extract_trx_from_chk() { +platform_trx_from_chk_cmd() { local header_len=$((0x$(get_magic_long_at "$1" 4))) - dd if="$1" of="$2" bs=$header_len skip=1 + echo -n dd bs=$header_len skip=1 } -platform_extract_trx_from_cybertan() { - dd if="$1" of="$2" bs=32 skip=1 +platform_trx_from_cybertan_cmd() { + echo -n dd bs=32 skip=1 } platform_do_upgrade() { local file_type=$(brcm47xx_identify "$1") local trx="$1" + local cmd="" case "$file_type" in - "chk") trx="/tmp/$(basename $1).trx"; platform_extract_trx_from_chk "$1" "$trx";; - "cybertan") trx="/tmp/$(basename $1).trx"; platform_extract_trx_from_cybertan "$1" "$trx";; + "chk") cmd=$(platform_trx_from_chk_cmd "$trx");; + "cybertan") cmd=$(platform_trx_from_cybertan_cmd "$trx");; esac shift - default_do_upgrade "$trx" "$@" + default_do_upgrade "$trx" "$cmd" }