public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [PATCH 2/2] schemas: Add a schema for binman
Date: Thu, 3 Aug 2023 22:29:47 +0300	[thread overview]
Message-ID: <b88502c6-b258-e4ea-e59c-2d1a1e30b75c@gmail.com> (raw)
In-Reply-To: <CAPnjgZ1DBMX+Th61TFmKtfq8oFtQCvpcivTahVtijRvwdJwf-Q@mail.gmail.com>

(I think I've strayed far away from schema/dtb side of things towards
binman-the-program side, so I'm dropping Rob and devicetree@ from Cc).

On 2023-07-20 22:55 +03:00, Simon Glass wrote:
> On Thu, 20 Jul 2023 at 09:23, Alper Nebi Yasak <alpernebiyasak@gmail.com> wrote:
>> There's also the issue of binman having multiple different device-trees:
>> its input, the ones in fdtmaps per image, the ones injected to U-Boot
>> dtb files per image. I'd say each has different needs, and those
>> differences have to be figured out before specified upstream. I can only
>> guess this is about the one that'll be in a u-boot.dtb.
> 
> Well, there is really only one. The fdtmap is actually the same
> schema, except that it mentions only the image that it is embedded in,
> i.e. if the fdtmap is for the SPI image, then the fdtmap in SPI flash
> only contains the definition for the SPI image, not the MMC image
> which is in a different device. The input is the same schema, albeit
> that things like 'offset' may be filled in by Binman automatically
> when it packs things.

I was thinking of things like generator nodes and templates and
"filename"s in blob entries that (IMO) only make sense as binman inputs
and never should be in a fdtmap. Trying to highlight a difference
between "how to build this image" and "what this image contains".

But I guess it's OK to call them the same schema unless something has
two conflicting meanings in input-domain and output-domain, and I can't
think of any counter-examples now.

>> I want to go through binman more thoroughly, but a lot of changes
>> happened since I last looked at it and I'm a bit slow at writing things,
>> so won't exactly be soon. That being said, here's some ideas off the top
>> of my head, for inspiration on both this schema and binman itself.
> 
> Do you mean the code? There are definitely some abstractions that are
> stretching a bit, but it is mostly holding together for now.

I mean both the implementation and the design. There's a lot more on my
mind, some more examples:

- Precise structures for data instead of thinking of them as black boxes
- Heuristically parsing arbitrary images/data for e.g. binman extract
- Deconstructing input files to reuse their pieces for building images
- Explicit dependency tracking and resolution for data and layout
- Making things act more like native Python objects
- In fact, making it entirely operable with just Python code
- Decoupling internals from the control dtbs ("entry._node" etc.)
- Ensuring reproducible builds and testing for it
- Fuzzing as a replacement for most tests
- ...

I think it has the beginnings of a very nice declarative-style tool, but
has to embrace that style to get there. (And I guess I'll have to do the
work to properly express myself on some points...)

> [...]

>> Or maybe even better, I think we should make it like FIT: allow a "data"
>> property that has it inside the dtb, or a pair of "data-offset/position"
>> and "data-size" properties if it's outside.
> 
> Eh? The point of the entry is to declare the position of actual data.
> If the data is elsewhere, then the entry will be too.

Sorry, I'm jumping into a different contexts here without explaining it.
I'm seeing a similarity between images that start with a fdtmap and the
images built by "mkimage -T fit -E". Then I'm extrapolating to the
non-"-E" case. Then extending to make it possible for a "fdtmap + data"
binman description to result in something almost backwards-compatible
with FIT, which could replace most uses of a fit etype.

(Of course, backwards compatible only if you add config nodes, and
flatten or don't nest entries, and whatnot. And fit etype would still stay.)

>> Inlining data inside the dtb
>> could help us do nice things in binman, like hashes/signatures as entry
>> types instead of special-casing them.
> 
> We already do that though, right? See testHash() for example. This is
> a powerful feature of a firmware-layout description / Binman, IMO,
> since all the metadata you need is right there.

Having that functionality in state.py and having to work around it for
mkimage/fit etypes (because we want to embed them into the data instead
of the binman dtb) is what I mean by special-casing.

If we had them as etypes, and could embed arbitrary entries as "data" in
binman dtb, I think we would have the best of both worlds -- avoid
calling mkimage just for hash/signature embedding, have it still
possible to put those in binman metadata, and enable a foundation for
other sign-verify flows (leaning towards replacing custom signing
tools/scripts with binman).

>> In fact it could be possible to turn binman images into a FIT 2.0 if we
>> do some more work on top of that, instead of nesting a FIT inside a
>> binman image.
> 
> Well binman needs to produce things which are not FITs. Bear in mind
> that the output can be a binary file in any format. It doesn't
> necessarily have to have any metadata in it at all, certainly not a
> FIT header.

I know, I don't mean it as the only mode of operation, I hope I have
explained better this time.

> Thanks again for your encouraging comments. I'll do a v2 with the above changes.

I'm glad to hear that you appreciate my comments, because trying to
review your work always feels quite hubristic to me, haha.

  reply	other threads:[~2023-08-03 19:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 21:18 [PATCH 1/2] schemas: Add firmware node schema Simon Glass
2023-07-11 21:18 ` [PATCH 2/2] schemas: Add a schema for binman Simon Glass
2023-07-20 15:23   ` Alper Nebi Yasak
2023-07-20 19:55     ` Simon Glass
2023-08-03 19:29       ` Alper Nebi Yasak [this message]
2023-08-12 13:09         ` Simon Glass
2023-07-14 16:58 ` [PATCH 1/2] schemas: Add firmware node schema Rob Herring
2023-07-14 17:57   ` Simon Glass
2023-07-19 21:06     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b88502c6-b258-e4ea-e59c-2d1a1e30b75c@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox