All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denys Dmytriyenko" <denis@denix.org>
To: Nandor Han <nandor.han@vaisala.com>
Cc: Zach Booth <zbooth.dev@gmail.com>,
	openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH v3] classes: Add a new bbclass that abstracts the generation of FIT blobs
Date: Mon, 30 Mar 2020 12:07:48 -0400	[thread overview]
Message-ID: <20200330160748.GL1578@denix.org> (raw)
In-Reply-To: <d2cb84cb-0480-eef1-5731-5cdab254b864@vaisala.com>

On Fri, Mar 27, 2020 at 08:24:49PM +0200, Nandor Han wrote:
> On 2020-03-27 20:16, Denys Dmytriyenko wrote:
> >On Fri, Mar 27, 2020 at 07:33:24PM +0200, Nandor Han wrote:
> >>On 2020-03-27 17:11, Zach Booth wrote:
> >>>On Fri, Mar 27, 2020 at 3:29 AM Nandor Han <nandor.han@vaisala.com> wrote:
> >>>>
> >>>>FIT format is very versatile allowing various combination of booting
> >>>>sequences. In the same time different U-Boot boot stages can use FIT
> >>>>blobs to pack various binaries (e.g. SPL supports reading U-Boot from a
> >>>>FIT blob). Because of the allowed level of customization, the generation
> >>>>of a FIT blob using a fixed image tree source, becomes challenging and
> >>>>increase the level of complexity where different configurations and
> >>>>combinations are needed.
> >>>>
> >>>>This bbclass will know how to generate a FIT blob, leaving the mechanics
> >>>>of the process (dependencies, task order...) to be handled by the users
> >>>>of the bbclass. In the same time will allow to separate the knowledge of
> >>>>the FIT format leaving the user code cleaner and more readable.
> >>>>
> >>>>Signed-off-by: Nandor Han <nandor.han@vaisala.com>
> >>>
> >>>This class looks very useful, but I did have a question. How would you
> >>>account for creating nodes dynamically? One use case of this would be
> >>>adding a DT node for each reference in KERNEL_DEVICETREE. Would that
> >>>functionality be expected to go in the recipe including this class or
> >>>the class itself?
> >>>
> >>
> >>Thanks Zack for feedback. Like I mentioned in one of Rickard's
> >>answer, I'm planning to update the `kernel-fitimage.bbclass` to use
> >>this class.
> >>
> >>In my local repo I have already a class that does what you're saying.
> >>
> >>e.g
> >>```
> >>...
> >>24 python do_generate_fit_image() {
> >>  25     import os.path
> >>  26
> >>  27     device_trees = (d.getVar("KERNEL_DEVICETREE").split())
> >>  28     kernel_key_path =
> >>'{path}'.format(path=d.getVar("SECURITY_DIR_KEYS_RD") or "")
> >>  29     conf_signature = (d.getVar("CONF_NODE_CONF1") or "")
> >>  30     image_name = ""
> >>  31     mkimage_opts = ""
> >>  32
> >>  33     for dtb in device_trees:
> >>  34         d.setVarFlag("IMAGE_NODE_FDT", "data",
> >>'/incbin/("./arch/{arch}/boot/dts/{dtb}")'.format(
> >>  35          arch=d.getVar("ARCH"), dtb=dtb))
> >>  36         d.setVarFlag("IMAGE_NODE_FDT", "description", dtb)
> >>  37
> >>  38         if os.path.exists(kernel_key_path):
> >>  39             image_name =
> >>"kernel-{dtb_name}{suffix}".format(dtb_name=os.path.splitext(dtb)[0],
> >>suffix=".rdkeys")
> >>  40             mkimage_opts = d.getVar("FIT_IMAGE_MKIMAGE_OPTS_SIGNED")
> >>  41             d.setVar("FIT_IMAGE_UBOOT_MKIMAGE_OPTS", ("-k {key}
> >>-r {extra}".format(
> >>  42              key=kernel_key_path, extra=mkimage_opts)))
> >>  43             generate_fit_image(image_name, d)
> >>  44
> >>  45         if not conf_signature:
> >>  46             d.delVarFlag("CONF_NODE_CONF1", "signature")
> >>  47
> >>  48         mkimage_opts = d.getVar("FIT_IMAGE_MKIMAGE_OPTS_UNSIGNED")
> >>  49         d.setVar("FIT_IMAGE_UBOOT_MKIMAGE_OPTS",
> >>"{extra}".format(extra=mkimage_opts))
> >>  50         image_name =
> >>"kernel-{dtb_name}{suffix}".format(dtb_name=os.path.splitext(dtb)[0],
> >>suffix=".unsigned")
> >>  51         generate_fit_image(image_name, d)
> >>  52
> >>  53         if not conf_signature:
> >>  54             d.setVarFlag("CONF_NODE_CONF1", "signature",
> >>conf_signature)
> >>  55 }
> >>...
> >>```
> >>
> >>The code above will generate a separate FIT blob for every device
> >>tree declared in KERNEL_DEVICETREE. However this functionality
> >
> >So, no multiple device trees in a single FIT image? No multiple
> >configurations, ramdisks, etc?
> 
> Given the class API is possible to configure your FIT source as you
> want. However, my plan is to refactor `kernel-fitimage` class to
> have this kind of features. The above code was only an example,
> something that I'm working on. I want to get this in and then it's
> easier to add new functionalities.

Considering that fitimage is a critical functionality used by many BSPs 
(even though it's not used in OE-Core itself), breaking it would upset 
so many people... Not sure about this gradual approach.

-- 
Denys


> >>overlaps with `kernel-fitimage` and my target is to keep this class
> >>as simple as possible and refactor `kernel-fitimage` to use the
> >>`fit_image` class. The code above will go in `kernel-fitimage`.
> >>
> >>Later on I'm planning to add a different class that can be use to
> >>generate U-Boot FIT blobs, which can be used by SPL.
> >>
> >>So this is only the first step :)
> >>
> 
> Nandor
> 

  reply	other threads:[~2020-03-30 16:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 21:43 [PATCH] Add a new bbclass that abstracts the generation of FIT blobs nandor.han
2020-03-27  7:15 ` [PATCH v2] classes: " Nandor Han
2020-03-27 17:23   ` [OE-core] " Alex Kiernan
2020-03-27 17:54     ` Nandor Han
2020-03-27  8:29 ` [PATCH v3] " Nandor Han
2020-03-27 15:11   ` [OE-core] " Zach Booth
2020-03-27 17:33     ` Nandor Han
2020-03-27 18:16       ` Denys Dmytriyenko
2020-03-27 18:24         ` Nandor Han
2020-03-30 16:07           ` Denys Dmytriyenko [this message]
2020-03-30 16:46             ` Nandor Han
2020-03-27 16:35   ` Richard Purdie
2020-03-27 17:18     ` Nandor Han
2020-05-26 17:57 ` [OE-core][PATCH v4 0/3] " Nandor Han
2020-05-26 17:57   ` [OE-core][PATCH v4 1/3] Add a recipe for `python3-fdt` package Nandor Han
2020-05-26 17:57   ` [OE-core][PATCH v4 2/3] classes: Add a new bbclass that abstracts the generation of FIT blobs Nandor Han
2020-05-26 17:57   ` [OE-core][PATCH v4 3/3] selftest: add a unit-test for fit-image bbclass Nandor Han
2020-05-26 17:57 ` [PATCH v3] classes: Add a new bbclass that abstracts the generation of FIT blobs Nandor Han
2020-05-26 18:02 ` ✗ patchtest: failure for Add a new bbclass that abstracts the generation of FIT blobs (rev6) Patchwork

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=20200330160748.GL1578@denix.org \
    --to=denis@denix.org \
    --cc=nandor.han@vaisala.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=zbooth.dev@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.