From patchwork Sun Feb 10 13:34:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1039413 X-Patchwork-Delegate: chunkeey@googlemail.com 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=david-bauer.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QBRF40av"; 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 43y91G6LzNz9s7h for ; Mon, 11 Feb 2019 00:36: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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=onNT4+noGKQelJJU3iDuDaj+Fxn4i4HuOVIGBNSP+Vk=; b=QBRF40avZ4QD1j FVjrmfShpi1NXAS2W5w8uu8mktKFWoztxbPggr9HMi4tPq9cebuQjLMBERv/22M+BoxGcg5koOSXc URIajAN+QdKi6LDAPWMeTh/1+zf9Jj2mUAP3zyfGYRJLlhM44LgxgIiJMeV/ECQjvCbzT17rOkVtU 3KMvDaWmKcvTnlBH2EuQ76G/tulkhdOB5BpVls5Gj/ZmAk6PSsb+lJpyQnX0piwOa+e3hN5DONZLp 7K8Y31E8VfVIqMdHPDhFUBGxS+lvqN0q288cF2zN0wgE/d+r9o4ctZctaoNIeXtlK9Jmuysb43vyX HCmznqL0fnA8CwUJlcEA==; 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 1gspH5-0004MJ-7x; Sun, 10 Feb 2019 13:35:59 +0000 Received: from mars.blocktrron.ovh ([51.254.112.43] helo=mail.blocktrron.ovh) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gspGt-0004Kv-Po for openwrt-devel@lists.openwrt.org; Sun, 10 Feb 2019 13:35:50 +0000 Received: from dbauer-t470.ffda.io (unknown [IPv6:2001:67c:2ed8:100e:7d57:c3c6:de56:593c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.blocktrron.ovh (Postfix) with ESMTPSA id 6AD8D1E06E for ; Sun, 10 Feb 2019 14:35:40 +0100 (CET) From: David Bauer To: openwrt-devel@lists.openwrt.org Date: Sun, 10 Feb 2019 14:34:28 +0100 Message-Id: <20190210133430.23792-1-mail@david-bauer.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190210_053547_993814_17DEA4C1 X-CRM114-Status: UNSURE ( 9.55 ) 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 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH 1/3] scripts: make eva_ramboot.py offset configurable 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: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The current eva_ramboot.py script is currently only compatible with Lantiq based AVM devices. For IPQ40xx devices, the offset needs to be changed. Also an alignment is not necessary here. Adjust the script to be able to pass an optional offset to load the image to. In case no offset is provided, the script behaves exactly as before this commit. Signed-off-by: David Bauer --- scripts/flashing/eva_ramboot.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/scripts/flashing/eva_ramboot.py b/scripts/flashing/eva_ramboot.py index b825d2768b..b182f09d21 100755 --- a/scripts/flashing/eva_ramboot.py +++ b/scripts/flashing/eva_ramboot.py @@ -1,24 +1,32 @@ -#!/usr/bin/python +#!/usr/bin/env python3 + +import argparse from ftplib import FTP from sys import argv from os import stat -assert len(argv) == 3 -ip = argv[1] -image = argv[2] +parser = argparse.ArgumentParser(description='Tool to boot AVM EVA ramdisk images.') +parser.add_argument('ip', type=str, help='IP-address to transfer the image to') +parser.add_argument('image', type=str, help='Location of the ramdisk image') +parser.add_argument('--offset', type=lambda x: int(x,0), help='Offset to load the image to in hex format with leading 0x. Only needed for non-lantiq devices.') +args = parser.parse_args() -size = stat(image).st_size +size = stat(args.image).st_size # arbitrary size limit, to prevent the address calculations from overflows etc. assert size < 0x2000000 -# We need to align the address. A page boundary seems to be sufficient on 7362sl -# and 7412 -addr = ((0x8000000 - size) & ~0xfff) -haddr = 0x80000000 + addr -img = open(image, "rb") +if args.offset: + addr = size + haddr = args.offset +else: + # We need to align the address. + # A page boundary seems to be sufficient on 7362sl and 7412 + addr = ((0x8000000 - size) & ~0xfff) + haddr = 0x80000000 + addr -ftp = FTP(ip, 'adam2', 'adam2') +img = open(args.image, "rb") +ftp = FTP(args.ip, 'adam2', 'adam2') def adam(cmd): print("> %s"%(cmd))