All of lore.kernel.org
 help / color / mirror / Atom feed
* Suggestion: When flash is uninitialized, *silently* fall back to default environment
@ 2021-06-30 23:19 Zack Weinberg
  0 siblings, 0 replies; only message in thread
From: Zack Weinberg @ 2021-06-30 23:19 UTC (permalink / raw)
  To: u-boot

Consider a boot ROM that looks for u-boot in several places (SPI
flash, eMMC flash, etc) and loads the first one it finds, and then
u-boot repeats the same search to find its own configuration.  If
there is _nothing_ on the SPI flash and u-boot and all its
configuration is on the eMMC, this will work fine _except_ that you'll
get a scary-looking message from env_set_default

*** Warning: bad CRC, using default environment

because uninitialized flash memory reads as all-ones (FF FF FF FF ...)
and the crc32 of ENV_SIZE bytes of 0xFF will typically not be 0xFFFF.

I'd like to suggest that env_import() should, when the CRC fails, scan
the environment block, and if it's uniformly 0xFF or uniformly 0x00,
then it should call env_set_default(0,0) instead of
env_set_default("bad CRC", 0).  If I'm reading the code right, the
only effect of this will be to suppress the warning message.

Thanks for your consideration,
zw

ps. Can we be sure that the crc32 of ENV_SIZE bytes of 0xFF will
_never_ be 0xFFFF and the crc32 of ENV_SIZE bytes of 0x00 will _never_
be 0x0000?  If not, it might be wise to do the scans for blank
flash/disk sectors _first_, rather than relying on the CRC to detect
them.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-01  3:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 23:19 Suggestion: When flash is uninitialized, *silently* fall back to default environment Zack Weinberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.