[U-Boot] Return value of run command

Enric Balletbo Serra eballetbo at gmail.com
Fri May 30 17:03:36 CEST 2014


Hi all,

Should the command 'run something"' return the value that returns
"something" or just return "true" if can execute something and "false"
if it can't ?

I'll explain. Imagine you have a variable that loads a file from the
mmc but this files doesn't exist.

  loadfile=load mmc ${mmcdev} ${loadaddr} my-file

In the case you do the following script

    if run loadfile; then  echo "true"; else echo "false"; fi

the result is always "true", either the file doesn't exist

OTOH, if you do :

    if ${loadfile}; then echo "true"; else echo "false"; fi

Then the result is "true" if file exist and "false" if file doesn't exist.

For me looks like the "run something" command should return the result
of the command but this is not the behaviour. With current behaviour
something like CONFIG_EXTRA_ENV_SETTINGS from
include/configs/am335x_evm.h file,

129                         "echo SD/MMC found on device ${mmcdev};" \
130                         "if run loadbootenv; then " \
131                                 "echo Loaded environment from ${bootenv};" \
132                                 "run importbootenv;" \
133                         "fi;" \


Either uEnv.txt file exist or not, the "run loadbootenv" always
returns true, so always tries to run "run importbootenv". I supose
this is not the expected behaviour.

The question is. It's a problem with run command or with the
definition of CONFIG_EXTRA_ENV_SETTING, that should be something like
that:

- 130                         "if run loadbootenv; then " \
+ 130                         "if ${loadbootenv}; then " \


Best regards,
  Enric


More information about the U-Boot mailing list