[U-Boot] a few questions about saving bootcount in the environment

Wolfgang Denk wd at denx.de
Mon Jul 25 16:35:04 CEST 2016


Dear Tom,

In message <20160725135754.GN14698 at bill-the-cat> you wrote:
> 
> > Right, it is only a last resort when you cannot find any better place
> > to storeit (in a hardware register that survives resets).
> 
> That's not strictly true.  One of the things I noticed recently is that
> Mender uses bootcount, in environment, as a least common denominator.
> And thrown in a file in a filesystem, in so far as you trust the
> underlying black box to be good about reads/writes and wear levelling,
> it's robust enough (for certain values of robust and enough).  We're
> dipping into one of those areas where experts have varying opinions on
> what's good enough, hence all the qualifiers.  But it is a useful
> option.  And neatly circumvents the need for a "driver" to clear the
> count too.

Agreed.  Let me rephrase the warning, then: it is always a good idea
to minimize the number of writes to the environment, especially when
done automagically.  One should at least avoid to re-write it on every
boot, especially when storage is some (flash based) storage device
with a limited number of erase/write cycles.  And even on other stoage
each write access includes the risk of errors.

Best regards,

Wolfgang Denk

-- 
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
People don't like to be lectured to, but if you can make them  laugh,
their  defenses  come  down,  and for the time being they've accepted
whatever truth is embedded in your humor.             - Paul Krassner


More information about the U-Boot mailing list