mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Riesch <michael.riesch@wolfvision.net>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH v3 7/7] of_overlay: Add option to apply overlay to live tree
Date: Tue, 14 Mar 2023 15:59:29 +0100	[thread overview]
Message-ID: <2b5df3a5-37f1-44f2-12f4-1bb6f2a0f379@wolfvision.net> (raw)
In-Reply-To: <20230310094222.2538259-8-s.hauer@pengutronix.de>

Hi Sascha,

On 3/10/23 10:42, Sascha Hauer wrote:
> The of_overlay command currently only supports applying overlays to the
> Linux device tree. Add an option to apply an overlay to the live tree.
> Using this option will apply the overlay and also triggers rescanning
> the device tree in case new devices have been added.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  commands/of_overlay.c | 38 ++++++++++++++++++++++++++++++++++----
>  1 file changed, 34 insertions(+), 4 deletions(-)
> 
> diff --git a/commands/of_overlay.c b/commands/of_overlay.c
> index b3660b4bf1..1d68e31ef2 100644
> --- a/commands/of_overlay.c
> +++ b/commands/of_overlay.c
> @@ -17,10 +17,20 @@ static int do_of_overlay(int argc, char *argv[])
>  	struct fdt_header *fdt;
>  	struct device_node *overlay;
>  	size_t size;
> +	bool live_tree = false;
> +	int opt;
>  
> -	if (argc != 2)
> +	if (argc < 2)
>  		return COMMAND_ERROR_USAGE;
>  
> +	while ((opt = getopt(argc, argv, "l")) > 0) {
> +		switch (opt) {
> +		case 'l':
> +			live_tree = true;
> +			break;
> +		}
> +	}
> +
>  	fdt = read_file(argv[optind], &size);

of course this is not the intended usage, but "of_overlay -l" (i.e.,
skipping the overlay argument) throws an exception.

>  	if (!fdt) {
>  		printf("cannot read %s\n", argv[optind]);
> @@ -32,7 +42,14 @@ static int do_of_overlay(int argc, char *argv[])
>  	if (IS_ERR(overlay))
>  		return PTR_ERR(overlay);
>  
> -	ret = of_register_overlay(overlay);
> +	if (live_tree) {
> +		ret = of_overlay_apply_tree(of_get_root_node(), overlay);

If I pass a meaningful argument ("of_overlay -l path_to_my_overlay"), I get

ERROR: of_resolver: __symbols__ missing from base devicetree
cannot apply oftree overlay: Invalid argument
of_overlay: Invalid argument

in return. The base device tree does not contain any __symbols__
sections indeed. How can I activate the generation of this section?

Thanks and regards,
Michael

> +		if (!ret)
> +			ret = of_probe();
> +	} else {
> +		ret = of_register_overlay(overlay);
> +	}
> +
>  	if (ret) {
>  		printf("cannot apply oftree overlay: %s\n", strerror(-ret));
>  		goto err;
> @@ -45,9 +62,22 @@ err:
>  	return ret;
>  }
>  
> +BAREBOX_CMD_HELP_START(of_overlay)
> +BAREBOX_CMD_HELP_TEXT("Register a device tree overlay file (dtbo) with barebox.")
> +BAREBOX_CMD_HELP_TEXT("By default the overlay is registered as a fixup and the")
> +BAREBOX_CMD_HELP_TEXT("overlay will then be applied to the Linux device tree.")
> +BAREBOX_CMD_HELP_TEXT("With -l given the overlay is applied to the barebox live")
> +BAREBOX_CMD_HELP_TEXT("tree instead. This involves probing new devices added in")
> +BAREBOX_CMD_HELP_TEXT("the overlay file.")
> +BAREBOX_CMD_HELP_TEXT("")
> +BAREBOX_CMD_HELP_TEXT("Options:")
> +BAREBOX_CMD_HELP_OPT("-l", "apply to barebox live tree")
> +BAREBOX_CMD_HELP_END
> +
>  BAREBOX_CMD_START(of_overlay)
>  	.cmd = do_of_overlay,
> -	BAREBOX_CMD_DESC("register device tree overlay as fixup")
> -	BAREBOX_CMD_OPTS("FILE")
> +	BAREBOX_CMD_DESC("register device tree overlay")
> +	BAREBOX_CMD_OPTS("[-l] FILE")
>  	BAREBOX_CMD_GROUP(CMD_GRP_MISC)
> +	BAREBOX_CMD_HELP(cmd_of_overlay_help)
>  BAREBOX_CMD_END



  reply	other threads:[~2023-03-14 15:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  9:42 [PATCH v3 0/7] support overlays to the barebox " Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 1/7] kbuild: Add target to build dtb overlay files Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 2/7] driver: Add rescan hook to struct device Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 3/7] i2c: implement rescan Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 4/7] spi: Directly register SPI device Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 5/7] spi: reduce scope of 'chip' Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 6/7] spi: implement rescan Sascha Hauer
2023-03-10  9:42 ` [PATCH v3 7/7] of_overlay: Add option to apply overlay to live tree Sascha Hauer
2023-03-14 14:59   ` Michael Riesch [this message]
2023-03-14 15:49     ` Sascha Hauer
2023-03-14 16:03       ` Michael Riesch
2023-03-15 16:09 ` [PATCH v3 0/7] support overlays to the barebox " Michael Riesch
2023-03-16  8:58   ` Sascha Hauer

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=2b5df3a5-37f1-44f2-12f4-1bb6f2a0f379@wolfvision.net \
    --to=michael.riesch@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@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