[RFC 0/2] Do not stop with an error when mkimage fails

Wolfgang Denk wd at denx.de
Sun Nov 7 15:48:06 CET 2021


Dear Heiko,

In message <CAEyMn7Zgn1ej3kGzg2kiCyqK5DQhkSdXNAUavZGs+3L_fb1Lvg at mail.gmail.com> you wrote:
>
> > > While converting to binman for an imx8mq board, it has been found that
> > > building in the u-boot CI fails. This is because an imx8mq requires an
> > > external binary (signed_hdmi_imx8m.bin). If this file cannot be found
> > > mkimage fails. To work around the problem the exception is caught, an
> > > error message is printed and binman continues.
> >
> > But how can you continue, when mkimage fails and cannot generate the
> > needed image?

Let me rephrase:

	How can can you continue, when mkimage fails and cannot
	_succesfully_ generate the needed image?

> > In your patch 2/2 we have this:
> >
> > +            tools.Run('mkimage', '-d', input_fname, *self._args, output_fname)
> > +        except Exception as e:
> > +            tout.Error("mkimage failed: %s" % e)
> > +
> >          self.SetContents(tools.ReadFile(output_fname))
> >
> > mkimage is supposed to create an output file which name is in
> > output_fname; if mkimage fails and you continue, the next step is
> > tools.ReadFile(output_fname) trying to read that file.  How is this
> > possible?
>
> # ls -al mkimage*
> -rw-r--r-- 1 hthiery hthiery      0 Nov  4 20:28 mkimage-out.spl.mkimage
> -rw-r--r-- 1 hthiery hthiery 180392 Nov  4 20:28 mkimage.spl.mkimage
>
> The file (mkimage-out.spl.mkimage) with size 0 seems to be created.  I
> assume mkimage will create that.

So in this situation we know that mkimage failed, and it generated
an empty output file.

I guess the output file is _not_ empty when no errors occur?

which reasonable results can you expect when you ignore an error and
just continue with garbage data as if nothing happened?

Sorry, but this makes no sense to me.  If there is an error, it
should be reported and - if possible - handled.  If this is not
possible, then the correct thing is to abort.  Ignoring errors and
trying to continue is always the worst thing to do.

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
"I go on working for the same reason a hen goes on laying eggs."
- H. L. Mencken


More information about the U-Boot mailing list