From patchwork Thu Dec 21 22:59:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852171 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nC1Fw3dJ"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="JPzBhgMk"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3z2nHG5Gb6z9sNr for ; Fri, 22 Dec 2017 10:03:06 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject: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=TBFERjerm40b7Xxffp91D/5Ah4Tul3bzmxCuy1TcDOY=; b=nC1Fw3dJxn8sG+ vHxSS9N5azNGd5GYO0Punu/35W3gngUa0AUJkNfKad5cyud7cf3bSa6UiJlY5ngGcY3LcR1bR5Wgi TF7ivFiNs2QGECkqb/RXa4BTfNqS18hH+rZQyQBnM6K23t2xp8pzQg16xlz1r8cswxVZ52wWJAipa 3luHaJU6fKahrmEkNQzP9l9nfTGfcjMTP1yq3RQIZhX/ACvHLqTjb/zuxCXWwyKfxmTMVwsNn9ixA CyfIAKFIF+m+RJNWlwxbsTW1SpeYrySg06khJddIsS7TWmziLX0h7zolirV8nOrKR7yiorgPXf3wq 2SGnY+lndr+22gV7VxWw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eS9re-0008Ur-JX; Thu, 21 Dec 2017 23:02:58 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::10]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005W2-3U for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1513897187; s=domk; d=heimpold.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject; bh=LH81VWRCv2cibN2+DLOX3Ei4WFHl4vGbCYf4a5t2V4Y=; b=JPzBhgMkbE0PPqsCv25lr79c21/TMi7LqPyhgymNuzAP2vusLVLgELAy4jHL2QMFd/ Hm2NBsisUqAEevsDx/tGsQCuiIP+jSGq3itM8saLd2YJzAKoVpBp7Jy9t5dHCrSrCcH6 nmhYBJIOtGGNqyHtDimAVOcg/+GuhCOSBd5ww= X-RZG-AUTH: :O2kGeEG7b/pS1EW8QnKjhhg/vO4pzqdNytq77N6ZPUGwIpLOmsCM+BB/Jumg6xgvP7zTEmd6XE5ldAR8t4zBTaiOPbzqatzKSbW9t+O5KA== X-RZG-CLASS-ID: mo00 Received: from tonne.mhei.heimpold.itr (p200300C7CBD4A700505400FFFEE949E7.dip0.t-ipconnect.de [IPv6:2003:c7:cbd4:a700:5054:ff:fee9:49e7]) by smtp.strato.de (RZmta 42.14 AUTH) with ESMTPSA id Y00a23tBLMxlSWV (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 21 Dec 2017 23:59:47 +0100 (CET) Received: from kerker.mhei.heimpold.itr (kerker.mhei.heimpold.itr [192.168.8.1]) by tonne.mhei.heimpold.itr (Postfix) with ESMTP id B448F1CBA85; Thu, 21 Dec 2017 23:59:46 +0100 (CET) From: Michael Heimpold To: lede-dev@lists.infradead.org Date: Thu, 21 Dec 2017 23:59:34 +0100 Message-Id: <1513897174-20803-8-git-send-email-mhei@heimpold.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513897174-20803-1-git-send-email-mhei@heimpold.de> References: <1513897174-20803-1-git-send-email-mhei@heimpold.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171221_150000_631547_A460B1D8 X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a01:238:20a:202:5300:0:0:10 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [LEDE-DEV] [PATCH 7/7] firmware-tools/ptgen: allow individual partition alignment X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Heimpold MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org At the moment, the alignment parameter can only be given once and affects all partitions the same way. For example, it's not possible to align the first partition to 1 MiB start offet, while aligning the next ones to a 4 MiB boundary. This can be useful for example when defining a small bootloader partition within the first erase block on an eMMC, but then aligning the rootfs to next start of erase block. This change splits the global alignment parameter to individual ones which thus allows individual partition alignment. Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index d549faf..547b83a 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -53,17 +53,16 @@ struct pte { struct partinfo { unsigned long size; int type; + int kb_align; }; int verbose = 0; int active = 1; int heads = -1; int sectors = -1; -int kb_align = 0; struct partinfo parts[4]; char *filename = NULL; - /* * parse the size argument, which is either * a simple number (K assumed) or @@ -127,7 +126,8 @@ static inline unsigned long round_to_cyl(long sect) } /* round the sector number up to the kb_align boundary */ -static inline unsigned long round_to_kb(long sect) { +static inline unsigned long round_to_kb(long sect, int kb_align) +{ return ((sect - 1) / kb_align + 1) * kb_align; } @@ -150,12 +150,12 @@ static int gen_ptable(uint32_t signature, int nr) pte[i].type = parts[i].type; start = sect + ((i == 0) ? sectors : 0); - if (kb_align != 0) - start = round_to_kb(start); + if (parts[i].kb_align != 0) + start = round_to_kb(start, parts[i].kb_align); pte[i].start = cpu_to_le32(start); sect = start + parts[i].size * 2; - if (kb_align == 0) + if (parts[i].kb_align == 0) sect = round_to_cyl(sect); pte[i].length = cpu_to_le32(len = sect - start); @@ -198,15 +198,17 @@ fail: static void usage(char *prog) { - fprintf(stderr, "Usage: %s [-v] -h -s -o [-a 0..4] [-l ] [[-t ] -p ...] \n", prog); + fprintf(stderr, "Usage: %s [-v] -h -s -o [-a 0..4] [[-l ] [-t ] -p ...] \n", prog); exit(EXIT_FAILURE); } int main (int argc, char **argv) { + int kb_align = 0; char type = 0x83; int ch; int part = 0; + uint32_t signature = 0x5452574F; /* 'OWRT' */ while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vl:S:")) != -1) { @@ -229,6 +231,7 @@ int main (int argc, char **argv) exit(EXIT_FAILURE); } parts[part].size = to_kbytes(optarg); + parts[part].kb_align = kb_align; parts[part++].type = type; break; case 't':