Hi Michael,
On 08.09.25 13:11, Michael Glembotzki wrote:
> Hi Stefano,
>
> Stefano Babic schrieb am Montag, 8. September 2025 um 11:44:43 UTC+2:
>
> Hi Michael,
>
> On 9/8/25 09:33, Michael Glembotzki wrote:
> > In swupdate reading the default uboot env for the first time
> results in:
> >
> > [ERROR] : SWUPDATE failed [0] ERROR util.c : read_lines_notify :
> 1294 :
> > Cannot read environment, using default
> >
> > Because it's more of a warning than an error, and swupdate treats
> output
> > to stderr as an error, reduce serverity by logging to stdout.
> >
>
> There is a reason for this. If the output is sent to stdout, it breaks
> scripts because the returned strings contain this output.
>
> But, using default values does not exit. It exits only if there is also
> no defenvfile.
>
> Our use case is calling fw_printenv in the pre_post_inst.c and an error
> is shown,
Mmmhhh....where is this file ?
> but for fresh devices this is no errror.
>
In fact, SWUpdate raises a WARN.
https://github.com/sbabic/swupdate/blob/master/bootloader/uboot.c#L57
> Another idea is to change
>
> RECOVERY_STATUS status = level == ERRORLEVEL ? FAILURE : RUN;
> swupdate_notify(status, "%s", level, lines[index]);
>
I am lost: SWUpdate does not fw_printenv, because it makes usage of the
library. This allows full control.
> in swupdate/core/util.c to
>
> swupdate_notify(RUN, "%s", level, lines[index]);
This has nothing to do, and this code is to exec any external command.
>
> but this feels even worse. Or shall we use different exit values in
> libubootenv?
The output is just a warning - helpful for testing. But it doesn't mean
there is an issue. A fresh board hasn't environment in flash, and the
string happens.
> Do you have a better idea to fix make the error / warn lesser strict?
>
I am missing the real issue, because this is just writing a string and
doesn't change the exit code, as it shouldn't do because with a default
environment, everything is fine.
Is pre_post_inst.c part of your application ? Where is coming from ? If
it is, why do not use the library instead of fw_printenv ?
Best regards,
Stefano
> > Signed-off-by: Michael Glembotzki <
Michael.G...@iris-sensing.com>
> > ---
> > src/fw_printenv.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/fw_printenv.c b/src/fw_printenv.c
> > index ef95b32..ceed065 100644
> > --- a/src/fw_printenv.c
> > +++ b/src/fw_printenv.c
> > @@ -160,7 +160,7 @@ int main (int argc, char **argv) {
> > defenvfile = DEFAULT_ENV_FILE;
> >
> > if ((ret = libuboot_open(ctx)) < 0) {
> > - fprintf(stderr, "Cannot read environment, using default\n");
> > + fprintf(stdout, "Cannot read environment, using default\n");
> > if ((ret = libuboot_load_file(ctx, defenvfile)) < 0) {
> > fprintf(stderr, "Cannot read default environment from file\n");
> > exit (ret);
>
> Best regards,
> Stefano Babic
>
> --
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
swupdate+u...@googlegroups.com
> <mailto:
swupdate+u...@googlegroups.com>.
> To view this discussion visit
https://groups.google.com/d/msgid/
> swupdate/1ae0b6b9-4160-4990-87f0-bd992fe218d9n%
40googlegroups.com
> <
https://groups.google.com/d/msgid/swupdate/1ae0b6b9-4160-4990-87f0-
> bd992fe218d9n%
40googlegroups.com?utm_medium=email&utm_source=footer>.