spl: fit: List DTOs applied by SPL in U-Boot control DT
PATCH 1/1 spl: fit: List DTOs applied by SPL in U-Boot control DT
Insert /u-boot,<dto-name> = <index> property into the U-Boot control DT during SPL DTO application process. This can be used by user to inspect which DTOs got applied by the SPL and in which order from running U-Boot.
Example:
```
u-boot=> fdt addr $fdtcontroladdr && fdt list /
Working FDT set to aee9aeb0
/ {
u-boot,fdt-dto-imx8mp-dhcom-pdk3-overlay-rev100 = <0x00000005>;
u-boot,fdt-dto-imx8mp-dhcom-som-overlay-rev100 = <0x00000004>;
u-boot,fdt-dto-imx8mp-dhcom-pdk-overlay-eth2xfast = <0x00000003>;
u-boot,fdt-dto-imx8mp-dhcom-som-overlay-eth2xfast = <0x00000002>;
...
```---
Cc: Manoj Sai <[email protected]>
Cc: Sean Anderson <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Suniel Mahesh <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- common/spl/spl_fit.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
common/spl/spl_fit.c +22 -1
@@ -363,6 +363,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, {struct spl_image_info image_info;int node, ret =0 , index =0 ; +char dtoname[256 ];/* * Use the address following the image as target address for the
@@ -450,7 +451,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,/* Make room in FDT for changes from the overlay */ ret =fdt_increase_size (spl_image->fdt_addr, - image_info.size); + image_info.size +strlen (str));if (ret <0 )break ;
@@ -464,6 +465,26 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,debug ("%s: DT overlay %s applied\n" , __func__,fit_get_name (ctx->fit, node,NULL )); + +/* +* Insert /u-boot,<dto-name> = <index> property into +* the U-Boot control DT. This can be used by user +* to inspect which DTOs got applied by the SPL from +* a running U-Boot. +*/ +snprintf (dtoname,sizeof (dtoname),"u-boot,%s" , str); + ret =fdt_setprop_u32 (spl_image->fdt_addr,0 , dtoname, + index); +if (!ret) { +/* +* The DTO itself was applied, do not treat the +* insertion of /u-boot,<dto-name> as an error +* so the system can possibly boot somehow. +*/ +debug ("%s: DT overlay %s name not inserted into / node (%d)\n" , + __func__, +fit_get_name (ctx->fit, node,NULL ), ret); + } }free (tmpbuffer);if (ret)
Signature · 1 line
2.43.0
Hi Marek,
Quoted 43 lines · Marek Vasut
Insert /u-boot,<dto-name> = <index> property into the U-Boot control DT during SPL DTO application process. This can be used by user to inspect which DTOs got applied by the SPL and in which order from running U-Boot.
Example:
``` u-boot=> fdt addr $fdtcontroladdr && fdt list / Working FDT set to aee9aeb0 / { u-boot,fdt-dto-imx8mp-dhcom-pdk3-overlay-rev100 = <0x00000005>; u-boot,fdt-dto-imx8mp-dhcom-som-overlay-rev100 = <0x00000004>; u-boot,fdt-dto-imx8mp-dhcom-pdk-overlay-eth2xfast = <0x00000003>; u-boot,fdt-dto-imx8mp-dhcom-som-overlay-eth2xfast = <0x00000002>; ... ```Signed-off-by Marek Vasut <[email protected]>---
Cc: Manoj Sai <[email protected]>
Cc: Sean Anderson <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Suniel Mahesh <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]--- common/spl/spl_fit.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)common/spl/spl_fit.c +1
-0@@ -363,6 +363,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, {struct spl_image_info image_info;int node, ret =0 , index =0 ; +char dtoname[256 ];/* * Use the address following the image as target address for the
common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 454
Quoted 5 lines
common/spl/spl_fit.c +1
-1@@ -450,7 +451,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,/* Make room in FDT for changes from the overlay */ ret =fdt_increase_size (spl_image->fdt_addr, - image_info.size); + image_info.size +strlen (str));
You may also need space for the string terminator (i.e. add 1 more byte).
Quoted 8 lines
common/spl/spl_fit.c +1
-0if (ret <0 )break ;@@ -464,6 +465,26 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,debug ("%s: DT overlay %s applied\n" , __func__,fit_get_name (ctx->fit, node,NULL )); +
common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 478
Quoted 10 lines
common/spl/spl_fit.c +10
-0+/* +* Insert /u-boot,<dto-name> = <index> property into +* the U-Boot control DT. This can be used by user +* to inspect which DTOs got applied by the SPL from +* a running U-Boot. +*/ +snprintf (dtoname,sizeof (dtoname),"u-boot,%s" , str); + ret =fdt_setprop_u32 (spl_image->fdt_addr,0 , dtoname, + index); +if (!ret) {
This means there was no error, right?
common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 487
Quoted 9 lines
common/spl/spl_fit.c +9
-0+/* +* The DTO itself was applied, do not treat the +* insertion of /u-boot,<dto-name> as an error +* so the system can possibly boot somehow. +*/ +debug ("%s: DT overlay %s name not inserted into / node (%d)\n" , + __func__, +fit_get_name (ctx->fit, node,NULL ), ret); + }
log_debug()
Quoted 6 lines
common/spl/spl_fit.c +0
-1}free (tmpbuffer);if (ret) --2.43.0
Regards,
Simon
On 6/27/24 10:37 AM, Simon Glass wrote:
Hi,
Quoted 7 lines
common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 454
Quoted 5 lines
/* Make room in FDT for changes from the overlay */ ret = fdt_increase_size(spl_image->fdt_addr,common/spl/spl_fit.c +1
-1- image_info.size); + image_info.size + strlen(str));You may also need space for the string terminator (i.e. add 1 more byte).
Fixed in V2 with expanded comment, thanks.
Quoted 5 lines
Quoted 5 lines
if (ret < 0) break;(quoted diff) +0
-0@@ -464,6 +465,26 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
Quoted 15 lines
common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 478
Quoted 13 lines
common/spl/spl_fit.c +11
-0debug ("%s: DT overlay %s applied\n" , __func__,fit_get_name (ctx->fit, node,NULL )); + +/* +* Insert /u-boot,<dto-name> = <index> property into +* the U-Boot control DT. This can be used by user +* to inspect which DTOs got applied by the SPL from +* a running U-Boot. +*/ +snprintf (dtoname,sizeof (dtoname),"u-boot,%s" , str); + ret =fdt_setprop_u32 (spl_image->fdt_addr,0 , dtoname, + index); +if (!ret) {This means there was no error, right?
Yes, this should be inverted, thanks.
Quoted 11 lines
common/spl/spl_fit.c static int spl_fit_append_fdt(struct spl_image_info *spl_image, · line 487
Quoted 9 lines
common/spl/spl_fit.c +9
-0+/* +* The DTO itself was applied, do not treat the +* insertion of /u-boot,<dto-name> as an error +* so the system can possibly boot somehow. +*/ +debug ("%s: DT overlay %s name not inserted into / node (%d)\n" , + __func__, +fit_get_name (ctx->fit, node,NULL ), ret); + }
log_debug()
The whole file uses debug(), so let's keep it consistent.
Thanks !
Hi Marek,
Quoted 5 lines · Marek Vasut
Insert /u-boot,<dto-name> = <index> property into the U-Boot control DT during SPL DTO application process. This can be used by user to inspect which DTOs got applied by the SPL and in which order from running U-Boot.
Example:
Quoted 11 lines
```
u-boot=> fdt addr $fdtcontroladdr && fdt list /
Working FDT set to aee9aeb0
/ {
u-boot,fdt-dto-imx8mp-dhcom-pdk3-overlay-rev100 = <0x00000005>;
u-boot,fdt-dto-imx8mp-dhcom-som-overlay-rev100 = <0x00000004>;
u-boot,fdt-dto-imx8mp-dhcom-pdk-overlay-eth2xfast = <0x00000003>;
u-boot,fdt-dto-imx8mp-dhcom-som-overlay-eth2xfast = <0x00000002>;
...
```Shouldn't this rather be in /config node?
Also, I am highly suggesting to have an additional prefix aside from u-boot to avoid unfortunate name clashes between DTO and existing properties. Or could be in its own child node of /config ?
In any case, can you please add or edit a file somewhere to define this new dt-binding.
Additional question, what is this index for?
I am wondering if we cannot simply have a string array with overlays applied left-to-right or right-to-left instead? Or u-boot,fdt-dto-N = "imx8mp-dhcom-pdk3-overlay-rev100";
Cheers,
Quentin
Quoted 1 line · Quentin Schulz
Hi Marek,
Hi,
Quoted 18 lines · Marek Vasut
Quoted 5 lines
Insert /u-boot,<dto-name> = <index> property into the U-Boot control DT during SPL DTO application process. This can be used by user to inspect which DTOs got applied by the SPL and in which order from running U-Boot.
Example:
Quoted 11 lines
``` u-boot=> fdt addr $fdtcontroladdr && fdt list / Working FDT set to aee9aeb0 / { u-boot,fdt-dto-imx8mp-dhcom-pdk3-overlay-rev100 = <0x00000005>; u-boot,fdt-dto-imx8mp-dhcom-som-overlay-rev100 = <0x00000004>; u-boot,fdt-dto-imx8mp-dhcom-pdk-overlay-eth2xfast = <0x00000003>; u-boot,fdt-dto-imx8mp-dhcom-som-overlay-eth2xfast = <0x00000002>; ... ```
Quoted 1 line
Shouldn't this rather be in /config node?
This is what I had there originally, but then I realized that some DTs might not have the /config node in them (or am I mistaken?), so I moved the new properties into the root node, which surely exists.
It also keeps the code simpler, as it doesn't have to fiddle with creation of the /config node if it doesn't exist.
Quoted 1 line
Also, I am highly suggesting to have an additional prefix aside from u-boot to avoid unfortunate name clashes between DTO and existing properties.
OK, fixed in V2.
Quoted 1 line
Or could be in its own child node of /config ?
Please see above.
Quoted 1 line
In any case, can you please add or edit a file somewhere to define this new dt-binding.
Done in V2
Quoted 1 line
Additional question, what is this index for?
To indicate in which order the DTOs were applied by the SPL. It matches the order in which the the DTOs are stored in the fitImage and the order in which SPL iterates over them. In case the SPL skips a DTO using board_spl_fit_append_fdt_skip(), the integer sequence might have gaps.
Quoted 1 line
I am wondering if we cannot simply have a string array with overlays applied left-to-right or right-to-left instead? Or u-boot,fdt-dto-N = "imx8mp-dhcom-pdk3-overlay-rev100";
We can, but that is much harder to test for presence of specific DTO on U-Boot command line. It is easy to test for presence of boolean or integer DT property using 'fdt' command.
Thanks !
Hi Marek,
Quoted 23 lines · Marek Vasut
Quoted 1 line · Quentin Schulz
Hi Marek,
Hi,
Quoted 18 lines · Marek Vasut
Quoted 16 lines
Insert /u-boot,<dto-name> = <index> property into the U-Boot control DT during SPL DTO application process. This can be used by user to inspect which DTOs got applied by the SPL and in which order from running U-Boot.
Example:
``` u-boot=> fdt addr $fdtcontroladdr && fdt list / Working FDT set to aee9aeb0 / { u-boot,fdt-dto-imx8mp-dhcom-pdk3-overlay-rev100 = <0x00000005>; u-boot,fdt-dto-imx8mp-dhcom-som-overlay-rev100 = <0x00000004>; u-boot,fdt-dto-imx8mp-dhcom-pdk-overlay-eth2xfast = <0x00000003>; u-boot,fdt-dto-imx8mp-dhcom-som-overlay-eth2xfast = <0x00000002>; ... ```
Quoted 6 lines
Quoted 1 line
Shouldn't this rather be in /config node?
This is what I had there originally, but then I realized that some DTs might not have the /config node in them (or am I mistaken?), so I moved the new properties into the root node, which surely exists.
It also keeps the code simpler, as it doesn't have to fiddle with creation of the /config node if it doesn't exist.
I don't think we should pollute the root node with this. If we want to be able to expose this in a proper binding to the upstream DT binding repo, I'm not sure this is going to fly :/
Quoted 12 lines
Quoted 1 line
Also, I am highly suggesting to have an additional prefix aside from u-boot to avoid unfortunate name clashes between DTO and existing properties.
OK, fixed in V2.
Quoted 1 line
Or could be in its own child node of /config ?
Please see above.
Quoted 1 line
In any case, can you please add or edit a file somewhere to define this new dt-binding.
Done in V2
Quoted 8 lines
Quoted 1 line
Additional question, what is this index for?
To indicate in which order the DTOs were applied by the SPL. It matches the order in which the the DTOs are stored in the fitImage and the order in which SPL iterates over them. In case the SPL skips a DTO using
board_spl_fit_append_fdt_skip(), the integer sequence might have gaps.Quoted 1 line
I am wondering if we cannot simply have a string array with overlays applied left-to-right or right-to-left instead? Or u-boot,fdt-dto-N = "imx8mp-dhcom-pdk3-overlay-rev100";
We can, but that is much harder to test for presence of specific DTO on U-Boot command line. It is easy to test for presence of boolean or integer DT property using 'fdt' command.
Not sure dt-bindings people would love to hear that we adapt the fdt to be easier to work with from the U-Boot CLI :)
In any case, another few thoughts that popped up overnight:
1- do we want to have this for SPL DTB modified by TPL? If so, I'm sure we want it different from the one passed from SPL to U-Boot proper IFF we start from a clean sheet (new DTB) and/or add the DTBO we applied on top the DTBOs already applied by the TPL to the SPL DTB before passing it to proper 2- Add info about which DTBOs were applied to the kernel DTB?
Cheers,
Quentin
On 6/28/24 10:27 AM, Quentin Schulz wrote:
Hi,
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Shouldn't this rather be in /config node?
This is what I had there originally, but then I realized that some DTs might not have the /config node in them (or am I mistaken?), so I moved the new properties into the root node, which surely exists.
It also keeps the code simpler, as it doesn't have to fiddle with creation of the /config node if it doesn't exist.
I don't think we should pollute the root node with this. If we want to be able to expose this in a proper binding to the upstream DT binding repo, I'm not sure this is going to fly :/
The other option is to add more code into SPL, that's not great.
I can check if /config node exists, and if so, add it there, otherwise do nothing. That should be some sort of compromise between bloat and config node. What do you think ?
[...]
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
I am wondering if we cannot simply have a string array with overlays applied left-to-right or right-to-left instead? Or u-boot,fdt-dto-N = "imx8mp-dhcom-pdk3-overlay-rev100";
We can, but that is much harder to test for presence of specific DTO on U-Boot command line. It is easy to test for presence of boolean or integer DT property using 'fdt' command.
Not sure dt-bindings people would love to hear that we adapt the fdt to be easier to work with from the U-Boot CLI :)
In any case, another few thoughts that popped up overnight:
1- do we want to have this for SPL DTB modified by TPL? If so, I'm sure we want it different from the one passed from SPL to U-Boot proper IFF we start from a clean sheet (new DTB) and/or add the DTBO we applied on top the DTBOs already applied by the TPL to the SPL DTB before passing it to proper
As far as I can tell, TPL currently does not support loading fitImages and applying DTOs from them. When this is available, I suspect the prefix of the newly added property would change from u-boot,spl-applied-dto- to u-boot,tpl-applied-dto- and that would be it.
Quoted 1 line
2- Add info about which DTBOs were applied to the kernel DTB?
SPL DTOs or DTOs applied from kernel fitImage ? Or a merging of those ?
Hi Marek,
Quoted 11 lines · Marek Vasut
On 6/28/24 10:27 AM, Quentin Schulz wrote:
Hi,
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
Shouldn't this rather be in /config node?
This is what I had there originally, but then I realized that some DTs might not have the /config node in them (or am I mistaken?), so I moved the new properties into the root node, which surely exists.
It also keeps the code simpler, as it doesn't have to fiddle with creation of the /config node if it doesn't exist.
Quoted 8 lines
Quoted 1 line
I don't think we should pollute the root node with this. If we want to be able to expose this in a proper binding to the upstream DT binding repo, I'm not sure this is going to fly :/
The other option is to add more code into SPL, that's not great.
I can check if /config node exists, and if so, add it there, otherwise do nothing. That should be some sort of compromise between bloat and config node. What do you think ?
[...]
Considering that we're trying to have the same DT for U-Boot and Linux kernel in the long run and that git grep "\s+config {" returns nothing in dts/upstream/src, I'm not sure this amounts to anything but dead-code? We could also always insert this node as pre/post process of the DT compilation? But I think some people want to reuse the exact same DTB (like, the binary itself) between U-Boot and the Linux kernel.
I guess we can start with checking if the /config node exists and we can figure something smarter once we need it?
[...]
Quoted 3 lines
Quoted 1 line
2- Add info about which DTBOs were applied to the kernel DTB?
SPL DTOs or DTOs applied from kernel fitImage ? Or a merging of those ?
DTOs that U-Boot proper applies to the kernel DTB either via fitimage configs, maybe also via syslinux (via fdtoverlays/devicetree-overlay) and the like?
Cheers,
Quentin
Quoted 1 line · Quentin Schulz
Hi Marek,
Hi,
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Shouldn't this rather be in /config node?
This is what I had there originally, but then I realized that some DTs might not have the /config node in them (or am I mistaken?), so I moved the new properties into the root node, which surely exists.
It also keeps the code simpler, as it doesn't have to fiddle with creation of the /config node if it doesn't exist.
I don't think we should pollute the root node with this. If we want to be able to expose this in a proper binding to the upstream DT binding repo, I'm not sure this is going to fly :/
Quoted 8 lines
Quoted 6 lines
The other option is to add more code into SPL, that's not great.
I can check if /config node exists, and if so, add it there, otherwise do nothing. That should be some sort of compromise between bloat and config node. What do you think ?
[...]
Considering that we're trying to have the same DT for U-Boot and Linux kernel in the long run and that
git grep "\s+config {"returns nothing in dts/upstream/src, I'm not sure this amounts to anything but dead-code? We could also always insert this node as pre/post process of the DT compilation? But I think some people want to reuse the exact same DTB (like, the binary itself) between U-Boot and the Linux kernel.
In my case, the /config node is inserted via *-u-boot.dtsi , I don't think those DT extras are going away anytime soon, esp. because of the 'bootph-*' properties.
Quoted 9 lines
I guess we can start with checking if the /config node exists and we can figure something smarter once we need it?
[...]
Quoted 3 lines
Quoted 1 line
2- Add info about which DTBOs were applied to the kernel DTB?
SPL DTOs or DTOs applied from kernel fitImage ? Or a merging of those ?
DTOs that U-Boot proper applies to the kernel DTB either via fitimage configs, maybe also via syslinux (via
fdtoverlays/devicetree-overlay) and the like?
Isn't that something that would be better (=more flexible and fixable if broken without bootloader update) done in a boot script which could be embedded in a fitImage ?
Hi Marek,
Quoted 16 lines · Marek Vasut
Quoted 1 line · Quentin Schulz
Hi Marek,
Hi,
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Shouldn't this rather be in /config node?
This is what I had there originally, but then I realized that some DTs might not have the /config node in them (or am I mistaken?), so I moved the new properties into the root node, which surely exists.
It also keeps the code simpler, as it doesn't have to fiddle with creation of the /config node if it doesn't exist.
I don't think we should pollute the root node with this. If we want to be able to expose this in a proper binding to the upstream DT binding repo, I'm not sure this is going to fly :/
The other option is to add more code into SPL, that's not great.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
I can check if /config node exists, and if so, add it there, otherwise do nothing. That should be some sort of compromise between bloat and config node. What do you think ?
[...]
Considering that we're trying to have the same DT for U-Boot and Linux kernel in the long run and that
git grep "\s+config {"returns nothing in dts/upstream/src, I'm not sure this amounts to anything but dead-code? We could also always insert this node as pre/post process of the DT compilation? But I think some people want to reuse the exact same DTB (like, the binary itself) between U-Boot and the Linux kernel.In my case, the /config node is inserted via *-u-boot.dtsi , I don't think those DT extras are going away anytime soon, esp. because of the 'bootph-*' properties.
The bootph properties are standardized (?) now. The kernel accepts them (see the ti and xilinx DTSes for Aarch64 for example) and it's part of the dt-schema now: https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/bootph.yaml though I cannot find it in the DT specification (not sure they need to be there though).
Quoted 11 lines
Quoted 9 lines
I guess we can start with checking if the /config node exists and we can figure something smarter once we need it?
[...]
Quoted 3 lines
Quoted 1 line
2- Add info about which DTBOs were applied to the kernel DTB?
SPL DTOs or DTOs applied from kernel fitImage ? Or a merging of those ?
DTOs that U-Boot proper applies to the kernel DTB either via fitimage configs, maybe also via syslinux (via
fdtoverlays/devicetree-overlay) and the like?Isn't that something that would be better (=more flexible and fixable if broken without bootloader update) done in a boot script which could be embedded in a fitImage ?
That's one way to do it though you risk desynchronization between the boot script and which overlays are applied and in which order. Additionally, can we actually already run a boot script from a configuration node? Because one can simply boot with a fit configuration and all of its DTBOs will be applied (if I'm not mistaken), if the boot script needs to be executed standalone before booting the configuration node, that's quite a surprising workflow (but that would work; we could probably also have the boot script directly call the bootm command with the proper configuration node, but then one would have to find a way on how to select which boot script to use between each representing their own configuration node?).
Cheers,
Quentin