[U-Boot] [PATCH] Provide more useful debugging when an initcall fails

Simon Glass sjg at chromium.org
Sat Apr 13 16:27:14 CEST 2013


The debug() which prints out the current call is not very useful, since if
it is called early enough (such as before the console is ready in the
pre-relocation board_init_f() sequence) it can hang the board.

It is more useful to print a message when a call fails, and in this case
the non-relocated symbol address provides a way for the offending function
to be located in System.map.

Adjust the initcall to provide this.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 lib/initcall.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/initcall.c b/lib/initcall.c
index fc91bf6..ace285d 100644
--- a/lib/initcall.c
+++ b/lib/initcall.c
@@ -23,15 +23,20 @@
 #include <common.h>
 #include <initcall.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int initcall_run_list(init_fnc_t init_sequence[])
 {
 	init_fnc_t *init_fnc_ptr;
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		debug("initcall: %p\n", *init_fnc_ptr);
 		if ((*init_fnc_ptr)()) {
+			unsigned long reloc_ofs = 0;
+
+			if (gd->flags & GD_FLG_RELOC)
+				reloc_ofs = gd->reloc_off;
 			debug("initcall sequence %p failed at call %p\n",
-			      init_sequence, *init_fnc_ptr);
+			      init_sequence, (char *)*init_fnc_ptr - reloc_ofs);
 			return -1;
 		}
 	}
-- 
1.8.1.3



More information about the U-Boot mailing list