[PATCH v5] fdt: Allow the devicetree to come from a bloblist

Tom Rini trini at konsulko.com
Thu Dec 28 17:01:44 CET 2023


On Thu, Dec 28, 2023 at 01:36:54PM +0000, Simon Glass wrote:

> Standard passage provides for a bloblist to be passed from one firmware
> phase to the next. That can be used to pass the devicetree along as well.
> Add an option to support this.
> 
> Tests for this will be added as part of the Universal Payload work.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> The discussion on this was not resolved and is now important due to the
> bloblist series from Raymond. So I am sending it again since I believe
> this is a better starting point than building on OF_BOARD
[snip]
> @@ -1662,23 +1667,42 @@ static void setup_multi_dtb_fit(void)
>  
>  int fdtdec_setup(void)
>  {
> -	int ret;
> +	int ret = -ENOENT;
> +
> +	/* If allowing a bloblist, check that first */
> +	if (CONFIG_IS_ENABLED(OF_BLOBLIST)) {
> +		ret = bloblist_maybe_init();
> +		if (!ret) {
> +			gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0);
> +			if (gd->fdt_blob) {
> +				gd->fdt_src = FDTSRC_BLOBLIST;
> +				log_debug("Devicetree is in bloblist at %p\n",
> +					  gd->fdt_blob);
> +			} else {
> +				log_debug("No FDT found in bloblist\n");
> +				ret = -ENOENT;
> +			}
> +		}
> +	}
>  
> -	/* The devicetree is typically appended to U-Boot */
> -	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> -		gd->fdt_blob = fdt_find_separate();
> -		gd->fdt_src = FDTSRC_SEPARATE;
> -	} else { /* embed dtb in ELF file for testing / development */
> -		gd->fdt_blob = dtb_dt_embedded();
> -		gd->fdt_src = FDTSRC_EMBED;
> +	/* Otherwise, the devicetree is typically appended to U-Boot */
> +	if (ret) {
> +		if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> +			gd->fdt_blob = fdt_find_separate();
> +			gd->fdt_src = FDTSRC_SEPARATE;
> +		} else { /* embed dtb in ELF file for testing / development */
> +			gd->fdt_blob = dtb_dt_embedded();
> +			gd->fdt_src = FDTSRC_EMBED;
> +		}
>  	}

This whole if/else tree looks wrong today, and then wrong with this
patch. If we have an embedded device tree, which should only be used for
development (or special case needs, I _think_ some users today are using
this for security type needs), it must win and be used. The over-ride
switch was set, and should be used. Then, I don't know if we should be
saying "the user provided a tree via OF_SEPARATE, it should be used" or
"the device has passed us a tree via standard mechanism, it should be
used" is the higher priority. I really don't know which is more valid.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20231228/49d67eab/attachment.sig>


More information about the U-Boot mailing list