From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH v4 07/11] of: overlay: add FIT image overlay support
Date: Tue, 5 Aug 2025 12:57:06 +0200 [thread overview]
Message-ID: <aJHjgp5uJI47PXK6@pengutronix.de> (raw)
In-Reply-To: <20250729-v2024-05-0-topic-fit-overlay-v4-7-af3ad99acde2@pengutronix.de>
On Tue, Jul 29, 2025 at 05:34:32PM +0200, Marco Felsch wrote:
> This adds the support to load devicetree overlays from a FIT image.
> There are a few options to handle FIT overlays since the FIT overlay
> spec is not very strict.
>
> This implements the most configurable case where each overlay does have
> its own config node (including the optional signature).
>
> - The "pattern" filter matches the config-node names (the node names
> below the configurations node), not the overlay image names (the node
> names below the images node).
>
> - The "compatible" filter check doesn't differ from the file based overlay
> handling.
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> Documentation/user/devicetree.rst | 19 +++---
> drivers/of/overlay.c | 132 +++++++++++++++++++++++++++++++++++---
> 2 files changed, 134 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index f02a12d44f0d53db3fb7bb065461c0ef193d0ab3..604ce0998cd8044cca59c40e65f4e9b95bec6112 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
> @@ -8,10 +8,13 @@
> */
> #define pr_fmt(fmt) "of_overlay: " fmt
>
> +#include <bootm.h>
> #include <common.h>
> #include <of.h>
> #include <errno.h>
> +#include <filetype.h>
> #include <globalvar.h>
> +#include <image-fit.h>
> #include <magicvar.h>
> #include <string.h>
> #include <libfile.h>
> @@ -463,8 +466,99 @@ static int of_overlay_apply_dir(struct device_node *root, const char *dirname,
> return ret;
> }
>
> +static int of_overlay_apply_fit(struct device_node *root, struct fit_handle *fit,
> + struct device_node *config)
> +{
> + const char *name = config->name;
> + struct device_node *overlay;
> + unsigned long ovl_sz;
> + const void *ovl;
> + int ret;
> +
> + if (!of_overlay_matches_filter(name, NULL))
> + return 0;
> +
> + ret = fit_open_image(fit, config, "fdt", &ovl, &ovl_sz);
> + if (ret)
> + return ret;
> +
> + overlay = of_unflatten_dtb(ovl, ovl_sz);
> +
> + if (!of_overlay_matches_filter(NULL, overlay)) {
> + ret = 0;
> + goto out;
> + }
> +
> + ret = of_overlay_apply_tree(root, overlay);
> + if (ret == -ENODEV)
> + pr_debug("Not applied %s (not compatible)\n", name);
> + else if (ret)
> + pr_err("Cannot apply %s: %s\n", name, strerror(-ret));
> + else
> + pr_info("Applied %s\n", name);
> +
> +out:
> + of_delete_node(overlay);
> +
> + return ret;
> +}
> +
> +static bool of_overlay_valid_config(struct fit_handle *fit,
> + struct device_node *config)
> +{
> + /*
> + * Either kernel or firmware is marked as mandatory by U-Boot
> + * (doc/usage/fit/source_file_format.rst) except for overlays
> + * (doc/usage/fit/overlay-fdt-boot.rst). Therefore we need to ensure
> + * that only "fdt" config nodes are recognized as overlay config node.
> + */
> + if (!fit_has_image(fit, config, "fdt") ||
> + fit_has_image(fit, config, "kernel") ||
> + fit_has_image(fit, config, "firmware"))
> + return false;
> +
> + return true;
> +}
> +
> +static int of_overlay_global_fixup_fit(struct device_node *root,
> + const char *fit_path, loff_t fit_size)
> +{
> + enum bootm_verify verify = bootm_get_verify_mode();
> + struct device_node *conf_node;
> + struct fit_handle *fit;
> + int ret;
> +
> + if (!IS_ENABLED(CONFIG_FITIMAGE))
> + return 0;
The comments in https://lore.barebox.org/barebox/ZpT3h0o089tae2WS@pengutronix.de/
do not seem to be addressed here.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-08-05 11:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 15:34 [PATCH v4 00/11] Add " Marco Felsch
2025-07-29 15:34 ` [PATCH v4 01/11] FIT: fix missing free in fit_open error path Marco Felsch
2025-07-29 15:34 ` [PATCH v4 02/11] FIT: fit_open_configuration: add match function support Marco Felsch
2025-07-29 15:34 ` [PATCH v4 03/11] of: overlay: make the pattern match function more generic Marco Felsch
2025-07-29 15:34 ` [PATCH v4 04/11] of: overlay: make search dir " Marco Felsch
2025-07-29 15:34 ` [PATCH v4 05/11] of: overlay: refactor of_overlay_global_fixup Marco Felsch
2025-07-29 15:34 ` [PATCH v4 06/11] FIT: make fit_config_verify_signature public Marco Felsch
2025-07-29 15:34 ` [PATCH v4 07/11] of: overlay: add FIT image overlay support Marco Felsch
2025-08-05 10:57 ` Sascha Hauer [this message]
2025-08-05 20:14 ` Marco Felsch
2025-07-29 15:34 ` [PATCH v4 08/11] of: overlay: replace filename with an more unique name Marco Felsch
2025-07-29 15:34 ` [PATCH v4 09/11] FIT: fit_open: make filename handling more robust Marco Felsch
2025-07-29 15:34 ` [PATCH v4 10/11] FIT: fit_open: save the filename Marco Felsch
2025-07-29 15:34 ` [PATCH v4 11/11] FIT: add support to cache opened fit images Marco Felsch
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=aJHjgp5uJI47PXK6@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.felsch@pengutronix.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