binman: Refactor fit to generate output at the end
authorSimon Glass <sjg@chromium.org>
Sun, 6 Mar 2022 03:19:01 +0000 (20:19 -0700)
committerSimon Glass <sjg@chromium.org>
Sat, 19 Mar 2022 01:24:25 +0000 (19:24 -0600)
commit38397d0833720f808370655f407c89bc5f1d8ce9
treefe70773991d920a74684809633f9600c28bbf179
parentc9ee33ac974b5ca2a818a1b0d684d5d27675b9a4
binman: Refactor fit to generate output at the end

At present the fit implementation creates the output tree while
scanning the FIT description. Then it updates the tree later when the
data is known.

This works, but is a bit confusing, since it requires mixing the scanning
code with the generation code, with a fix-up step at the end.

It is actually possible to do this in two phases, one to scan everything
and the other to generate the FIT. Thus the FIT is generated in one pass,
when everything is known.

Update the code accordingly. The only functional change is that the 'data'
property for each node are now last instead of first, which is really a
more natural position. Update the affected test to deal with this.

One wrinkle is that the calculated properties (image-pos, size and offset)
are now added before the FIT is generated. so we must filter these out
when copying properties from the binman description to the FIT.

Most of the change here is splitting out some of the code from the
ReadEntries() implementation into _BuildInput(). So despite the large
diff, most of the code is the same. It is not feasible to split this patch
up, so far as I can tell.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
tools/binman/etype/fit.py
tools/binman/ftest.py
tools/binman/test/224_fit_bad_oper.dts