From patchwork Thu Mar 31 10:53:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hoyes X-Patchwork-Id: 1611681 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KTgCS42Cpz9sGG for ; Thu, 31 Mar 2022 21:53:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E7FC840CE; Thu, 31 Mar 2022 12:53:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D3106832E9; Thu, 31 Mar 2022 12:53:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id EE5BB832E9 for ; Thu, 31 Mar 2022 12:53:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peter.hoyes@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 361C023A; Thu, 31 Mar 2022 03:53:38 -0700 (PDT) Received: from e125920.cambridge.arm.com (unknown [10.1.199.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 70FF53F718; Thu, 31 Mar 2022 03:53:37 -0700 (PDT) From: Peter Hoyes To: u-boot@lists.denx.de Cc: sjg@chromium.org, andre.przywara@arm.com, diego.sueiro@arm.com, Peter Hoyes Subject: [PATCH] fdt: Add -q option to fdt addr for distro_bootcmd Date: Thu, 31 Mar 2022 11:53:22 +0100 Message-Id: <20220331105322.3495402-1-peter.hoyes@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Peter Hoyes distro_bootcmd uses this construct a few times to test $fdt_addr_r, and fall back on $fdtcontroladdr if not set/invalid: if fdt addr ${fdt_addr_r}; then ... else ... fi If the `fdt addr` test fails, it prints the following message on the console, suggesting there is an error when there is not: libfdt fdt_check_header(): FDT_ERR_BADMAGIC To remove this potentially confusing error message, this patch adds -q as a 'quiet' option for fdt addr, and uses this flag in config_distro_bootcmd.h Signed-off-by: Peter Hoyes --- cmd/fdt.c | 30 +++++++++++++++++++++++------- include/config_distro_bootcmd.h | 6 +++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 2a207bf2b5..fc2fddfb3c 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -119,13 +119,27 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (strncmp(argv[1], "ad", 2) == 0) { unsigned long addr; int control = 0; + int quiet = 0; struct fdt_header *blob; /* Set the address [and length] of the fdt */ argc -= 2; argv += 2; - if (argc && !strcmp(*argv, "-c")) { - control = 1; + while (argc > 0 && **argv == '-') { + char *arg = *argv; + + while (*++arg) { + switch (*arg) { + case 'c': + control = 1; + break; + case 'q': + quiet = 1; + break; + default: + return CMD_RET_USAGE; + } + } argc--; argv++; } @@ -145,7 +159,8 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) addr = hextoul(argv[0], NULL); blob = map_sysmem(addr, 0); - if (!fdt_valid(&blob)) + if ((quiet && fdt_check_header(blob)) || + (!quiet && !fdt_valid(&blob))) return 1; if (control) gd->fdt_blob = blob; @@ -159,12 +174,13 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* Optional new length */ len = hextoul(argv[1], NULL); if (len < fdt_totalsize(blob)) { - printf("New length %d < existing length %d, ignoring\n", - len, fdt_totalsize(blob)); + if (!quiet) + printf("New length %d < existing length %d, ignoring\n", + len, fdt_totalsize(blob)); } else { /* Open in place with a new length */ err = fdt_open_into(blob, blob, len); - if (err != 0) { + if (!quiet && err != 0) { printf("libfdt fdt_open_into(): %s\n", fdt_strerror(err)); } @@ -1055,7 +1071,7 @@ static int fdt_print(const char *pathp, char *prop, int depth) /********************************************************************/ #ifdef CONFIG_SYS_LONGHELP static char fdt_help_text[] = - "addr [-c] [] - Set the [control] fdt location to \n" + "addr [-cq] [] - Set the [control] fdt location to \n" #ifdef CONFIG_OF_LIBFDT_OVERLAY "fdt apply - Apply overlay to the DT\n" #endif diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 2f90929178..c55023889c 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -126,7 +126,7 @@ #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR #define BOOTENV_EFI_BOOTMGR \ "boot_efi_bootmgr=" \ - "if fdt addr ${fdt_addr_r}; then " \ + "if fdt addr -q ${fdt_addr_r}; then " \ "bootefi bootmgr ${fdt_addr_r};" \ "else " \ "bootefi bootmgr;" \ @@ -141,7 +141,7 @@ "boot_efi_binary=" \ "load ${devtype} ${devnum}:${distro_bootpart} " \ "${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; " \ - "if fdt addr ${fdt_addr_r}; then " \ + "if fdt addr -q ${fdt_addr_r}; then " \ "bootefi ${kernel_addr_r} ${fdt_addr_r};" \ "else " \ "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \ @@ -360,7 +360,7 @@ "setenv bootp_arch " BOOTENV_EFI_PXE_ARCH ";" \ "if dhcp ${kernel_addr_r}; then " \ "tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};" \ - "if fdt addr ${fdt_addr_r}; then " \ + "if fdt addr -q ${fdt_addr_r}; then " \ "bootefi ${kernel_addr_r} ${fdt_addr_r}; " \ "else " \ "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \