[U-Boot] [PATCH] imx: save reset cause in 'reset_cause' environment variable

Bill Pringlemeir bpringlemeir at nbsps.com
Fri Feb 6 21:56:25 CET 2015


> On 02/05/2015 03:58 PM, Eric Nelson wrote:
>> The cause of a reset is generally useful, and shouldn't be
>> blindly cleared in the process of displaying it as a part
>> of the boot announcement.
>>
>> <snip>
>>
>> diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c
>> index 28ccd29..4a54051 100644
>> --- a/arch/arm/imx-common/cpu.c
>> +++ b/arch/arm/imx-common/cpu.c
>> @@ -28,6 +28,7 @@ char *get_reset_cause(void)
>> {
>> 	u32 cause;
>> 	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
>> +	char *rval = "unknown";
>>
>> 	cause = readl(&src_regs->srsr);
>> <snip>
>>
>> 	}
>> +	setenv("reset_cause", rval);
>> +	return rval;

On  6 Feb 2015, eric.nelson at boundarydevices.com wrote:

> Nak.

> This routine is called before the environment is initialized.

Okay, that makes sense we can't do this.

> There's no way to set the environment here, which I think
> means that this patch is a pre-cursor to anything else.

> 	http://patchwork.ozlabs.org/patch/436492/
 	
> If we feel the need to reset it before an O/S boots, there is a common
> spot here:
> http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/imx-common/cpu.c;hb=HEAD#l205

> That won't be invoked if the O/S is started with "go" though
> (often done with QNX or Windows).

The 'write' is to prevent against multiple bits set.  Say for instance
you remove this check.  Someone has U-boot siting at a command line for
a long time before they boot an OS.  Occasionally, some memory/hardware
error happens and the device resets.  In this case, the reason will be
from multiple resets.

I think it is good to write/clear (and record) the reason early.  So, I
think just having 'cause' as a global or accessible when the environment
is ready would solve your problem.

Writing does two things,

 1. clears the 'reset cause' to prevent someone else to look at.
 2. primes the 'cause' for the next reset; the bits are sticky. w1c

I think we miss the last point with this patch.  The 'cause' just needs to
be recorded and kept around until the environment is up (or however we
want to pass it around).  

Recording it early and clearing is best as you can know what the 'last
cause' was.  Otherwise, you might get multiple causes in the register.

Err, maybe I mis-understand something?  If you do this patch and have
multiple soft resets (watchdog, CSU, JTAG, ipp, warm, etc) are the bits
accumulated?

Fwiw,
Bill.


More information about the U-Boot mailing list