[U-Boot] [RFC] Make U-Boot log great again

Robert Nelson robertcnelson at gmail.com
Fri Feb 16 19:49:45 UTC 2018


On Fri, Feb 16, 2018 at 1:01 PM, Sam Protsenko
<semen.protsenko at linaro.org> wrote:
> Hi guys,
>
> TL;DR This is a suggestion about fixing U-Boot log, which has got
> worse recently.
>
> Right now U-Boot and SPL logs are cluttered with bogus warnings like
> these (on X15 board, but I'm pretty sure it should appear on many
> others):
>
>     Loading Environment from FAT...
>     *** Warning - bad CRC, using default environment
>     Failed (-5)

This one seems to cause the most confusion with end users.  They like
to think it's a real bug, when in reality, "saveenv" and friends was
just never run from within u-boot or a separate environment partition
wasn't pre-programmed.

It's one of those bugs, users asked 10 years ago when the Beagle first
launched, yet users still ask from time to time..

>
> Those are the consequences of next commit:
>
>     fb69464eae1e ("env: Allow to build multiple environments in Kconfig")
>
> Because of this commit, I can see following changes in my .config file:
>
>     +CONFIG_ENV_IS_IN_FAT=y
>     +CONFIG_ENV_FAT_INTERFACE="mmc"
>     +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
>     +CONFIG_ENV_FAT_FILE="uboot.env"
>
> which led U-Boot to try and load the environment from different
> sources. I agree that it's good thing to do and can be useful, but the
> problem is that the code for loading the environment wasn't changed to
> handle errors properly.
>
> How I suggest to handle that case:
>
>  1. If we have two sources for the environment (e.g. FAT partition on
> SD card and some raw partition on eMMC), we shouldn't print error
> messages if we were unable to load the environment from one source
>  2. We should probably print some human-readable information that we
> didn't find the environment there, let's skip and look for next source
> (but don't print those warnings/failed messages)
>  3. And only print the error message in case when U-Boot environment
> wasn't found at all (on all possible sources).
>
> I don't have enough time to fix this by my own right now. But let's
> discuss how to approach this issue in a best way possible. And if
> someone wants to step forward and do that -- would be really nice. If
> no -- I can look into that later. But let's collect some opinions
> here, first.

I've also found, when you are dealing with multiple sources, it's nice
to print "where" you came from.

Otherwise, I've been known to make things way to verbose, but it's
easier to debug years later, when your adding a new family, or
overhauling when/how "overlays" are handled...

Regards,

-- 
Robert Nelson
https://rcn-ee.com/


More information about the U-Boot mailing list