diff mbox

[U-Boot,2/2] cmd: fdt: Print error message when fdt application fails

Message ID 20161215230327.28896-2-stefan@agner.ch
State Accepted
Commit 082b1414e80ffa94569613705eac319488324516
Delegated to: Tom Rini
Headers show

Commit Message

Stefan Agner Dec. 15, 2016, 11:03 p.m. UTC
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(-)

Comments

Maxime Ripard Dec. 16, 2016, 9:33 a.m. UTC | #1
On Thu, Dec 15, 2016 at 03:03:27PM -0800, Stefan Agner wrote:
> 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>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime
Simon Glass Dec. 17, 2016, 10:48 p.m. UTC | #2
On 16 December 2016 at 02:33, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Thu, Dec 15, 2016 at 03:03:27PM -0800, Stefan Agner wrote:
>> 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>
>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass Jan. 14, 2017, 5:14 p.m. UTC | #3
On 17 December 2016 at 15:48, Simon Glass <sjg@chromium.org> wrote:
> On 16 December 2016 at 02:33, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
>> On Thu, Dec 15, 2016 at 03:03:27PM -0800, Stefan Agner wrote:
>>> 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>
>>
>> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt, thanks!
diff mbox

Patch

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 */