From patchwork Thu Dec 21 22:59:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852167 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="i5tk/jl1"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="fom5An9S"; 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 3z2nFH4mqwz9ryQ for ; Fri, 22 Dec 2017 10:01:23 +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=QnDUPU70iAizhv5IIAn4aCfJJbClps+0NN4bU2lbh+I=; b=i5tk/jl1Cj3SJj UPsuyXTq8aHJ3Kk5tVhjgph9g+qAe2zefm5Tt5CnpQZeOHuFCTTjKbr9z+D9UmPpoG32OolGvlbsq 49LEEWy41aPd/SNycbh+Pk35muOVF+YMARZ91khSr+ph57rhDOSHW11IKbK2tKoQcKAJJ+9HFvAnW tvaVsNy6UoQ6wmaxgJlycV2FpC2MOYQRUCIFA+eQoV3Kv6xUhTfVYnIEi3g1rQKvpq3gxmp+Nhmc1 ayfhrJJ5Kor5vtyLo684FARFpwRjZywn9vTsaAkPOaBFZyZ5tPzrMo2Hci3PKTiypZcMPkS4q21ih R8D7mTSZctSsL2MyqXdQ==; 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 1eS9pt-00078u-Gx; Thu, 21 Dec 2017 23:01:09 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::3]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005Vy-3K for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:07 +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=DekTs+UK2ac65L8fscZfhHQ5oD/QA/aCn9m0qNWXFhU=; b=fom5An9ScDYgyLlrsewNxJLiqVTzKspBsJWyKHaMRgVhNvNccCubbUCD+/f0DuboST pqkAZzw7FaXe+K8RQEQamx1+ItEqie5Wxg1+RA16edZ+uQm5BRI2+d8+D/GWweE3aye0 jEJ7+OvIh35LolpsAmnYuC66oZH0V9+S6ql88= 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 Y00a23tBLMxkSWQ (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:46 +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 4CABB1C23FD; 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:28 +0100 Message-Id: <1513897174-20803-2-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_589612_7F116F05 X-CRM114-Status: GOOD ( 13.42 ) 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:3 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 1/7] firmware-tools/ptgen: fix minor coding style issues 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 Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 60 +++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 8466d35..93d66eb 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -1,4 +1,4 @@ -/* +/* * ptgen - partition table generator * Copyright (C) 2006 by Felix Fietkau * @@ -9,12 +9,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -63,25 +63,26 @@ struct partinfo parts[4]; char *filename = NULL; -/* +/* * parse the size argument, which is either * a simple number (K assumed) or * K, M or G * * returns the size in KByte */ -static long to_kbytes(const char *string) { +static long to_kbytes(const char *string) +{ int exp = 0; long result; char *end; result = strtoul(string, &end, 0); switch (tolower(*end)) { - case 'k' : - case '\0' : exp = 0; break; - case 'm' : exp = 1; break; - case 'g' : exp = 2; break; - default: return 0; + case 'k' : + case '\0' : exp = 0; break; + case 'm' : exp = 1; break; + case 'g' : exp = 2; break; + default: return 0; } if (*end) @@ -99,9 +100,10 @@ static long to_kbytes(const char *string) { } /* convert the sector number into a CHS value for the partition table */ -static void to_chs(long sect, unsigned char chs[3]) { +static void to_chs(long sect, unsigned char chs[3]) +{ int c,h,s; - + s = (sect % sectors) + 1; sect = sect / sectors; h = sect % heads; @@ -116,10 +118,11 @@ static void to_chs(long sect, unsigned char chs[3]) { } /* round the sector number up to the next cylinder */ -static inline unsigned long round_to_cyl(long sect) { +static inline unsigned long round_to_cyl(long sect) +{ int cyl_size = heads * sectors; - return sect + cyl_size - (sect % cyl_size); + return sect + cyl_size - (sect % cyl_size); } /* round the sector number up to the kb_align boundary */ @@ -131,7 +134,7 @@ static inline unsigned long round_to_kb(long sect) { static int gen_ptable(uint32_t signature, int nr) { struct pte pte[4]; - unsigned long sect = 0; + unsigned long sect = 0; int i, fd, ret = -1, start, len; memset(pte, 0, sizeof(struct pte) * 4); @@ -140,22 +143,27 @@ static int gen_ptable(uint32_t signature, int nr) fprintf(stderr, "Invalid size in partition %d!\n", i); return -1; } + pte[i].active = ((i + 1) == active) ? 0x80 : 0; pte[i].type = parts[i].type; + start = sect + sectors; if (kb_align != 0) start = round_to_kb(start); pte[i].start = cpu_to_le32(start); + sect = start + parts[i].size * 2; if (kb_align == 0) sect = round_to_cyl(sect); pte[i].length = cpu_to_le32(len = sect - start); + to_chs(start, pte[i].chs_start); to_chs(start + len - 1, pte[i].chs_end); + if (verbose) - fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", i, (long) start * 512, ((long) start + (long) len) * 512, (long) len * 512); - printf("%ld\n", ((long) start * 512)); - printf("%ld\n", ((long) len * 512)); + fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", i, (long)start * 512, ((long)start + (long)len) * 512, (long)len * 512); + printf("%ld\n", (long)start * 512); + printf("%ld\n", (long)len * 512); } if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { @@ -179,7 +187,7 @@ static int gen_ptable(uint32_t signature, int nr) fprintf(stderr, "write failed.\n"); goto fail; } - + ret = 0; fail: close(fd); @@ -188,7 +196,7 @@ 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(1); } @@ -208,10 +216,10 @@ int main (int argc, char **argv) verbose++; break; case 'h': - heads = (int) strtoul(optarg, NULL, 0); + heads = (int)strtoul(optarg, NULL, 0); break; case 's': - sectors = (int) strtoul(optarg, NULL, 0); + sectors = (int)strtoul(optarg, NULL, 0); break; case 'p': if (part > 3) { @@ -222,15 +230,15 @@ int main (int argc, char **argv) parts[part++].type = type; break; case 't': - type = (char) strtoul(optarg, NULL, 16); + type = (char)strtoul(optarg, NULL, 16); break; case 'a': - active = (int) strtoul(optarg, NULL, 0); + active = (int)strtoul(optarg, NULL, 0); if ((active < 0) || (active > 4)) active = 0; break; case 'l': - kb_align = (int) strtoul(optarg, NULL, 0) * 2; + kb_align = (int)strtoul(optarg, NULL, 0) * 2; break; case 'S': signature = strtoul(optarg, NULL, 0); @@ -241,7 +249,7 @@ int main (int argc, char **argv) } } argc -= optind; - if (argc || (heads <= 0) || (sectors <= 0) || !filename) + if (argc || (heads <= 0) || (sectors <= 0) || !filename) usage(argv[0]); return gen_ptable(signature, part); From patchwork Thu Dec 21 22:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852168 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="Cyu1iRlA"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="S4vMb3HF"; 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 3z2nFY2qLVz9s7F for ; Fri, 22 Dec 2017 10:01:37 +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=2+wOEHWC86taIAWp+6cwCiCdyXBVCjesp+/ljZK7W9M=; b=Cyu1iRlAZrM6t8 E386O4PMTon5ND0YE/8zXOCr+b3CyDbFKfV10doegGH6GNqDQVt27tRz/A/Xx/qtmwnVgmtP6+/9V mbSD53sy8AfOZzeD/UcxblDorfdws4/8/54lbfX/26eiuPdGH1xcNVK90/o6BHjweIGyeoYwjWiQ1 INpoUd5abo5AV9JGnM5n2wuUno4hY/sLuhBmePf0VpRz7cUrK/K8Z4zuV5BNezBP0aMaMA6BU9VOZ 0GujbzC6GvEXlAIr2czFBmrCJtoFYxDeke/kwBJ3l19GgR6wy1y1YH1qxWhEe5Dc9RfjmngKsHKHy w2YRPBuG7TdyblQxTKXg==; 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 1eS9qH-0007b7-1S; Thu, 21 Dec 2017 23:01:33 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::12]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005Vu-3T for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:07 +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=2auPhTTi8mZFayUrfKheyi4x6//RVXFAZ1eOfVRCToU=; b=S4vMb3HFOqYvZ4priR57sWL4KrI3jRnrvDpGz4kJgcThINN1QUB15y/fPUAk6PrFAL ZxrO8ITapmiK8NOgJxtJMskYgxnGommsVhSsmV29sQbUUsCjDEHloF4j4Dku8WjbicgD KutXRVfPZO3ZDhTuYHjyFN9ZQY0thngh5IAxg= X-RZG-AUTH: :O2kGeEG7b/pS1EW8QnKjhhg/vO4pzqdNytq77N6ZPUGwIpLOmsCM+BB/JuKj9RosYI7owD/XKfycfQ== X-RZG-CLASS-ID: mo00 Received: from tonne.mhei.heimpold.itr (p5DC3A286.dip0.t-ipconnect.de [93.195.162.134]) by smtp.strato.de (RZmta 42.14 DYNA|AUTH) with ESMTPSA id Y00a23tBLMxkSWP (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:46 +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 5FC761CBA85; 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:29 +0100 Message-Id: <1513897174-20803-3-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_580159_9A33500E X-CRM114-Status: UNSURE ( 9.44 ) X-CRM114-Notice: Please train this message. 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:12 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 2/7] firmware-tools/ptgen: do not truncate the output file 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 image file operated on is always truncated to 512 bytes. This limits the usage of ptgen somewhat. This change allows to use ptgen on existing, larger image files. In this case, only the partition table is written/updated while the rest of the image file is left alone. Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 93d66eb..ff97cd5 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -166,7 +166,7 @@ static int gen_ptable(uint32_t signature, int nr) printf("%ld\n", (long)len * 512); } - if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { + if ((fd = open(filename, O_WRONLY|O_CREAT, 0644)) < 0) { fprintf(stderr, "Can't open output file '%s'\n",filename); return -1; } From patchwork Thu Dec 21 22:59:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852169 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="McBMhBU7"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="K9d7Zc21"; 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 3z2nG44GTyz9ryQ for ; Fri, 22 Dec 2017 10:02:04 +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=Yl3l5x4antnrtBFcvQi4fbOqH5UT4eUjM2hbUMOEJfo=; b=McBMhBU7JfkAPD mTcrVtf7AYrRvs40FExksGLKBcAotRkZxdui1rbeCkenemEefJ/d1LHjNpAlMf8upFRBrRNC+x42u VqnL8F7tcWcWYQB2hegPI0m2BOrKPcALJTYpdNDEE0AvtaXzcCLUsL9bubdcx8U40qrWacCVAoQi2 jOgiEfUB0F/XivTkjGzCE4xg0TZR0x2Y3mlhgPFiWxA6LHuPzCEB4nXr4sR6U5aYkMXZj2hsTHjeL s7P04n+vlfTsO7Nt/rus9nXdUWUst3oTFwOqcoLrlAiOlMom6k9KBwdOTXohgaQozYlgaYe3k4deY q08s50ya557p6/gtIqiA==; 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 1eS9qb-0007r2-8i; Thu, 21 Dec 2017 23:01:53 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::4]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005Vw-2u for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:07 +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=UWKo6HRPv+r0QLcSpRCob9Bmq9PVrh6nbTu6Pmb+qyw=; b=K9d7Zc21squWL57d6xYLg1176K1gX1hrJHkx8qijItp9A1LmC57HQNqujhwM/jcFtG WR9e5qSFrtg+3MG0Bq7TjQ+Vql8/l+BwTJDKpvd5YD+sWli3oQL3H9gyrAsn3SX35e23 1JVIyq1lQ6gketVpG9v+GHWHnzRDX2bZ3FNHo= X-RZG-AUTH: :O2kGeEG7b/pS1EW8QnKjhhg/vO4pzqdNytq77N6ZPUGwIpLOmsCM+BB/JuKj9RosYI7owD/XKfycfQ== X-RZG-CLASS-ID: mo00 Received: from tonne.mhei.heimpold.itr (p5DC3A286.dip0.t-ipconnect.de [93.195.162.134]) by smtp.strato.de (RZmta 42.14 DYNA|AUTH) with ESMTPSA id Y00a23tBLMxkSWR (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:46 +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 72EA11CBAAB; 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:30 +0100 Message-Id: <1513897174-20803-4-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_599218_3823A6FB X-CRM114-Status: UNSURE ( 6.09 ) X-CRM114-Notice: Please train this message. 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:4 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 3/7] firmware-tools/ptgen: use portable exit codes 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 Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index ff97cd5..b5e317d 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -197,7 +197,7 @@ fail: static void usage(char *prog) { fprintf(stderr, "Usage: %s [-v] -h -s -o [-a 0..4] [-l ] [[-t ] -p ...] \n", prog); - exit(1); + exit(EXIT_FAILURE); } int main (int argc, char **argv) @@ -224,7 +224,7 @@ int main (int argc, char **argv) case 'p': if (part > 3) { fprintf(stderr, "Too many partitions\n"); - exit(1); + exit(EXIT_FAILURE); } parts[part].size = to_kbytes(optarg); parts[part++].type = type; @@ -252,5 +252,5 @@ int main (int argc, char **argv) if (argc || (heads <= 0) || (sectors <= 0) || !filename) usage(argv[0]); - return gen_ptable(signature, part); + return gen_ptable(signature, part) ? EXIT_FAILURE : EXIT_SUCCESS; } From patchwork Thu Dec 21 22:59:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852170 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="RHI1MBYV"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="WYmjRCsP"; 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 3z2nGS2MyDz9ryQ for ; Fri, 22 Dec 2017 10:02:24 +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=d4R1rrThKNPLB5Dj1njqxO+24AGrmN9mk2YUriADFdE=; b=RHI1MBYV5PIlun L6bmb2OAeow9/mKAHgbKERRzCA+phE4bc3uKiv6lUTsE8/3nIQ+my3MsdMMaqXLevhX+QdP81m/0n NdVnxkbId/9DFwSt5sTQRgvKQ6lvZ/DoTg7ZeOTvevBhWyN1tX6KzhAukEOrmGM5ee4Vo2wH0/UHP FScGL6Z/n8yR39BaK+4tVL2zBO1wPjNO6ci1FysgOpVE2gAZzGhnklqOjxiVqSaAeP05oKAfUYKwl NEhJ9MUeP7rvTjYkubWbRH9Ntgs2ceQiCbWzbXToxa7/vLb+1RCCxi8U6wIPxex2CUuS+9EevkeK2 5uG2lzc42YdvzjXRQkrA==; 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 1eS9qv-00084I-Pr; Thu, 21 Dec 2017 23:02:13 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::8]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005Vv-35 for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:11 +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=cADxtDnBmcHJ5spvG9KfqXj3BcMtQZDXbwDN+vflKQI=; b=WYmjRCsPbwnErx96sTCN/bsUoOz6w/iHw5g2xG4yECetMNaD0nni9FQYYX4UmzhbPC dtADF3Et3KCTYU+oTcw3240rXe2GPsEDCQsO5GMVdWxEM4cNMqHSpzCo+t4Vrs3TnGMn PrlE1aOiUsyO/MJeqyzccQoDUwVzGM2yPum9s= 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 Y00a23tBLMxkSWS (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:46 +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 832E61CBABA; 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:31 +0100 Message-Id: <1513897174-20803-5-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_637073_99330F98 X-CRM114-Status: UNSURE ( 7.48 ) X-CRM114-Notice: Please train this message. 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:8 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 4/7] firmware-tools/ptgen: change some variable types to prevent casts 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 Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index b5e317d..af14d73 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -135,7 +135,8 @@ static int gen_ptable(uint32_t signature, int nr) { struct pte pte[4]; unsigned long sect = 0; - int i, fd, ret = -1, start, len; + unsigned long start, len; + int i, fd, ret = -1; memset(pte, 0, sizeof(struct pte) * 4); for (i = 0; i < nr; i++) { @@ -161,9 +162,9 @@ static int gen_ptable(uint32_t signature, int nr) to_chs(start + len - 1, pte[i].chs_end); if (verbose) - fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", i, (long)start * 512, ((long)start + (long)len) * 512, (long)len * 512); - printf("%ld\n", (long)start * 512); - printf("%ld\n", (long)len * 512); + fprintf(stderr, "Partition %d: start=%lu, end=%lu, size=%lu\n", i, start * 512, (start + len) * 512, len * 512); + printf("%lu\n", start * 512); + printf("%lu\n", len * 512); } if ((fd = open(filename, O_WRONLY|O_CREAT, 0644)) < 0) { From patchwork Thu Dec 21 22:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852164 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="Fc6xw2Bm"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="Gw/Au6T/"; 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 3z2nD66W3pz9ryQ for ; Fri, 22 Dec 2017 10:00:22 +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=b1aEeUWHaTeMQfye6/bqTo7vsQOq1vrpbQJY1wb6qLk=; b=Fc6xw2BmgIc6xT fGrGeedHNv6joWIiiQPQ3ZNH3mI2YmzqxjwG0QUQn8BmuUKp6te9YcSniHiLAEovDgU6twa+C5XCV UiT6bOxWeEH5jV5zNGyQkhXTKy943t/H3zkXRlN2kZNee7XShmaleZn/BO7StYbcCeN7lvbbqGVaI ggrNws1EcooXhzRTpI6KS1yusQU7QT8TmLScRi+oGEHEUlrCsoDamJEjIP3i4mHv03+4HiHSM/MuZ oOcPOv6G85/2j+p4/TC7mfPCb9sVu8axOnLwKhOORTwE0o6gXX4uCInhvtpWYC1q/XH0x66sqZQqv BxPYDFaMIRFeW/f9Autw==; 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 1eS9ot-0005px-A8; Thu, 21 Dec 2017 23:00:07 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::9]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005Vz-3P for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:03 +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=/prt5TwoSC20HYQ2T+HSufUqpBESA87kSrhrg0FAvnI=; b=Gw/Au6T/ik1bYR37PUrhB440ckHXpw3FliJtGAcyojP+AQyz8knIXc7XCln0ENeEgG CW68DslP3przQcZ20UI2fsN/cbuHWpZrIhjNS61QZZYEKmF+6HgrNte9Tsxaza7XUZfS Hx3nX8gbTLpenmXJt7cxNtYXQWTEsu1EEmoS0= 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 Y00a23tBLMxlSWU (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 977371CC11D; 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:32 +0100 Message-Id: <1513897174-20803-6-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_616533_D6A434CF X-CRM114-Status: UNSURE ( 7.41 ) X-CRM114-Notice: Please train this message. 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:9 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 5/7] firmware-tools/ptgen: improve error messages on failures 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 Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index af14d73..3e1b8ba 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -30,6 +30,7 @@ #include #include #include +#include #if __BYTE_ORDER == __BIG_ENDIAN #define cpu_to_le32(x) bswap_32(x) @@ -168,24 +169,24 @@ static int gen_ptable(uint32_t signature, int nr) } if ((fd = open(filename, O_WRONLY|O_CREAT, 0644)) < 0) { - fprintf(stderr, "Can't open output file '%s'\n",filename); + fprintf(stderr, "Can't open output file '%s': %s\n", filename, strerror(errno)); return -1; } lseek(fd, 440, SEEK_SET); if (write(fd, &signature, sizeof(signature)) != sizeof(signature)) { - fprintf(stderr, "write failed.\n"); + perror("Writing disk signature failed"); goto fail; } lseek(fd, 446, SEEK_SET); if (write(fd, pte, sizeof(struct pte) * 4) != sizeof(struct pte) * 4) { - fprintf(stderr, "write failed.\n"); + perror("Writing partition table failed"); goto fail; } lseek(fd, 510, SEEK_SET); if (write(fd, "\x55\xaa", 2) != 2) { - fprintf(stderr, "write failed.\n"); + perror("Writing signature failed"); goto fail; } From patchwork Thu Dec 21 22:59:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 852165 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="Oiyhl0C9"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="IQbWrxRS"; 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 3z2nDP0117z9s7F for ; Fri, 22 Dec 2017 10:00:36 +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=QjWrLJLQmWEfp5k3eDwdmxQRzIE4TNBgzebI1pgIlcE=; b=Oiyhl0C9ZIAok5 QW5H4PInhFh8T2b/dBcw8MPsvq9UuA/jb/bhNWXNShzojwKtRQENu9hqa9FYVYkaYe1c0hQaO/0uq XMXBvG9cW1BqvYjoRRIisXOEtSYrKZUoWtIA0uwkFlLhrUWUaGFRf0LuK0ZRZfWQdzMcSdiU/vecq SSoyUwa0+jkevDQ3vdcCP1B0dWjE3oshVGu/GJQMjF+OnXhxqDJpaC5jh+agAPBfybQF7PUsKyenE fblAnBvAUbSWA7lmDxkzawb3pCn8h3UxW7qEefXD6I9ZwQe1Vv+OkJXhYeZOaLqk90uZuSU+Z6yrJ 9/jIC7mgnAyv8bOVxt3Q==; 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 1eS9pD-0006E2-9B; Thu, 21 Dec 2017 23:00:27 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::11]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eS9om-0005Vt-3P for lede-dev@lists.infradead.org; Thu, 21 Dec 2017 23:00:07 +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=f6r7g6e5T8l9BrZowp1E55p1Sa7pMWXnahkdacfoecg=; b=IQbWrxRSTP4CfYJE0en29oQTwCIBXOhekMm/L6m/Q9oBtVf/PoaeDGcHgc0Aap0DaQ iML93H7Yl9BFNle2QFAqHXrMXoj0riaIxBpNpSEUgM++sMT4FUHZXPypm0bm58Tssawu 6agcJYX3ZZ2/Wadk3jcCRczHSOQDz07nJ3Y5Q= X-RZG-AUTH: :O2kGeEG7b/pS1EW8QnKjhhg/vO4pzqdNytq77N6ZPUGwIpLOmsCM+BB/JuKj9RosYI7owD/XKfycfQ== X-RZG-CLASS-ID: mo00 Received: from tonne.mhei.heimpold.itr (p5DC3A286.dip0.t-ipconnect.de [93.195.162.134]) by smtp.strato.de (RZmta 42.14 DYNA|AUTH) with ESMTPSA id Y00a23tBLMxkSWT (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:46 +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 A3E7915F104; 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:33 +0100 Message-Id: <1513897174-20803-7-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_614912_2A70990F X-CRM114-Status: UNSURE ( 7.90 ) X-CRM114-Notice: Please train this message. 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:11 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 6/7] firmware-tools/ptgen: fix start sector calculation 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 Consider the following example: $ ./ptgen -v -a 0 -h 255 -s 63 -l 1024 -o test2.img -p 3M -p 128M -p 128M Partition 0: start=1048576, end=4194304, size=3145728 1048576 3145728 Partition 1: start=5242880, end=139460608, size=134217728 5242880 134217728 Partition 2: start=140509184, end=274726912, size=134217728 140509184 134217728 Opening the image file with cfdisk shows that there is free space between the partitions which is not required/intended: Size: 1 GiB, 1073741824 bytes, 2097152 sectors Label: dos, identifier: 0x5452574f Device Boot Start End Sectors Size Id Type test2.img1 2048 8191 6144 3M 83 Linux Free space 8192 10239 2048 1M test2.img2 10240 272383 262144 128M 83 Linux Free space 272384 274431 2048 1M test2.img3 274432 536575 262144 128M 83 Linux Free space 536576 2097151 1560576 762M With this patch the very same execution of ptgen results in: $ ./ptgen -v -a 0 -h 255 -s 63 -l 1024 -o test2.img -p 3M -p 128M -p 128M Partition 0: start=1048576, end=4194304, size=3145728 1048576 3145728 Partition 1: start=4194304, end=138412032, size=134217728 4194304 134217728 Partition 2: start=138412032, end=272629760, size=134217728 138412032 134217728 And the view with cfdisk shows, that there is no free space inserted anymore: Disk: test2.img Size: 1 GiB, 1073741824 bytes, 2097152 sectors Label: dos, identifier: 0x5452574f Device Boot Start End Sectors Size Id Type test2.img1 2048 8191 6144 3M 83 Linux test2.img2 8192 270335 262144 128M 83 Linux test2.img3 270336 532479 262144 128M 83 Linux Free space 532480 2097151 1564672 764M Signed-off-by: Michael Heimpold --- tools/firmware-utils/src/ptgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 3e1b8ba..d549faf 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -149,7 +149,7 @@ static int gen_ptable(uint32_t signature, int nr) pte[i].active = ((i + 1) == active) ? 0x80 : 0; pte[i].type = parts[i].type; - start = sect + sectors; + start = sect + ((i == 0) ? sectors : 0); if (kb_align != 0) start = round_to_kb(start); pte[i].start = cpu_to_le32(start); 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':