From patchwork Mon Apr 1 10:45:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1072786 X-Patchwork-Delegate: sjg@chromium.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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44XthY5xMMz9sNw for ; Tue, 2 Apr 2019 00:38:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6D28BC21E68; Mon, 1 Apr 2019 13:38:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4A518C21E3A; Mon, 1 Apr 2019 13:37:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 50915C21DA6; Mon, 1 Apr 2019 10:46:41 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id CEF62C21D65 for ; Mon, 1 Apr 2019 10:46:40 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id A957A3C013A; Mon, 1 Apr 2019 12:46:40 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ok4rAsm9ZnpE; Mon, 1 Apr 2019 12:46:30 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id D824A3C00C3; Mon, 1 Apr 2019 12:46:20 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 1 Apr 2019 12:46:20 +0200 From: Eugeniu Rosca To: Simon Glass , Tom Rini , Masahiro Yamada , Stefan Roese , Sam Protsenko , Simon Goldschmidt , Marek Vasut , George McCollister , Alexey Brodkin , Alexander Graf , York Sun , Tuomas Tynkkynen , Thomas Petazzoni , Shawn Guo , Paul Kocialkowski , Pantelis Antoniou , Michal Simek , Max Krummenacher , Marcel Ziswiler , Joe Hershberger , Joakim Tjernlund , Heiko Schocher , Hannes Schmelzer , Hannes Schmelzer , Daniel Schwierzeck , Bin Meng , Date: Mon, 1 Apr 2019 12:45:33 +0200 Message-ID: <20190401104537.29801-2-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401104537.29801-1-erosca@de.adit-jv.com> References: <20190401104537.29801-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] X-Mailman-Approved-At: Mon, 01 Apr 2019 13:37:35 +0000 Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH v2 1/5] fdt: boot_get_fdt: remove redundant zeroing out X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Paranoid programming [1] lies at the foundation of proper software development, but the repetitive zeroing-out of output arguments in the context of the same function rather clutters the code and inhibits further refactoring/optimization than is doing any good. In boot_get_fdt(), we already perform zero/NULL-initialization of *of_flat_tree and *of_size at the beginning of the function, so doing the same at function error-out is redundant/superfluous. Moreover, keeping the code unchanged might encourage the developers to update *of_flat_tree and *of_size during some interim computations, which is against the current design of boot_get_fdt(). Currently, writing useful data into these arguments happens just before successfully returning from boot_get_fdt() and it should better stay so. [1] https://blog.regehr.org/archives/1106 Signed-off-by: Eugeniu Rosca Reviewed-by: Simon Glass --- Changes in v2: - s/zeroint-out/zeroing-out/ in commit description - Link v1: https://patchwork.ozlabs.org/patch/1071586/ --- common/image-fdt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/image-fdt.c b/common/image-fdt.c index 01186aeac7a4..1817ce6bce30 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -489,8 +489,6 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, no_fdt: ok_no_fdt = 1; error: - *of_flat_tree = NULL; - *of_size = 0; if (!select && ok_no_fdt) { debug("Continuing to boot without FDT\n"); return 0; From patchwork Mon Apr 1 10:45:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1072790 X-Patchwork-Delegate: sjg@chromium.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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44Xtjc4bhmz9sPS for ; Tue, 2 Apr 2019 00:39:16 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 57F8AC21E77; Mon, 1 Apr 2019 13:38:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B8929C21EA6; Mon, 1 Apr 2019 13:37:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 40CD4C21D65; Mon, 1 Apr 2019 10:46:52 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id F0248C21D4A for ; Mon, 1 Apr 2019 10:46:51 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id C9A273C02EC; Mon, 1 Apr 2019 12:46:51 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CQbxyVA8kLBu; Mon, 1 Apr 2019 12:46:40 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 323713C014A; Mon, 1 Apr 2019 12:46:30 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 1 Apr 2019 12:46:29 +0200 From: Eugeniu Rosca To: Simon Glass , Tom Rini , Masahiro Yamada , Stefan Roese , Sam Protsenko , Simon Goldschmidt , Marek Vasut , George McCollister , Alexey Brodkin , Alexander Graf , York Sun , Tuomas Tynkkynen , Thomas Petazzoni , Shawn Guo , Paul Kocialkowski , Pantelis Antoniou , Michal Simek , Max Krummenacher , Marcel Ziswiler , Joe Hershberger , Joakim Tjernlund , Heiko Schocher , Hannes Schmelzer , Hannes Schmelzer , Daniel Schwierzeck , Bin Meng , Date: Mon, 1 Apr 2019 12:45:34 +0200 Message-ID: <20190401104537.29801-3-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401104537.29801-1-erosca@de.adit-jv.com> References: <20190401104537.29801-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] X-Mailman-Approved-At: Mon, 01 Apr 2019 13:37:35 +0000 Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH v2 2/5] fdt: boot_get_fdt: really boot w/o FDT when "goto no_fdt" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The 'no_fdt' goto label was introduced by v2015.01 commit [0] and it had two review stages [1-2]. The *documented* purpose behind commit [0] is (excerpt from commit description): > allows both FDT and non-FDT kernels to boot by making the > third parameter to the bootm/bootz optional While [1] and [2] share the same goal, they have very different implementations: - [1] was based on a very simple 'argc' check at function error out with returning success to the caller if the third parameter was NOT passed to bootm/bootz command. This approach had the downside of returning success to the caller even in case of legitimate internal errors, which should halt booting. - [2] added the "no_fdt" label and several "goto no_fdt" statements. This allowed to report the legitimate internal errors to the caller. IOW the major difference between [1] and [2] is: - [1] boot w/o FDT if FDT address is not passed to boot{m,z,*} - [2] give *freedom* to the developer to boot w/o FDT from any (more or less) arbitrary point in the function flow (and here comes the peculiar aspect, which looks to be a leftover from [1]) with the precondition that the 3rd argument (FDT address) is NOT provided to boot{m,z,*}. In practice, this means that only a subset of "goto no_fdt" end up booting w/o FDT while the other subset is returning an error to the caller. This patch removes the peculiar behavior described above, such that "goto no_fdt" performs really what it tells to the developer. The motivation of this patch is to decrease the unneeded complexity and increase the readability of boot_get_fdt(). [0] 48aead71c1ad ("fdt: Allow non-FDT kernels to boot when CONFIG_OF_LIBFDT is defined") [1] https://patchwork.ozlabs.org/patch/412923/ ("[U-Boot,v1] fdt: Allow non-FDT kernels to boot when CONFIG_OF_LIBFDT is defined") [2] https://patchwork.ozlabs.org/patch/415635/ ("[U-Boot,v2] fdt: Allow non-FDT kernels to boot when CONFIG_OF_LIBFDT is defined") Signed-off-by: Eugeniu Rosca Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - NA - Link v1: https://patchwork.ozlabs.org/patch/1071587/ --- common/image-fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/image-fdt.c b/common/image-fdt.c index 1817ce6bce30..c335e7e2f220 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -489,7 +489,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, no_fdt: ok_no_fdt = 1; error: - if (!select && ok_no_fdt) { + if (ok_no_fdt) { debug("Continuing to boot without FDT\n"); return 0; } From patchwork Mon Apr 1 10:45:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1072794 X-Patchwork-Delegate: sjg@chromium.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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44Xtkh00YVz9sPS for ; Tue, 2 Apr 2019 00:40:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A99B9C21EE5; Mon, 1 Apr 2019 13:38:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2C0B5C21EBE; Mon, 1 Apr 2019 13:37:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 10889C21D65; Mon, 1 Apr 2019 10:47:13 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id C751AC21D4A for ; Mon, 1 Apr 2019 10:47:12 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id A1CB93C00D1; Mon, 1 Apr 2019 12:47:12 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QFujLi0BxV_P; Mon, 1 Apr 2019 12:47:06 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 7E4BB3C014A; Mon, 1 Apr 2019 12:46:54 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 1 Apr 2019 12:46:54 +0200 From: Eugeniu Rosca To: Simon Glass , Tom Rini , Masahiro Yamada , Stefan Roese , Sam Protsenko , Simon Goldschmidt , Marek Vasut , George McCollister , Alexey Brodkin , Alexander Graf , York Sun , Tuomas Tynkkynen , Thomas Petazzoni , Shawn Guo , Paul Kocialkowski , Pantelis Antoniou , Michal Simek , Max Krummenacher , Marcel Ziswiler , Joe Hershberger , Joakim Tjernlund , Heiko Schocher , Hannes Schmelzer , Hannes Schmelzer , Daniel Schwierzeck , Bin Meng , Date: Mon, 1 Apr 2019 12:45:35 +0200 Message-ID: <20190401104537.29801-4-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401104537.29801-1-erosca@de.adit-jv.com> References: <20190401104537.29801-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] X-Mailman-Approved-At: Mon, 01 Apr 2019 13:37:35 +0000 Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH v2 3/5] fdt: boot_get_fdt: simplify no_fdt handling (non-functional) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Increase the readability of boot_get_fdt(). No change in behavior is expected. Signed-off-by: Eugeniu Rosca Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - NA - Link v1: https://patchwork.ozlabs.org/patch/1071588/ --- common/image-fdt.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/common/image-fdt.c b/common/image-fdt.c index c335e7e2f220..68bcab85baf4 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -279,7 +279,6 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, int fdt_noffset; #endif const char *select = NULL; - int ok_no_fdt = 0; *of_flat_tree = NULL; *of_size = 0; @@ -487,12 +486,9 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, return 0; no_fdt: - ok_no_fdt = 1; + debug("Continuing to boot without FDT\n"); + return 0; error: - if (ok_no_fdt) { - debug("Continuing to boot without FDT\n"); - return 0; - } return 1; } From patchwork Mon Apr 1 10:45:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1072795 X-Patchwork-Delegate: sjg@chromium.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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44Xtkp3l8Wz9sP8 for ; Tue, 2 Apr 2019 00:40:18 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3C147C21EFC; Mon, 1 Apr 2019 13:39:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CE502C21ECC; Mon, 1 Apr 2019 13:37:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CAADCC21D65; Mon, 1 Apr 2019 10:47:19 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id 86A1EC21D4A for ; Mon, 1 Apr 2019 10:47:19 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 61E2A3C014A; Mon, 1 Apr 2019 12:47:19 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nqB1WzxpSx2T; Mon, 1 Apr 2019 12:47:12 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id DC2833C02F4; Mon, 1 Apr 2019 12:46:58 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 1 Apr 2019 12:46:58 +0200 From: Eugeniu Rosca To: Simon Glass , Tom Rini , Masahiro Yamada , Stefan Roese , Sam Protsenko , Simon Goldschmidt , Marek Vasut , George McCollister , Alexey Brodkin , Alexander Graf , York Sun , Tuomas Tynkkynen , Thomas Petazzoni , Shawn Guo , Paul Kocialkowski , Pantelis Antoniou , Michal Simek , Max Krummenacher , Marcel Ziswiler , Joe Hershberger , Joakim Tjernlund , Heiko Schocher , Hannes Schmelzer , Hannes Schmelzer , Daniel Schwierzeck , Bin Meng , Date: Mon, 1 Apr 2019 12:45:36 +0200 Message-ID: <20190401104537.29801-5-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401104537.29801-1-erosca@de.adit-jv.com> References: <20190401104537.29801-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] X-Mailman-Approved-At: Mon, 01 Apr 2019 13:37:35 +0000 Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH v2 4/5] fdt: boot_get_fdt: android: compress handling (non-functional) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Prepare for booting Android images which lack any DTB in the second area by using 'fdtaddr' environment variable as source/address of FDT. No functional/behavioral change expected in this patch. Signed-off-by: Eugeniu Rosca Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - Restored fdt_totalsize() check - Link v1: https://patchwork.ozlabs.org/patch/1071590/ --- common/image-fdt.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/common/image-fdt.c b/common/image-fdt.c index 68bcab85baf4..a5d8b41d0209 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -461,17 +461,16 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, struct andr_img_hdr *hdr = buf; ulong fdt_data, fdt_len; - if (android_image_get_second(hdr, &fdt_data, &fdt_len) != 0) - goto no_fdt; + if (!android_image_get_second(hdr, &fdt_data, &fdt_len) && + !fdt_check_header((char *)fdt_data)) { + fdt_blob = (char *)fdt_data; + if (fdt_totalsize(fdt_blob) != fdt_len) + goto error; - fdt_blob = (char *)fdt_data; - if (fdt_check_header(fdt_blob) != 0) + debug("## Using FDT in Android image second area\n"); + } else { goto no_fdt; - - if (fdt_totalsize(fdt_blob) != fdt_len) - goto error; - - debug("## Using FDT found in Android image second area\n"); + } #endif } else { debug("## No Flattened Device Tree\n"); From patchwork Mon Apr 1 10:52:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1072793 X-Patchwork-Delegate: sjg@chromium.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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44XtkN0d9Jz9sNw for ; Tue, 2 Apr 2019 00:39:56 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id AE297C21EE7; Mon, 1 Apr 2019 13:39:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8C494C21EE3; Mon, 1 Apr 2019 13:37:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 598BDC21D65; Mon, 1 Apr 2019 10:54:00 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id 09A79C21D4A for ; Mon, 1 Apr 2019 10:54:00 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id B622D3C014D; Mon, 1 Apr 2019 12:53:59 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EZ3i67Cd3lP7; Mon, 1 Apr 2019 12:53:52 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 814C03C0149; Mon, 1 Apr 2019 12:53:52 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 1 Apr 2019 12:53:51 +0200 From: Eugeniu Rosca To: Simon Glass , Tom Rini , Masahiro Yamada , Stefan Roese , Sam Protsenko , Simon Goldschmidt , Marek Vasut , George McCollister , Alexey Brodkin , Alexander Graf , York Sun , Tuomas Tynkkynen , Thomas Petazzoni , Shawn Guo , Paul Kocialkowski , Pantelis Antoniou , Michal Simek , Max Krummenacher , Marcel Ziswiler , Joe Hershberger , Joakim Tjernlund , Heiko Schocher , Hannes Schmelzer , Hannes Schmelzer , Daniel Schwierzeck , Bin Meng , Date: Mon, 1 Apr 2019 12:52:52 +0200 Message-ID: <20190401105252.30002-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401104537.29801-1-erosca@de.adit-jv.com> References: <20190401104537.29801-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] X-Mailman-Approved-At: Mon, 01 Apr 2019 13:37:35 +0000 Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH v2 5/5] fdt: boot_get_fdt: android: use ENV 'fdtaddr' as fallback X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Our platform doesn't store the DTB into the Android image second area, but rather copies the DTB to RAM from a dedicated dtb.img partition [0], prior to booting the Android image by calling bootm. Similar to [1], we find it useful to just call 'bootm' and have the right DTB being passed to OS (assuming its address has been previously stored in 'fdtaddr' by calling `fdt addr `). Booting Android with DTB from 'fdtaddr' will only occur if: - No DTB is embedded in the second area of Android image - 'fdtaddr' points to a valid DTB in RAM [0] https://source.android.com/devices/architecture/dto/partitions [1] https://patchwork.ozlabs.org/patch/1046652/ ("Support boot Android image without address on bootm command") Signed-off-by: Eugeniu Rosca Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - Removed fdt_totalsize() computation, since FDT size verification is only relevant for blobs embedded in U-Boot-supported images - Link v1: https://patchwork.ozlabs.org/patch/1071591/ --- common/image-fdt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/image-fdt.c b/common/image-fdt.c index a5d8b41d0209..3aa5ffff0f69 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -469,7 +469,15 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch, debug("## Using FDT in Android image second area\n"); } else { - goto no_fdt; + fdt_addr = env_get_hex("fdtaddr", 0); + if (!fdt_addr) + goto no_fdt; + + fdt_blob = map_sysmem(fdt_addr, 0); + if (fdt_check_header(fdt_blob)) + goto no_fdt; + + debug("## Using FDT at ${fdtaddr}=Ox%lx\n", fdt_addr); } #endif } else {