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

Graeme Russ graeme.russ at gmail.com
Tue Apr 16 16:20:19 CEST 2013


Hi Andreas,


On Wed, Apr 17, 2013 at 12:15 AM, Andreas Bießmann <
andreas.devel at googlemail.com> wrote:
>
> Hi Graeme,
>
> On 04/16/2013 03:35 PM, Graeme Russ wrote:
> > Hi Andreas,
> >
> > On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bießmann
> > <andreas.devel at googlemail.com <mailto:andreas.devel at googlemail.com>>
wrote:
> >>
> >> Dear Wolfgang,
> >>
> >> On 04/16/2013 03:05 PM, Wolfgang Denk wrote:
> >> > Dear Andreas,
> >> >
> >> > In message <516D4B00.9030102 at gmail.com
> > <mailto:516D4B00.9030102 at gmail.com>> you wrote:
>
> <snip>
>
> > I think that ultimately there should only be a single hang() function
>
> Ok.
>
> >> > 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?
> >
> > Doesn't it make  sense to use panic()?
>
> In my opinion it makes sense to panic(). In my special case I also need
> to hang() when panic(). The next question is then how to visualize the
> (end-)user of that device that we hang().

In panic()?

My thought would be along the lines of:
 - Detect something fatal
 - Call panic()
 - Do something to alert the user - puts(), start a LED blinking, etc.
 - Stay in panic() if you need CPU cycles to  keep alerting the user (LED
blinking for example)
 - Call hang() if you've done everything you can

Regards,

Graeme


More information about the U-Boot mailing list