public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 4/5] bootcount: display5: spl: Extend SPL to support bootcount checking
Date: Mon, 26 Feb 2018 16:31:47 +0100	[thread overview]
Message-ID: <20180226163147.756745a7@jawa> (raw)
In-Reply-To: <20180226162225.475e8617@jawa>

On Mon, 26 Feb 2018 16:22:25 +0100
Lukasz Majewski <lukma@denx.de> wrote:

> Hi Stefan,
> 
> > Hi Lukasz,
> > 
> > On 26.02.2018 13:22, Lukasz Majewski wrote:  
> > > This patch is necessary for providing basic bootcount checking in
> > > the case of using "falcon" boot mode.
> > > 
> > > It forces u-boot proper boot, when we exceed the number of errors.
> > > 
> > > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > > ---
> > > 
> > >   board/liebherr/display5/spl.c | 6 +++++-
> > >   1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/board/liebherr/display5/spl.c
> > > b/board/liebherr/display5/spl.c index 0a36e656c0..5812f71dfc
> > > 100644 --- a/board/liebherr/display5/spl.c
> > > +++ b/board/liebherr/display5/spl.c
> > > @@ -20,6 +20,7 @@
> > >   #include <environment.h>
> > >   #include <fsl_esdhc.h>
> > >   #include <netdev.h>
> > > +#include <bootcount.h>
> > >   #include "common.h"
> > >   
> > >   DECLARE_GLOBAL_DATA_PTR;
> > > @@ -194,6 +195,9 @@ void board_init_f(ulong dummy)
> > >   	/* Clear the BSS. */
> > >   	memset(__bss_start, 0, __bss_end - __bss_start);
> > >   
> > > +	/* Increment bootcount */
> > > +	bootcount_inc();
> > > +    
> > 
> > Wouldn't it be better, to move this incrementing into some common
> > code, so that other platform who might use the bootcounter in SPL
> > in the future could also use it without code duplication?
> > 
> > What do you think?  
> 
> To provide this functionality I need to add bootcount_inc() and check
> bootcount_error(). Both are static inlines from  #include
> <bootcount.h>
> 
> However, maybe it would be better to put this code to generic SPL. I
> will try to do it for v2.

The problem here is that we need very early code to do this (increment
bootcount). Now it is done in SPL's board_init_f.
It is the first C function, called from crt0.S asm file.

I'm not sure if we have such early code common for all archs/platforms.

If we put this bootcount_inc() to latter SPL code, we risk hanging in
SPL with WDT reset and not incremented bootcount...

Also the bootcount shall be incremented in the same function where we
enable and initialize WDT.

> 
> Thanks for the idea.
> 
> > 
> > Thanks,
> > Stefan  
> 
> 
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> 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




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180226/3f188068/attachment.sig>

  reply	other threads:[~2018-02-26 15:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26 12:22 [U-Boot] [PATCH v1 0/5] Provide SPL support for bootcount (in the case of using falcon boot mode) Lukasz Majewski
2018-02-26 12:22 ` [U-Boot] [PATCH v1 1/5] bootcount: spl: Enable bootcount support in SPL Lukasz Majewski
2018-02-26 12:22 ` [U-Boot] [PATCH v1 2/5] bootcount: Add function wrappers to handle bootcount increment and error checking Lukasz Majewski
2018-02-26 14:27   ` Tom Rini
2018-02-26 12:22 ` [U-Boot] [PATCH v1 3/5] bootcount: u-boot: Do not increment bootcount if already done in SPL Lukasz Majewski
2018-02-26 14:27   ` Tom Rini
2018-02-26 14:53     ` Lukasz Majewski
2018-02-26 15:00       ` Tom Rini
2018-02-26 15:07         ` Lukasz Majewski
2018-02-26 12:22 ` [U-Boot] [PATCH v1 4/5] bootcount: display5: spl: Extend SPL to support bootcount checking Lukasz Majewski
2018-02-26 15:14   ` Stefan Roese
2018-02-26 15:22     ` Lukasz Majewski
2018-02-26 15:31       ` Lukasz Majewski [this message]
2018-02-26 15:59         ` Stefan Roese
2018-02-26 16:27           ` Lukasz Majewski
2018-02-26 12:22 ` [U-Boot] [PATCH v1 5/5] bootcount: display5: config: Enable boot count feature in the display5 board Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180226163147.756745a7@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox