[U-Boot] [PATCH] make hang() a weak function

Wolfgang Denk wd at denx.de
Tue Apr 16 16:17:24 CEST 2013


Dear Andreas,

In message <516D52EE.1040402 at gmail.com> you wrote:
> 
> Yes it is independent (or should at least). But there are still slightly
> different versions:

Yes, I know :-(

> ---8<---
> arch/powerpc/lib/board.c:void __hang(void)
> arch/powerpc/lib/board.c-{
> arch/powerpc/lib/board.c-       puts("### ERROR ### Please RESET the
> board ###\n");
> arch/powerpc/lib/board.c-       bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> arch/powerpc/lib/board.c-       for (;;)
> --->8---

This is probably what the generic code should look like.

> > Note that hang() is not supposed to do anything else, it just hangs
> > the system.  If you have a debugger attached, you will be able to do a
> > simple stack backtrace and see exactly where you are hanging, and why.
> 
> Well, for this specific board I plan to panic() on wrong hardware
> detection (which will in turn call hang()). My requirements say that I
> have to visualize this state then, I thought it would be a good idea to
> blink some lights in the endless loop in hang() for this specific board.
> 
> > If you think you need to have specialized code, you are doing
> > something wrong.
> 
> Really? How would you solve this requirement?

Turn on the blinking in panic(), before calling hang().  This requires
that you have some way to blink a LED when the CPU is hanging in an
endlss loop, though.

In general, panic() and hang() are for fatal errors where no way of
recovery is possible and where you cannot make any assumptions about
remaining (or even allowed) functionality. The puts() and
bootstage_*() calls above are already stretching the design pretty
far.  We should not add more functionality here.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
That said, there may be good reasons for what you did beyond obsequi-
ous sycophantic parody. Perhaps you might be so kind as to elucidate.
         -- Tom Christiansen in <5ldjbm$jtk$1 at csnews.cs.colorado.edu>


More information about the U-Boot mailing list