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 3/5] bootcount: u-boot: Do not increment bootcount if already done in SPL
Date: Mon, 26 Feb 2018 15:53:18 +0100	[thread overview]
Message-ID: <20180226155318.22163e6b@jawa> (raw)
In-Reply-To: <20180226142711.GM4311@bill-the-cat>

Hi Tom,

> On Mon, Feb 26, 2018 at 01:22:44PM +0100, Lukasz Majewski wrote:
> 
> > If the CONFIG_SPL_BOOTCOUNT_LIMIT is defined, the bootcount
> > variable is already incremented after each boot attempt.
> > 
> > For that reason we shall not increment it again in u-boot.
> > 
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > ---
> > 
> >  common/autoboot.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/common/autoboot.c b/common/autoboot.c
> > index 2eef7a04cc..87fca2ea92 100644
> > --- a/common/autoboot.c
> > +++ b/common/autoboot.c
> > @@ -298,7 +298,9 @@ const char *bootdelay_process(void)
> >  
> >  #ifdef CONFIG_BOOTCOUNT_LIMIT
> >  	bootcount = bootcount_load();
> > +#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT
> >  	bootcount++;
> > +#endif
> >  	bootcount_store(bootcount);
> >  	env_set_ulong("bootcount", bootcount);
> >  	bootlimit = env_get_ulong("bootlimit", 10, 0);  
> 
> Shouldn't we make the whole bit of code here depend on
> !CONFIG_SPL_BOOTCOUNT_LIMIT ?  

Maybe I will try to present the scenario:

- We do use SPL to boot from either eMMC (if in falcon) or from SPI-NOR
  (if not in falcon)

- With bootcount:
	-- We may want to boot into eMMC directly, so we need to
	increment the bootcount (no matter where it is located).

	-- We intentionally (by setting other env variable) or not (by
	entering X resets) abort falcon mode boot from SPL and boot to
	u-boot (which is in spi-nor).
	In this case we do need all the bootcount limit functionality
	(i.e. altbootcmd) excluding increment bootcount (as it was
	done in SPL).
	
+#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT is only required to achieve this
goal without making any more code change...

> Or for that matter, re-work the first
> patch to instead be:
> bool SUPPORT_BOOTCOUNT "Support bootcount in some way"
> choice "Bootcount location"
> bool SPL_BOOTCOUNT_LIMIT "Count boots from POV of SPL"
> bool BOOTCOUNT_LIMIT "Count boots from POV of full U-Boot"
> endchoice

But then SPL_BOOTCOUNT_LIMIT would select BOOTCOUNT_LIMIT to fulfil the
above scenario.

> 
> ?  Looking back at my old series from 2014 to do this, I just had a
> big warning saying you need to enable bootcount for SPL or for full
> U-Boot so you would never set BOOTCOUNT_LIMIT if doing SPL bootcount
> instead.

Such functionality can be achieved with SPL_BOOTCOUNT_LIMIT depending
on BOOTCOUNT_LIMIT.

If SPL_BOOTCOUNT_LIMIT selected, then "[PATCH v1 3/5] bootcount: u-boot:
Do not increment bootcount if already done in SPL" does its job.

> 




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/a68921cb/attachment.sig>

  reply	other threads:[~2018-02-26 14:53 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 [this message]
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
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=20180226155318.22163e6b@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