U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] cmd: fdt: Print error message when fdt application fails
Date: Thu, 15 Dec 2016 15:03:27 -0800	[thread overview]
Message-ID: <20161215230327.28896-2-stefan@agner.ch> (raw)
In-Reply-To: <20161215230327.28896-1-stefan@agner.ch>

From: Stefan Agner <stefan.agner@toradex.com>

There are lots of reason why a FDT application might fail, the
error code might give an indication. Let the error code translate
in a error string so users can try to understand what went wrong.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
---
Currently I get this when I apply a device tree overlay to a device
tree without symbols:

  Colibri iMX7 # fdt apply ${loadaddr}
  Colibri iMX7 # fdt print
  libfdt fdt_path_offset() returned FDT_ERR_BADMAGIC
  Colibri iMX7 #

With this change, the situation is a bit more indicative:

  Colibri iMX7 # fdt apply ${loadaddr}
  fdt_overlay_apply(): FDT_ERR_NOTFOUND
  Colibri iMX7 # fdt print
  libfdt fdt_path_offset() returned FDT_ERR_BADMAGIC
  Colibri iMX7 #

 cmd/fdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 8bd345a..6883e75 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -642,6 +642,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else if (strncmp(argv[1], "ap", 2) == 0) {
 		unsigned long addr;
 		struct fdt_header *blob;
+		int ret;
 
 		if (argc != 3)
 			return CMD_RET_USAGE;
@@ -654,8 +655,11 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (!fdt_valid(&blob))
 			return CMD_RET_FAILURE;
 
-		if (fdt_overlay_apply(working_fdt, blob))
+		ret = fdt_overlay_apply(working_fdt, blob);
+		if (ret) {
+			printf("fdt_overlay_apply(): %s\n", fdt_strerror(ret));
 			return CMD_RET_FAILURE;
+		}
 	}
 #endif
 	/* resize the fdt */
-- 
2.10.2

  reply	other threads:[~2016-12-15 23:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-15 23:03 [U-Boot] [PATCH 1/2] libfdt: overlay: Fix missing symbols condition Stefan Agner
2016-12-15 23:03 ` Stefan Agner [this message]
2016-12-16  9:33   ` [U-Boot] [PATCH 2/2] cmd: fdt: Print error message when fdt application fails Maxime Ripard
2016-12-17 22:48     ` Simon Glass
2017-01-14 17:14       ` Simon Glass
2016-12-16  9:32 ` [U-Boot] [PATCH 1/2] libfdt: overlay: Fix missing symbols condition Maxime Ripard
2016-12-18  0:56   ` Stefan Agner
2016-12-19 13:19     ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161215230327.28896-2-stefan@agner.ch \
    --to=stefan@agner.ch \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox